Refactored required writable property function from epics app (#743)
This commit is contained in:
+4
-92
@@ -325,96 +325,6 @@ static void Init_Service_Handlers(void)
|
||||
apdu_set_reject_handler(MyRejectHandler);
|
||||
}
|
||||
|
||||
/** Determine if this is a writable property, and, if so,
|
||||
* note that in the EPICS output.
|
||||
* This function may need a lot of customization for different implementations.
|
||||
*
|
||||
* @param object_type [in] The BACnet Object type of this object.
|
||||
* @note object_instance [in] The ID number for this object.
|
||||
* @param rpm_property [in] Points to structure holding the Property,
|
||||
* Value, and Error information.
|
||||
*/
|
||||
static void CheckIsWritableProperty(BACNET_OBJECT_TYPE object_type,
|
||||
/* uint32_t object_instance, */
|
||||
BACNET_PROPERTY_REFERENCE *rpm_property)
|
||||
{
|
||||
bool bIsWritable = false;
|
||||
if ((object_type == OBJECT_ANALOG_OUTPUT) ||
|
||||
(object_type == OBJECT_BINARY_OUTPUT) ||
|
||||
(object_type == OBJECT_COMMAND) ||
|
||||
(object_type == OBJECT_MULTI_STATE_OUTPUT) ||
|
||||
(object_type == OBJECT_ACCESS_DOOR)) {
|
||||
if (rpm_property->propertyIdentifier == PROP_PRESENT_VALUE) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if (object_type == OBJECT_AVERAGING) {
|
||||
if ((rpm_property->propertyIdentifier == PROP_ATTEMPTED_SAMPLES) ||
|
||||
(rpm_property->propertyIdentifier == PROP_WINDOW_INTERVAL) ||
|
||||
(rpm_property->propertyIdentifier == PROP_WINDOW_SAMPLES)) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if (object_type == OBJECT_FILE) {
|
||||
if (rpm_property->propertyIdentifier == PROP_ARCHIVE) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if ((object_type == OBJECT_LIFE_SAFETY_POINT) ||
|
||||
(object_type == OBJECT_LIFE_SAFETY_ZONE)) {
|
||||
if (rpm_property->propertyIdentifier == PROP_MODE) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if (object_type == OBJECT_PROGRAM) {
|
||||
if (rpm_property->propertyIdentifier == PROP_PROGRAM_CHANGE) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if (object_type == OBJECT_PULSE_CONVERTER) {
|
||||
if (rpm_property->propertyIdentifier == PROP_ADJUST_VALUE) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if ((object_type == OBJECT_TRENDLOG) ||
|
||||
(object_type == OBJECT_EVENT_LOG) ||
|
||||
(object_type == OBJECT_TREND_LOG_MULTIPLE)) {
|
||||
if ((rpm_property->propertyIdentifier == PROP_ENABLE) ||
|
||||
(rpm_property->propertyIdentifier == PROP_RECORD_COUNT)) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if (object_type == OBJECT_LOAD_CONTROL) {
|
||||
if ((rpm_property->propertyIdentifier == PROP_REQUESTED_SHED_LEVEL) ||
|
||||
(rpm_property->propertyIdentifier == PROP_START_TIME) ||
|
||||
(rpm_property->propertyIdentifier == PROP_SHED_DURATION) ||
|
||||
(rpm_property->propertyIdentifier == PROP_DUTY_WINDOW) ||
|
||||
(rpm_property->propertyIdentifier == PROP_SHED_LEVELS)) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if ((object_type == OBJECT_ACCESS_ZONE) ||
|
||||
(object_type == OBJECT_ACCESS_USER) ||
|
||||
(object_type == OBJECT_ACCESS_RIGHTS) ||
|
||||
(object_type == OBJECT_ACCESS_CREDENTIAL)) {
|
||||
if (rpm_property->propertyIdentifier == PROP_GLOBAL_IDENTIFIER) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
} else if (object_type == OBJECT_NETWORK_SECURITY) {
|
||||
if ((rpm_property->propertyIdentifier ==
|
||||
PROP_BASE_DEVICE_SECURITY_POLICY) ||
|
||||
(rpm_property->propertyIdentifier ==
|
||||
PROP_NETWORK_ACCESS_SECURITY_POLICIES) ||
|
||||
(rpm_property->propertyIdentifier == PROP_SECURITY_TIME_WINDOW) ||
|
||||
(rpm_property->propertyIdentifier == PROP_PACKET_REORDER_TIME) ||
|
||||
(rpm_property->propertyIdentifier == PROP_LAST_KEY_SERVER) ||
|
||||
(rpm_property->propertyIdentifier == PROP_SECURITY_PDU_TIMEOUT) ||
|
||||
(rpm_property->propertyIdentifier == PROP_DO_NOT_HIDE)) {
|
||||
bIsWritable = true;
|
||||
}
|
||||
}
|
||||
/* Add more checking here, eg for Time_Synchronization_Recipients,
|
||||
* Manual_Slave_Address_Binding, Object_Property_Reference,
|
||||
* Life Safety Tracking_Value, Reliability, Mode,
|
||||
* or Present_Value when Out_Of_Service is TRUE.
|
||||
*/
|
||||
if (bIsWritable) {
|
||||
fprintf(stdout, " Writable");
|
||||
}
|
||||
}
|
||||
|
||||
static const char *protocol_services_supported_text(size_t bit_index)
|
||||
{
|
||||
bool is_confirmed = false;
|
||||
@@ -738,8 +648,10 @@ static void PrintReadPropertyData(BACNET_OBJECT_TYPE object_type,
|
||||
/* Closing brace for this multi-valued array */
|
||||
fprintf(stdout, " }");
|
||||
}
|
||||
CheckIsWritableProperty(object_type, /* object_instance, */
|
||||
rpm_property);
|
||||
if (property_list_writable_member(object_type,
|
||||
rpm_property->propertyIdentifier)) {
|
||||
fprintf(stdout, " Writable");
|
||||
}
|
||||
fprintf(stdout, "\n");
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -1661,3 +1661,132 @@ bool property_list_bacnet_array_member(
|
||||
return property_list_member(Properties_BACnetARRAY, object_property);
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Determine if this property is required to be writable
|
||||
* @note Property Conformance Code of W means writable
|
||||
* @param object_type - object-type to be checked
|
||||
* @param object_property - object-property to be checked
|
||||
* @return true if the property is a required writable property
|
||||
*/
|
||||
bool property_list_writable_member(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID object_property)
|
||||
{
|
||||
bool writable = false;
|
||||
|
||||
switch (object_type) {
|
||||
case OBJECT_ANALOG_OUTPUT:
|
||||
case OBJECT_BINARY_OUTPUT:
|
||||
case OBJECT_MULTI_STATE_OUTPUT:
|
||||
case OBJECT_BINARY_LIGHTING_OUTPUT:
|
||||
case OBJECT_ACCESS_DOOR:
|
||||
case OBJECT_COMMAND:
|
||||
case OBJECT_STAGING:
|
||||
if (object_property == PROP_PRESENT_VALUE) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_AVERAGING:
|
||||
if ((object_property == PROP_ATTEMPTED_SAMPLES) ||
|
||||
(object_property == PROP_WINDOW_INTERVAL) ||
|
||||
(object_property == PROP_WINDOW_SAMPLES)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_FILE:
|
||||
if (object_property == PROP_ARCHIVE) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_LIFE_SAFETY_POINT:
|
||||
case OBJECT_LIFE_SAFETY_ZONE:
|
||||
if (object_property == PROP_MODE) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_PROGRAM:
|
||||
if (object_property == PROP_PROGRAM_CHANGE) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_PULSE_CONVERTER:
|
||||
if (object_property == PROP_ADJUST_VALUE) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_EVENT_LOG:
|
||||
case OBJECT_TRENDLOG:
|
||||
case OBJECT_TREND_LOG_MULTIPLE:
|
||||
if ((object_property == PROP_ENABLE) ||
|
||||
(object_property == PROP_RECORD_COUNT)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_LOAD_CONTROL:
|
||||
if ((object_property == PROP_REQUESTED_SHED_LEVEL) ||
|
||||
(object_property == PROP_START_TIME) ||
|
||||
(object_property == PROP_SHED_DURATION) ||
|
||||
(object_property == PROP_DUTY_WINDOW) ||
|
||||
(object_property == PROP_SHED_LEVELS)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_ACCESS_CREDENTIAL:
|
||||
case OBJECT_ACCESS_RIGHTS:
|
||||
case OBJECT_ACCESS_USER:
|
||||
case OBJECT_ACCESS_ZONE:
|
||||
if (object_property == PROP_GLOBAL_IDENTIFIER) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_NETWORK_SECURITY:
|
||||
if ((object_property == PROP_BASE_DEVICE_SECURITY_POLICY) ||
|
||||
(object_property == PROP_NETWORK_ACCESS_SECURITY_POLICIES) ||
|
||||
(object_property == PROP_SECURITY_TIME_WINDOW) ||
|
||||
(object_property == PROP_PACKET_REORDER_TIME) ||
|
||||
(object_property == PROP_LAST_KEY_SERVER) ||
|
||||
(object_property == PROP_SECURITY_PDU_TIMEOUT) ||
|
||||
(object_property == PROP_LAST_KEY_SERVER) ||
|
||||
(object_property == PROP_SECURITY_PDU_TIMEOUT) ||
|
||||
(object_property == PROP_DO_NOT_HIDE)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_NOTIFICATION_FORWARDER:
|
||||
if (object_property == PROP_SUBSCRIBED_RECIPIENTS) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_CHANNEL:
|
||||
if ((object_property == PROP_PRESENT_VALUE) ||
|
||||
(object_property == PROP_LIST_OF_OBJECT_PROPERTY_REFERENCES) ||
|
||||
(object_property == PROP_CHANNEL_NUMBER) ||
|
||||
(object_property == PROP_CONTROL_GROUPS)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_LIGHTING_OUTPUT:
|
||||
if ((object_property == PROP_PRESENT_VALUE) ||
|
||||
(object_property == PROP_LIGHTING_COMMAND)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_AUDIT_LOG:
|
||||
if (object_property == PROP_ENABLE) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
case OBJECT_COLOR:
|
||||
case OBJECT_COLOR_TEMPERATURE:
|
||||
if ((object_property == PROP_PRESENT_VALUE) ||
|
||||
(object_property == PROP_COLOR_COMMAND)) {
|
||||
writable = true;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return writable;
|
||||
}
|
||||
|
||||
@@ -47,6 +47,10 @@ extern "C" {
|
||||
bool property_list_bacnet_array_member(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID object_property);
|
||||
BACNET_STACK_EXPORT
|
||||
bool property_list_writable_member(
|
||||
BACNET_OBJECT_TYPE object_type,
|
||||
BACNET_PROPERTY_ID object_property);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user