Git Product home page Git Product logo

bacnet.examples's People

Contributors

gralin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bacnet.examples's Issues

Error when subscribing data from PLC..

Hi, I am not so good in BACnet. But here is the problem.

I am using the SubscriptionManager from these examples (AnotherStorageImplementation).

We have a PLC which is trying to subscribe AnalogValue parameters from a Windows service which is based on BacnetActivity classes.

The problem is that the server decodes an error after bacnetClient.Notify function. The error comes in this function in BacnetClient class:

private void OnRecieve(IBacnetTransport sender, byte[] buffer, int offset, int msgLength, BacnetAddress remoteAddress)

The buffer[] contains the following data:
[0] 129
{1] 10
[2] 0
[3] 13
[4] 1
[5] 0
[6] 80
[7] 1
[8] 1
[9] 145
[10] 5
[11] 145
[12] 7
The offset parameter is 6 which points to 80 => Error

The subscribing works with Yabe.. but not with the PLC.

Exception schedule object not working as of Weekshedule flow, help needed!

Hello @gralin ,
I am trying to setup exception schedule as per week schedule setup in this example, schedule object get added successfully in virtual device, but defined exception schedule not getting added.
Below is the code i have implemented to achieve this.

[Serializable]
    class ExceptionScheduleTimeValue
    {
        public DateTime dt;
        public object Value;
        public ExceptionScheduleTimeValue(DateTime dt, object Value)
        {
            this.dt = dt;
            this.Value = Value;
        }
    }
[Serializable]
    class ExceptionScheduleArray
    {
        public List<ExceptionScheduleTimeValue>[] listOfTimeValues = new List<ExceptionScheduleTimeValue>[1];
        public DateTime period;
        public ExceptionScheduleArray(DateTime fdPeriod, List<ExceptionScheduleTimeValue>[] foExceptionScheduleTimeValue)
        {
            this.listOfTimeValues = foExceptionScheduleTimeValue;
            this.period = fdPeriod;
        }
    }
[Serializable]
    class BacnetWeeklyExceptionSchedule : ASN1.IEncode
    {
        public List<ExceptionScheduleArray>[] loExceptionScheduleArray = new List<ExceptionScheduleArray>[1];
        public void Encode(EncodeBuffer buffer)
        {
            for (int i = 0; i < loExceptionScheduleArray.Length; i++)
            {
                ASN1.encode_opening_tag(buffer, 0);
                List<ExceptionScheduleArray> loArray = loExceptionScheduleArray[i];
                var loExceptionScheduleTimeValue = loArray[i];
                ASN1.bacapp_encode_application_data(buffer, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_DATE, loArray[j].period));

                foreach (var ds in loExceptionScheduleTimeValue.listOfTimeValues)
                {
                    var loTime = ds[0].dt;
                    var loValue = ds[0].Value;

                    ASN1.bacapp_encode_application_data(buffer, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_TIME, loTime));
                    ASN1.bacapp_encode_application_data(buffer, new BacnetValue(loValue));
                }

                ASN1.encode_closing_tag(buffer, 0);
            }
        }
    }

Below is the object creation for exception schedule using structure defined above.


var loBacnetValue = new List<BacnetValue>();
var loNewPropertyValue = new BacnetPropertyValue();

BacnetWeeklyExceptionSchedule loBacnetWeeklyExceptionSchedule = new BacnetWeeklyExceptionSchedule();

DateTime ldDate = DateTime.Now.AddDays(1).AddMinutes(2);

List<ExceptionScheduleTimeValue>[] loExceptionSchedulTimeValue = new List<ExceptionScheduleTimeValue>[1];
loExceptionSchedulTimeValue[0] = new List<ExceptionScheduleTimeValue>();
loExceptionSchedulTimeValue[0].Add(new ExceptionScheduleTimeValue(ldDate, Convert.ToSingle(111)));

BACnetCalendarEntry loBACnetCalendarEntry = new BACnetCalendarEntry();
loBACnetCalendarEntry.Entries = new List<object>();
loBACnetCalendarEntry.Entries.Add(new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_DATE, DateTime.Today.AddDays(1)));

loBacnetWeeklyExceptionSchedule.loExceptionScheduleArray = new List<ExceptionScheduleArray>[1];
loBacnetWeeklyExceptionSchedule.loExceptionScheduleArray[0] = new List<ExceptionScheduleArray>();

loBacnetWeeklyExceptionSchedule.loExceptionScheduleArray[0].Add(new ExceptionScheduleArray(ldDate, loExceptionSchedulTimeValue));

loBacnetValue.Add(new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_SPECIAL_EVENT, loBacnetWeeklyExceptionSchedule));

loNewPropertyValue.value = loBacnetValue;
loNewPropertyValue.property = new BacnetPropertyReference((uint)BacnetPropertyIds.PROP_EXCEPTION_SCHEDULE, ASN1.BACNET_ARRAY_ALL);
loBacnetPropertyValueList.Add(loNewPropertyValue);

moBacnetClient.CreateObjectRequest(loBacnetAddress, new BacnetObjectId(BacnetObjectTypes.OBJECT_SCHEDULE, (uint)liTopInstanceID), loBacnetPropertyValueList);

I am newbie and looking around your SDK and BACnet implementation, Please help me on this
Thanks

ReadPropertyMultiple request without specifying BacnetPropertyReference->propertyArrayIndex

I am trying to send to server "ReadPropertyMultiple" request, however I am unable to read non-array BACNet properties, since the System.IO.BACnet.BacnetClient.ReadPropertyMultipleRequest requires list of System.IO.BACnet.BacnetPropertyReference(s) ...

