ela-compil / BACnet

BACnet protocol library for .NET :satellite:
https://www.nuget.org/packages/bacnet/
MIT License
215 stars 95 forks source link

Problem with use Multi_State_Value #99

Closed cedricht closed 2 years ago

cedricht commented 2 years ago

Hi,

I can use the request for send present value for analag value and binary value. For this my code is ok

newValue = new BacnetValue(BacnetApplicationTags.BACNET_APPLICATION_TAG_ENUMERATED, Convert.ToSingle(value));
BacnetObjectId objectIdtToUse = BacnetObjectTypeConvert(TypeId, ObjectId);
request.requestSuccess =   WriteScalarValue(Device, objectIdtToUse, BacnetPropertyIds.PROP_PRESENT_VALUE, newValue);

When i will send a present value to MultiStateValue with this same code i have this message :

System.Exception: 'Error from device: ERROR_CLASS_PROPERTY - ERROR_CODE_INVALID_DATA_TYPE

I'm sure the problem is in my code. Does anyone have an example to write in bacnet one Multistate value.

Thank you for your answers

gralin commented 2 years ago

Present_Value property of Multi-state value object is of type Unsigned. You have to use BacnetApplicationTags.BACNET_APPLICATION_TAG_UNSIGNED_INT and send and integer value, not float.

image

cedricht commented 2 years ago

Hi,

I tried your recommendation.

It’s Ok, Think you for your Helping

Best Regard, Cédric