Inheritance: IBacNetApdu
Beispiel #1
0
        public void WriteProperty(uint instanceId, BacNetObject bacNetObject, BacNetEnums.BACNET_PROPERTY_ID propertyId, ArrayList valueList, WritePropertyDelegate callBack = null)
        {
            var apdu = new WriteProperty(bacNetObject, propertyId, valueList);

            apdu.InstanceId = instanceId;
            apdu.CallBack   = callBack;
            var npdu = new BacNetIpNpdu();

            npdu.ExpectingReply = true;
            IPEndPoint endPoint = null;

            foreach (BacNetRemoteDevice remoteDevice in BacNetDevice.Instance.Remote)
            {
                if (remoteDevice.InstanceNumber == instanceId)
                {
                    npdu.Destination = remoteDevice.BacAddress;
                    endPoint         = remoteDevice.EndPoint;
                }
            }

            lock (_writePropertyPool)
            {
                if (_writePropertyPool.ContainsKey(apdu.InvokeId))
                {
                    _writePropertyPool[apdu.InvokeId].CallBack(_writePropertyPool[apdu.InvokeId].InstanceId, null, null);
                    _writePropertyPool.Remove(apdu.InvokeId);
                }
                _writePropertyPool.Add(apdu.InvokeId, apdu);
            }

            BacNetDevice.Instance.Services.Execute(npdu, apdu, endPoint);
        }
Beispiel #2
0
        public void WriteProperty(uint instanceId, BacNetObject bacNetObject, BacNetEnums.BACNET_PROPERTY_ID propertyId, ArrayList valueList, WritePropertyDelegate callBack = null)
        {
            var apdu = new WriteProperty(bacNetObject, propertyId, valueList);
            apdu.InstanceId = instanceId;
            apdu.CallBack = callBack;
            var npdu = new BacNetIpNpdu();
            npdu.ExpectingReply = true;
            IPEndPoint endPoint = null;
            foreach (BacNetRemoteDevice remoteDevice in BacNetDevice.Instance.Remote)
            {
                if (remoteDevice.InstanceNumber == instanceId)
                {
                    npdu.Destination = remoteDevice.BacAddress;
                    endPoint = remoteDevice.EndPoint;
                }
            }

            lock (_writePropertyPool)
            {
                if (_writePropertyPool.ContainsKey(apdu.InvokeId))
                {
                    _writePropertyPool[apdu.InvokeId].CallBack(_writePropertyPool[apdu.InvokeId].InstanceId, null, null);
                    _writePropertyPool.Remove(apdu.InvokeId);
                }
                _writePropertyPool.Add(apdu.InvokeId, apdu);
            }

            BacNetDevice.Instance.Services.Execute(npdu, apdu, endPoint);
        }