This commit is contained in:
@@ -72,13 +72,7 @@ uint32_t Analog_Value_Index_To_Instance(unsigned index)
|
|||||||
/* that correlates to the correct instance number */
|
/* that correlates to the correct instance number */
|
||||||
unsigned Analog_Value_Instance_To_Index(uint32_t object_instance)
|
unsigned Analog_Value_Instance_To_Index(uint32_t object_instance)
|
||||||
{
|
{
|
||||||
unsigned index = MAX_ANALOG_VALUES;
|
return object_instance;
|
||||||
|
|
||||||
Analog_Value_Init();
|
|
||||||
if (object_instance < MAX_ANALOG_VALUES)
|
|
||||||
index = object_instance;
|
|
||||||
|
|
||||||
return index;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* note: the object name must be unique within this device */
|
/* note: the object name must be unique within this device */
|
||||||
@@ -151,7 +145,6 @@ int Analog_Value_Encode_Property_APDU(uint8_t * apdu,
|
|||||||
return apdu_len;
|
return apdu_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
/* returns true if successful */
|
/* returns true if successful */
|
||||||
bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code)
|
||||||
@@ -159,11 +152,9 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
|||||||
bool status = false; /* return value */
|
bool status = false; /* return value */
|
||||||
unsigned int object_index = 0;
|
unsigned int object_index = 0;
|
||||||
unsigned int priority = 0;
|
unsigned int priority = 0;
|
||||||
uint8_t level = ANALOG_LEVEL_NULL;
|
|
||||||
int len = 0;
|
int len = 0;
|
||||||
BACNET_APPLICATION_DATA_VALUE value;
|
BACNET_APPLICATION_DATA_VALUE value;
|
||||||
|
|
||||||
Analog_Value_Init();
|
|
||||||
if (!Analog_Value_Valid_Instance(wp_data->object_instance)) {
|
if (!Analog_Value_Valid_Instance(wp_data->object_instance)) {
|
||||||
*error_class = ERROR_CLASS_OBJECT;
|
*error_class = ERROR_CLASS_OBJECT;
|
||||||
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
*error_code = ERROR_CODE_UNKNOWN_OBJECT;
|
||||||
@@ -184,12 +175,11 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
|||||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||||
(priority != 6 /* reserved */ ) &&
|
(priority != 6 /* reserved */ ) &&
|
||||||
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
|
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
|
||||||
level = (uint8_t) value.type.Real;
|
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Value_Instance_To_Index(wp_data->
|
Analog_Value_Instance_To_Index(wp_data->
|
||||||
object_instance);
|
object_instance);
|
||||||
priority--;
|
priority--;
|
||||||
Present_Value[object_index] = level;
|
Present_Value[object_index] = value.type.Real;
|
||||||
/* Note: you could set the physical output here if we
|
/* Note: you could set the physical output here if we
|
||||||
are the highest priority.
|
are the highest priority.
|
||||||
However, if Out of Service is TRUE, then don't set the
|
However, if Out of Service is TRUE, then don't set the
|
||||||
@@ -253,7 +243,6 @@ bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
|||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef TEST
|
#ifdef TEST
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|||||||
@@ -36,9 +36,9 @@
|
|||||||
#include "version.h"
|
#include "version.h"
|
||||||
/* objects */
|
/* objects */
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "ai.h"
|
|
||||||
#if 0
|
|
||||||
#include "av.h"
|
#include "av.h"
|
||||||
|
#if 0
|
||||||
|
#include "ai.h"
|
||||||
#include "bi.h"
|
#include "bi.h"
|
||||||
#include "bv.h"
|
#include "bv.h"
|
||||||
#include "wp.h"
|
#include "wp.h"
|
||||||
@@ -105,12 +105,12 @@ unsigned Device_Object_List_Count(void)
|
|||||||
unsigned count = 1; /* at least 1 for device object */
|
unsigned count = 1; /* at least 1 for device object */
|
||||||
|
|
||||||
/* FIXME: add objects as needed */
|
/* FIXME: add objects as needed */
|
||||||
count += Analog_Input_Count();
|
|
||||||
#if 0
|
#if 0
|
||||||
|
count += Analog_Input_Count();
|
||||||
count += Binary_Input_Count();
|
count += Binary_Input_Count();
|
||||||
count += Binary_Value_Count();
|
count += Binary_Value_Count();
|
||||||
count += Analog_Value_Count();
|
|
||||||
#endif
|
#endif
|
||||||
|
count += Analog_Value_Count();
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@@ -136,6 +136,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
|||||||
object_count = 1;
|
object_count = 1;
|
||||||
/* FIXME: add objects as needed */
|
/* FIXME: add objects as needed */
|
||||||
/* analog input objects */
|
/* analog input objects */
|
||||||
|
#if 0
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* array index starts at 1, and 1 for the device object */
|
/* array index starts at 1, and 1 for the device object */
|
||||||
object_index -= object_count;
|
object_index -= object_count;
|
||||||
@@ -146,7 +147,6 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
|||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
/* binary value objects */
|
/* binary value objects */
|
||||||
if (!status) {
|
if (!status) {
|
||||||
object_index -= object_count;
|
object_index -= object_count;
|
||||||
@@ -158,6 +158,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
|||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
/* analog value objects */
|
/* analog value objects */
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* array index starts at 1, and 1 for the device object */
|
/* array index starts at 1, and 1 for the device object */
|
||||||
@@ -169,6 +170,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
|||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
/* binary input objects */
|
/* binary input objects */
|
||||||
if (!status) {
|
if (!status) {
|
||||||
/* normalize the index since
|
/* normalize the index since
|
||||||
@@ -267,9 +269,9 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
|
|||||||
}
|
}
|
||||||
/* FIXME: indicate the objects that YOU support */
|
/* FIXME: indicate the objects that YOU support */
|
||||||
bitstring_set_bit(&bit_string, OBJECT_DEVICE, true);
|
bitstring_set_bit(&bit_string, OBJECT_DEVICE, true);
|
||||||
bitstring_set_bit(&bit_string, OBJECT_ANALOG_INPUT, true);
|
|
||||||
#if 0
|
|
||||||
bitstring_set_bit(&bit_string, OBJECT_ANALOG_VALUE, true);
|
bitstring_set_bit(&bit_string, OBJECT_ANALOG_VALUE, true);
|
||||||
|
#if 0
|
||||||
|
bitstring_set_bit(&bit_string, OBJECT_ANALOG_INPUT, true);
|
||||||
bitstring_set_bit(&bit_string, OBJECT_BINARY_VALUE, true);
|
bitstring_set_bit(&bit_string, OBJECT_BINARY_VALUE, true);
|
||||||
bitstring_set_bit(&bit_string, OBJECT_BINARY_INPUT, true);
|
bitstring_set_bit(&bit_string, OBJECT_BINARY_INPUT, true);
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -38,9 +38,9 @@
|
|||||||
#include "rp.h"
|
#include "rp.h"
|
||||||
/* demo objects */
|
/* demo objects */
|
||||||
#include "device.h"
|
#include "device.h"
|
||||||
#include "ai.h"
|
|
||||||
#if 0
|
|
||||||
#include "av.h"
|
#include "av.h"
|
||||||
|
#if 0
|
||||||
|
#include "ai.h"
|
||||||
#include "bi.h"
|
#include "bi.h"
|
||||||
#include "bv.h"
|
#include "bv.h"
|
||||||
#endif
|
#endif
|
||||||
@@ -74,9 +74,9 @@ int Encode_Property_APDU(
|
|||||||
error_class, error_code);
|
error_class, error_code);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case OBJECT_ANALOG_INPUT:
|
case OBJECT_ANALOG_VALUE:
|
||||||
if (Analog_Input_Valid_Instance(object_instance)) {
|
if (Analog_Value_Valid_Instance(object_instance)) {
|
||||||
apdu_len = Analog_Input_Encode_Property_APDU(
|
apdu_len = Analog_Value_Encode_Property_APDU(
|
||||||
&apdu[0],
|
&apdu[0],
|
||||||
object_instance,
|
object_instance,
|
||||||
property,
|
property,
|
||||||
|
|||||||
Reference in New Issue
Block a user