public bool ReadPropertyMultipleRequest(BacnetAddress address, BacnetObjectId objectId, IList<BacnetPropertyReference> propertyIdAndArrayIndex, out IList<BacnetReadAccessResult> values, byte invokeId = 0);

.. and the System.IO.BACnet.BacnetPropertyReference requires propertyArrayIndex ..

    public struct BacnetPropertyReference
    {
        public uint propertyIdentifier;
        public uint propertyArrayIndex;

        public BacnetPropertyReference(uint id, uint arrayIndex);

        public BacnetPropertyIds GetPropertyId();
        public override string ToString();
    }

.. which, when not set, defaults to 0. This causes, that after request with this list is sent, all properties are requested with propertyArrayIndex: 0, which fail for non-array object properties.

Is there any way to not add the propertyArrayIndex into request and thus be able to read non-array properties with ReadPropertyMultiple request?

Thanks

SendWhoIsRouterToNetwork

Hi,
I am trying to use the source code for discovering the network and I want to use WhoIsRouterToNetwork request but I don't find any reference to it in the source code.

My goal is to retrieve all of the routers which are behind the bbmd IP that I have.

This is my code:

public HashSet<BacnetDeviceNode> WhoIs()
  {
      _bacnetClient.OnIam += OnIAmResponse;
      _bacnetClient.RegisterAsForeignDevice(_ipAddress, 10);
      _bacnetClient.RemoteWhoIs(_ipAddress);

      _whoIsResponseTimer.Elapsed += OnWhoIsResponseTimerElapsed;
      _whoIsResponseTimer.Start();

      _autoResetEvent.WaitOne();
      return _discoveredDevices;
  }

in this section of code, I use BacnetClient object that I have created, and register my bbmd as foreign device and send RemoteWhoIs (in addition I open a timer of 3 seconds for retreiving all of the aware devices).
I retrieve the I-Am Device of the devices that the bbmd knows but not the devices which are connected to other routers that behind the bbmd (those that I can discover if I would get I-Am Router-To-Network).

This is a pcap for other bacnet discover tool from other programming langauge:

Send Who-Is-Router-To-Network
image

Retrieve response of I-Am-Router-To-Network
image

The I-Am-Router-To-Network response data
image

In this pcap you can see that I-Am-Router-To-Network response has a parameter of IP that defines a router behind the bbmd.

So my question is, how can I send this request so I could get all of the routers that behind the bbmd, or if there is another way to get the whole devices of a bbmd?

AnotherStorageImplementation example and BBMD..?

Hi,

Thank you very much for the great library. I made an application based on the AnotherStorageImplementation project.

Now the problem is that I have to add BBMD support and cannot make it. The BBMD example uses a different approach and have not succeeded to integrate the BBMD.

All my BACnet devices are created dynamically from the SQL server and the AnotherStorageImplementation example is great for that. Please, can you help to integrate the BBMD into it? This is my first BACnet project..

Thank you :-)
Ilkka

AlarmSummaryOrEventRequest

Hello, the examples are containing an Alarm Listener, but I have nothing found, how I could write an Alarm Sender.

Or how I must answer of an OnGetAlarmSummaryOrEventRequest

Please could you add such a sample to the Examples.

Best Regards,
mgrontzki

Correct PRESENT_VALUE type of BINARY_OBJECT at BACnet.Room.Simulator

BACnet room simulator's Binary Objects PRESENT VALUES are defined as BOOLEAN. Per BACnet specification present value need to be ENUMERATED.

Could you fix this?

DeviceStorage.xml

Property Id="PROP_PRESENT_VALUE" Tag="BACNET_APPLICATION_TAG_ENUMERATED">
          <Value>0</Value>
</Property>

Form1.cs, line 249,250

 BacnetActivity.SetBacObjectPresentValue(Bac_Cmdchauffage, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED,Convert.ToUInt32(ModeChauf)));
            BacnetActivity.SetBacObjectPresentValue(Bac_CmdClim, new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED, Convert.ToUInt32(ModeClim)));

Thx.

Not able to make it work BasicAlarmListener

Hello,

I am trying to understood BACnet, stuck with below event not calling on defined device

bacnet_client.OnEventNotify += new BacnetClient.EventNotificationCallbackHandler(handler_OnEventNotify);

Below handler is never called even i change present value below/above limit and event state gets changes in sacada simulator. I have tried with Analog value, Analog input object for device(deviceID: 2000, instance id: 0)

static void handler_OnEventNotify(BacnetClient sender, BacnetAddress adr, BacnetEventNotificationData EventData)
       {
           string val = adr.ToString() + ":" + EventData.initiatingObjectIdentifier.type + ":" + EventData.initiatingObjectIdentifier.instance + ":" + EventData.eventObjectIdentifier.type + ":" + EventData.eventObjectIdentifier.instance;
           Console.WriteLine(val + " " + EventData.fromState + " to " + EventData.toState + " " + EventData.notifyType.ToString());
       }

Please help me on this
Thanks

Get NullReferenceException when reading analog input

Hi, Im using the simple read and write example in github for reading an analog input from my BACNET device through mstp. But I keep getting null reference exception when reading the analoginput. And i can detect the BACNET device in StartActivity(). And YABE was able to do the reading for the device.

Did you have any idea what cause this error?

The detailed error was also posted in StackOverflow:https://stackoverflow.com/questions/76298222/getting-a-null-error-exception-when-trying-to-read-analog-input-from-a-bacnet-de

Thanks a lot if you could help

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.