@@ -63,13 +63,13 @@ time_t g_warmStartTimer; // Timer used for delaying the warm start.
63
63
64
64
// Constants
65
65
// =======================================
66
- const std::string APPLICATION_VERSION = " 0 .0.26 " ; // See CHANGELOG.md for a full list of changes.
66
+ const std::string APPLICATION_VERSION = " 1 .0.0 " ; // See CHANGELOG.md for a full list of changes.
67
67
const uint32_t MAX_RENDER_BUFFER_LENGTH = 1024 * 20 ;
68
68
69
69
70
70
// Callback Functions to Register to the DLL
71
71
// Message Functions
72
- uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * receivedConnectionString, const uint8_t maxConnectionStringLength , uint8_t * receivedConnectionStringLength , uint8_t * networkType);
72
+ uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * sourceConnectionString, uint8_t * sourceConnectionStringLength, uint8_t * destinationConnectionString , uint8_t * destinationConnectionStringLength, const uint8_t maxConnectionStringLength , uint8_t * networkType);
73
73
uint16_t CallbackSendMessage (const uint8_t * message, const uint16_t messageLength, const uint8_t * connectionString, const uint8_t connectionStringLength, const uint8_t networkType, bool broadcast);
74
74
75
75
// System Functions
@@ -201,7 +201,7 @@ int main(int argc, char** argv)
201
201
}
202
202
203
203
// Call the DLLs loop function which checks for messages and processes them.
204
- fpLoop ();
204
+ fpTick ();
205
205
206
206
// Handle any user input.
207
207
// Note: User input in this example is used for the following:
@@ -655,6 +655,18 @@ bool SetupDevice() {
655
655
}
656
656
std::cout << " OK" << std::endl;
657
657
658
+ // AnalogInput - OutOfService Example (AI)
659
+ std::cout << " Added AnalogInput OutOfService Example. analogInputOutOfService.instance=[" << g_exampleDatabase.analogInputOutOfService .instance << " ]... " ;
660
+ if (!fpAddObject (g_exampleDatabase.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, g_exampleDatabase.analogInputOutOfService .instance )) {
661
+ std::cerr << " Failed to add AnalogInput OutOfService Example" << std::endl;
662
+ return -1 ;
663
+ }
664
+
665
+ // Make out of service writable
666
+ fpSetPropertyWritable (g_exampleDatabase.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, g_exampleDatabase.analogInputOutOfService .instance , CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_OUT_OF_SERVICE, true );
667
+
668
+ std::cout << " OK" << std::endl;
669
+
658
670
// Add the Network Port Object
659
671
std::cout << " Added NetworkPort. networkPort.instance=[" << g_exampleDatabase.networkPort .instance << " ]... " ;
660
672
if (!fpAddNetworkPortObject (g_exampleDatabase.device .instance , g_exampleDatabase.networkPort .instance , CASBACnetStackExampleConstants::NETWORK_TYPE_IPV4, CASBACnetStackExampleConstants::PROTOCOL_LEVEL_BACNET_APPLICATION, CASBACnetStackExampleConstants::NETWORK_PORT_LOWEST_PROTOCOL_LAYER)) {
@@ -879,14 +891,14 @@ bool DoUserInput()
879
891
}
880
892
881
893
// Callback used by the BACnet Stack to check if there is a message to process
882
- uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * receivedConnectionString, const uint8_t maxConnectionStringLength , uint8_t * receivedConnectionStringLength , uint8_t * networkType)
894
+ uint16_t CallbackReceiveMessage (uint8_t * message, const uint16_t maxMessageLength, uint8_t * sourceConnectionString, uint8_t * sourceConnectionStringLength, uint8_t * destinationConnectionString , uint8_t * destinationConnectionStringLength, const uint8_t maxConnectionStringLength , uint8_t * networkType)
883
895
{
884
896
// Check parameters
885
897
if (message == NULL || maxMessageLength == 0 ) {
886
898
std::cerr << " Invalid input buffer" << std::endl;
887
899
return 0 ;
888
900
}
889
- if (receivedConnectionString == NULL || maxConnectionStringLength == 0 ) {
901
+ if (sourceConnectionString == NULL || maxConnectionStringLength == 0 ) {
890
902
std::cerr << " Invalid connection string buffer" << std::endl;
891
903
return 0 ;
892
904
}
@@ -905,14 +917,14 @@ uint16_t CallbackReceiveMessage(uint8_t* message, const uint16_t maxMessageLengt
905
917
std::cout << std::endl << " FYI: Received message from [" << ipAddress << " :" << port << " ], length [" << bytesRead << " ]" << std::endl;
906
918
907
919
// Convert the IP Address to the connection string
908
- if (!ChipkinCommon::ChipkinConvert::IPAddressToBytes (ipAddress, receivedConnectionString , maxConnectionStringLength)) {
920
+ if (!ChipkinCommon::ChipkinConvert::IPAddressToBytes (ipAddress, sourceConnectionString , maxConnectionStringLength)) {
909
921
std::cerr << " Failed to convert the ip address into a connectionString" << std::endl;
910
922
return 0 ;
911
923
}
912
- receivedConnectionString [4 ] = port / 256 ;
913
- receivedConnectionString [5 ] = port % 256 ;
924
+ sourceConnectionString [4 ] = port / 256 ;
925
+ sourceConnectionString [5 ] = port % 256 ;
914
926
915
- *receivedConnectionStringLength = 6 ;
927
+ *sourceConnectionStringLength = 6 ;
916
928
*networkType = CASBACnetStackExampleConstants::NETWORK_TYPE_IP;
917
929
918
930
/*
@@ -1108,6 +1120,13 @@ bool CallbackGetPropertyBool(uint32_t deviceInstance, uint16_t objectType, uint3
1108
1120
return true ;
1109
1121
}
1110
1122
}
1123
+ // AnalogInput - OutOfService Example
1124
+ else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_OUT_OF_SERVICE) {
1125
+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1126
+ *value = g_exampleDatabase.analogInputOutOfService .outOfService ;
1127
+ return true ;
1128
+ }
1129
+ }
1111
1130
return false ;
1112
1131
}
1113
1132
@@ -1134,6 +1153,13 @@ bool CallbackGetPropertyCharString(const uint32_t deviceInstance, const uint16_t
1134
1153
return true ;
1135
1154
}
1136
1155
}
1156
+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1157
+ if (g_exampleDatabase.analogInputOutOfService .description .size () <= maxElementCount) {
1158
+ memcpy (value, g_exampleDatabase.analogInputOutOfService .description .c_str (), g_exampleDatabase.analogInputOutOfService .description .size ());
1159
+ *valueElementCount = (uint32_t )g_exampleDatabase.analogInputOutOfService .description .size ();
1160
+ return true ;
1161
+ }
1162
+ }
1137
1163
return false ;
1138
1164
}
1139
1165
// Example of Character String Value Object Present Value property
@@ -1309,6 +1335,16 @@ bool CallbackGetPropertyEnum(uint32_t deviceInstance, uint16_t objectType, uint3
1309
1335
*value = g_exampleDatabase.analogInput .reliability ;
1310
1336
return true ;
1311
1337
}
1338
+ // Analog Input - OutOfService Example
1339
+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1340
+ if (g_exampleDatabase.analogInputOutOfService .outOfService ) {
1341
+ *value = g_exampleDatabase.analogInputOutOfService .tempReliability ;
1342
+ }
1343
+ else {
1344
+ *value = g_exampleDatabase.analogInputOutOfService .reliability ;
1345
+ }
1346
+ return true ;
1347
+ }
1312
1348
}
1313
1349
// Network Port Object - FdBbmdAddress Host Type
1314
1350
else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_FD_BBMD_ADDRESS) {
@@ -1322,6 +1358,11 @@ bool CallbackGetPropertyEnum(uint32_t deviceInstance, uint16_t objectType, uint3
1322
1358
*value = g_exampleDatabase.analogInput .units ;
1323
1359
return true ;
1324
1360
}
1361
+ // Analog Input - OutOfService Example
1362
+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1363
+ *value = g_exampleDatabase.analogInputOutOfService .units ;
1364
+ return true ;
1365
+ }
1325
1366
}
1326
1367
1327
1368
// Debug for customer
@@ -1451,6 +1492,16 @@ bool CallbackGetPropertyReal(uint32_t deviceInstance, uint16_t objectType, uint3
1451
1492
*value = g_exampleDatabase.CreatedAnalogValueData [objectInstance].value ;
1452
1493
return true ;
1453
1494
}
1495
+ // Check if this is for the analog input out of service example
1496
+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1497
+ if (g_exampleDatabase.analogInputOutOfService .outOfService ) {
1498
+ *value = g_exampleDatabase.analogInputOutOfService .tempPresentValue ;
1499
+ }
1500
+ else {
1501
+ *value = g_exampleDatabase.analogInputOutOfService .presentValue ;
1502
+ }
1503
+ return true ;
1504
+ }
1454
1505
}
1455
1506
// Example of Analog Output Priority Array property
1456
1507
else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_PRIORITY_ARRAY) {
@@ -1470,7 +1521,7 @@ bool CallbackGetPropertyReal(uint32_t deviceInstance, uint16_t objectType, uint3
1470
1521
}
1471
1522
}
1472
1523
else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_COV_INCURMENT && objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInput .instance ) {
1473
- *value = g_exampleDatabase.analogInput .covIncurment ;
1524
+ *value = g_exampleDatabase.analogInput .covIncrement ;
1474
1525
return true ;
1475
1526
}
1476
1527
else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_MAX_PRES_VALUE && objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_VALUE && objectInstance == g_exampleDatabase.analogValue .instance ) {
@@ -1693,6 +1744,16 @@ bool CallbackSetPropertyBitString(const uint32_t deviceInstance, const uint16_t
1693
1744
// Callback used by the BACnet Stack to set Boolean property values to the user
1694
1745
bool CallbackSetPropertyBool (const uint32_t deviceInstance, const uint16_t objectType, const uint32_t objectInstance, const uint32_t propertyIdentifier, const bool value, const bool useArrayIndex, const uint32_t propertyArrayIndex, const uint8_t priority, uint32_t * errorCode)
1695
1746
{
1747
+ if (deviceInstance == g_exampleDatabase.device .instance ) {
1748
+ // AnalogInput - OutOfService Example
1749
+ if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_OUT_OF_SERVICE) {
1750
+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1751
+ g_exampleDatabase.analogInputOutOfService .outOfService = value;
1752
+ return true ;
1753
+ }
1754
+ }
1755
+ }
1756
+
1696
1757
return false ;
1697
1758
}
1698
1759
@@ -1785,6 +1846,15 @@ bool CallbackSetPropertyEnum(const uint32_t deviceInstance, const uint16_t objec
1785
1846
return true ;
1786
1847
}
1787
1848
}
1849
+ else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_RELIABILITY) {
1850
+ // Example of setting reliability to an object that is OutOfService
1851
+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
1852
+ if (g_exampleDatabase.analogInputOutOfService .outOfService ) {
1853
+ g_exampleDatabase.analogInputOutOfService .tempReliability = value;
1854
+ return true ;
1855
+ }
1856
+ }
1857
+ }
1788
1858
}
1789
1859
return false ;
1790
1860
}
@@ -1936,10 +2006,17 @@ bool CallbackSetPropertyReal(const uint32_t deviceInstance, const uint16_t objec
1936
2006
g_exampleDatabase.CreatedAnalogValueData [objectInstance].value = value;
1937
2007
return true ;
1938
2008
}
2009
+ // Example of setting presentValue to an object that is OutOfService
2010
+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
2011
+ if (g_exampleDatabase.analogInputOutOfService .outOfService ) {
2012
+ g_exampleDatabase.analogInputOutOfService .tempPresentValue = value;
2013
+ return true ;
2014
+ }
2015
+ }
1939
2016
}
1940
2017
else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_COV_INCURMENT) {
1941
2018
if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInput .instance ) {
1942
- g_exampleDatabase.analogInput .covIncurment = value;
2019
+ g_exampleDatabase.analogInput .covIncrement = value;
1943
2020
return true ;
1944
2021
}
1945
2022
}
@@ -2248,6 +2325,16 @@ bool GetObjectName(const uint32_t deviceInstance, const uint16_t objectType, con
2248
2325
*valueElementCount = (uint32_t ) stringSize;
2249
2326
return true ;
2250
2327
}
2328
+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_exampleDatabase.analogInputOutOfService .instance ) {
2329
+ stringSize = g_exampleDatabase.analogInputOutOfService .objectName .size ();
2330
+ if (stringSize > maxElementCount) {
2331
+ std::cerr << " Error - not enough space to store full name of objectType=[" << objectType << " ], objectInstance=[" << objectInstance << " ]" << std::endl;
2332
+ return false ;
2333
+ }
2334
+ memcpy (value, g_exampleDatabase.analogInputOutOfService .objectName .c_str (), stringSize);
2335
+ *valueElementCount = (uint32_t )stringSize;
2336
+ return true ;
2337
+ }
2251
2338
else {
2252
2339
// Check if the value is an Analog Value and check if it was a created object
2253
2340
if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_VALUE && g_exampleDatabase.CreatedAnalogValueData .count (objectInstance) > 0 ) {
@@ -2412,3 +2499,4 @@ bool HookTextMessage(const uint32_t sourceDeviceIdentifier, const bool useMessag
2412
2499
return false ;
2413
2500
}
2414
2501
2502
+
0 commit comments