public CallbacksImpl(ICallbacks callbacks) { _callbacks = callbacks; _isTypeValidDelegate = IsTypeValid; GCHandle.Alloc(_isTypeValidDelegate); _releaseNetReferenceDelegate = ReleaseNetReference; GCHandle.Alloc(_releaseNetReferenceDelegate); _releaseNetDelegateGCHandleDelegate = ReleaseNetDelegateGCHandle; GCHandle.Alloc(_releaseNetDelegateGCHandleDelegate); _createLazyTypeInfoDelegate = CreateLazyTypeInfo; GCHandle.Alloc(_createLazyTypeInfoDelegate); _loadTypeInfoDelegate = LoadTypeInfo; GCHandle.Alloc(_loadTypeInfoDelegate); _instantiateTypeDelgate = InstantiateType; GCHandle.Alloc(_instantiateTypeDelgate); _callComponentCompletedDelegate = CallComponentCompleted; GCHandle.Alloc(_callComponentCompletedDelegate); _callObjectDestroyedDelegate = CallObjectDestroyed; GCHandle.Alloc(_callObjectDestroyedDelegate); _readPropertyDelegate = ReadProperty; GCHandle.Alloc(_readPropertyDelegate); _writePropertyDelegate = WriteProperty; GCHandle.Alloc(_writePropertyDelegate); _invokeMethodDelegate = InvokeMethod; GCHandle.Alloc(_invokeMethodDelegate); _gcCollectDelegate = GCCollect; GCHandle.Alloc(_gcCollectDelegate); _raiseNetSignalsDelegate = RaiseNetSignals; GCHandle.Alloc(_raiseNetSignalsDelegate); _awaitTaskDelegate = AwaitTask; GCHandle.Alloc(_awaitTaskDelegate); _serializeDelegate = Serialize; GCHandle.Alloc(_serializeDelegate); _invokeDelegateDelegate = InvokeDelegate; GCHandle.Alloc(_invokeDelegateDelegate); }
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); }
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); }