@@ -86,7 +86,7 @@ int main()
86
86
return 0 ;
87
87
}
88
88
std::cout << " OK" << std::endl;
89
- std::cout << " FYI: BACnet Stack version: " << fpGetAPIMajorVersion () << " ." << fpGetAPIMinorVersion () << " ." << fpGetAPIPatchVersion () << " ." << fpGetAPIBuildVersion () << std::endl;
89
+ std::cout << " FYI: CAS BACnet Stack version: " << fpGetAPIMajorVersion () << " ." << fpGetAPIMinorVersion () << " ." << fpGetAPIPatchVersion () << " ." << fpGetAPIBuildVersion () << std::endl;
90
90
91
91
// 2. Connect the UDP resource to the BACnet Port
92
92
// ---------------------------------------------------------------------------
@@ -157,10 +157,7 @@ int main()
157
157
158
158
// Enable the services that this device supports
159
159
// Some services are mandatory for BACnet devices and are already enabled.
160
- // These are:
161
- // Read Property
162
- // Who Is
163
- // Who Has
160
+ // These are: Read Property, Who Is, Who Has
164
161
//
165
162
// Any other services need to be enabled as below.
166
163
@@ -241,6 +238,7 @@ int main()
241
238
return false ;
242
239
}
243
240
241
+
244
242
// Update Writable Device Properties
245
243
// UTC Offset
246
244
if (!fpSetPropertyWritable (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_DEVICE, g_database.device .instance , CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_UTC_OFFSET, true )) {
@@ -288,7 +286,7 @@ int main()
288
286
fpSetPropertySubscribable (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, g_database.analogInput .instance , CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_PRESENT_VALUE, true );
289
287
fpSetPropertyWritable (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, g_database.analogInput .instance , CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_COV_INCURMENT, true );
290
288
291
- // Enable the description property
289
+ // Enable the description, and Reliabiliyty property
292
290
fpSetPropertyByObjectTypeEnabled (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_DESCRIPTION, true );
293
291
fpSetPropertyByObjectTypeEnabled (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT, CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_RELIABILITY, true );
294
292
@@ -347,6 +345,7 @@ int main()
347
345
std::cerr << " Failed to add MultiStateInput" << std::endl;
348
346
return -1 ;
349
347
}
348
+ fpSetPropertyByObjectTypeEnabled (g_database.device .instance , CASBACnetStackExampleConstants::OBJECT_TYPE_MULTI_STATE_INPUT, CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_STATE_TEXT, true );
350
349
std::cout << " OK" << std::endl;
351
350
352
351
// MultiStateOutput (MSO)
@@ -454,8 +453,6 @@ int main()
454
453
}
455
454
std::cout << " OK" << std::endl;
456
455
457
-
458
-
459
456
// 4. Send I-Am of this device
460
457
// ---------------------------------------------------------------------------
461
458
// To be a good citizen on a BACnet network. We should annouce ourselfs when we start up.
@@ -528,7 +525,7 @@ bool DoUserInput()
528
525
case ' i' : {
529
526
// Increment the Analog Value
530
527
g_database.analogValue .presentValue += 1 .1f ;
531
- std::cout << " Incrementing Analog Output to " << g_database.analogValue .presentValue << std::endl;
528
+ std::cout << " Incrementing Analog Value to " << g_database.analogValue .presentValue << std::endl;
532
529
533
530
// Notify the stack that this data point was updated so the stack can check for logic
534
531
// that may need to run on the data. Example: check if COV (change of value) occurred.
@@ -555,6 +552,9 @@ bool DoUserInput()
555
552
}
556
553
break ;
557
554
}
555
+ case ' d' : {
556
+ }
557
+
558
558
case ' h' :
559
559
default : {
560
560
// Print the Help
@@ -564,8 +564,9 @@ bool DoUserInput()
564
564
std::cout << " https://github.com/chipkin/BACnetServerExampleCPP" << std::endl << std::endl;
565
565
566
566
std::cout << " Help:" << std::endl;
567
- std::cout << " i - (i)ncrement Analog Value " << g_database.analogValue .instance << " by 1.1" << std::endl;
568
- std::cout << " r - Toggle the Analog Input (r)eliability status" << std::endl;
567
+ std::cout << " i - (i)ncrement Analog Value:2" << g_database.analogValue .instance << " by 1.1" << std::endl;
568
+ std::cout << " r - Toggle the Analog Input:0 (r)eliability status" << std::endl;
569
+ // std::cout << "d - (d)ebug" << std::endl;
569
570
std::cout << " h - (h)elp" << std::endl;
570
571
std::cout << " q - (q)uit" << std::endl;
571
572
std::cout << std::endl;
@@ -834,6 +835,13 @@ bool CallbackGetPropertyCharString(const uint32_t deviceInstance, const uint16_t
834
835
*valueElementCount = snprintf (value, maxElementCount, " Example custom property 512 + 3" );
835
836
return true ;
836
837
}
838
+ else if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_MULTI_STATE_INPUT && propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_STATE_TEXT && objectInstance == g_database.multiStateInput .instance ) {
839
+ if (useArrayIndex && propertyArrayIndex > 0 && propertyArrayIndex <= g_database.multiStateInput .numberOfStates ) {
840
+ // 0 is number of dates.
841
+ *valueElementCount = snprintf (value, maxElementCount, g_database.multiStateInput .stateText [propertyArrayIndex-1 ].c_str ());
842
+ return true ;
843
+ }
844
+ }
837
845
return false ;
838
846
}
839
847
@@ -915,6 +923,18 @@ bool CallbackGetPropertyEnum(uint32_t deviceInstance, uint16_t objectType, uint3
915
923
return true ;
916
924
}
917
925
}
926
+
927
+
928
+
929
+ // Debug for customer
930
+ if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_SYSTEM_STATUS &&
931
+ objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_DEVICE)
932
+ {
933
+ std::cout << " Debug: Device:System Status" << std::endl;
934
+ *value = 1 ;
935
+ return true ;
936
+ }
937
+
918
938
919
939
// We could not answer this request.
920
940
return false ;
@@ -1007,6 +1027,7 @@ bool CallbackGetPropertyInt(uint32_t deviceInstance, uint16_t objectType, uint32
1007
1027
// Callback used by the BACnet Stack to get Real property values from the user
1008
1028
bool CallbackGetPropertyReal (uint32_t deviceInstance, uint16_t objectType, uint32_t objectInstance, uint32_t propertyIdentifier, float * value, bool useArrayIndex, uint32_t propertyArrayIndex)
1009
1029
{
1030
+
1010
1031
// Example of Analog Input / Value Object Present Value property
1011
1032
if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_PRESENT_VALUE) {
1012
1033
if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_ANALOG_INPUT && objectInstance == g_database.analogInput .instance ) {
@@ -1157,6 +1178,12 @@ bool CallbackGetPropertyUInt(uint32_t deviceInstance, uint16_t objectType, uint3
1157
1178
return true ;
1158
1179
}
1159
1180
}
1181
+ else if (propertyIdentifier == CASBACnetStackExampleConstants::PROPERTY_IDENTIFIER_STATE_TEXT) {
1182
+ if (objectType == CASBACnetStackExampleConstants::OBJECT_TYPE_MULTI_STATE_INPUT && objectInstance == g_database.multiStateInput .instance ) {
1183
+ *value = g_database.multiStateInput .numberOfStates ;
1184
+ return true ;
1185
+ }
1186
+ }
1160
1187
return false ;
1161
1188
}
1162
1189
0 commit comments