This commit is contained in:
skarg
2007-10-19 04:11:20 +00:00
parent 1f8a8b6f84
commit 740bb873be
3 changed files with 16 additions and 25 deletions
+2 -13
View File
@@ -72,13 +72,7 @@ uint32_t Analog_Value_Index_To_Instance(unsigned index)
/* that correlates to the correct instance number */
unsigned Analog_Value_Instance_To_Index(uint32_t object_instance)
{
unsigned index = MAX_ANALOG_VALUES;
Analog_Value_Init();
if (object_instance < MAX_ANALOG_VALUES)
index = object_instance;
return index;
return object_instance;
}
/* 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;
}
#if 0
/* returns true if successful */
bool Analog_Value_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
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 */
unsigned int object_index = 0;
unsigned int priority = 0;
uint8_t level = ANALOG_LEVEL_NULL;
int len = 0;
BACNET_APPLICATION_DATA_VALUE value;
Analog_Value_Init();
if (!Analog_Value_Valid_Instance(wp_data->object_instance)) {
*error_class = ERROR_CLASS_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) &&
(priority != 6 /* reserved */ ) &&
(value.type.Real >= 0.0) && (value.type.Real <= 100.0)) {
level = (uint8_t) value.type.Real;
object_index =
Analog_Value_Instance_To_Index(wp_data->
object_instance);
priority--;
Present_Value[object_index] = level;
Present_Value[object_index] = value.type.Real;
/* Note: you could set the physical output here if we
are the highest priority.
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;
}
#endif
#ifdef TEST
#include <assert.h>
+9 -7
View File
@@ -36,9 +36,9 @@
#include "version.h"
/* objects */
#include "device.h"
#include "ai.h"
#if 0
#include "av.h"
#if 0
#include "ai.h"
#include "bi.h"
#include "bv.h"
#include "wp.h"
@@ -105,12 +105,12 @@ unsigned Device_Object_List_Count(void)
unsigned count = 1; /* at least 1 for device object */
/* FIXME: add objects as needed */
count += Analog_Input_Count();
#if 0
count += Analog_Input_Count();
count += Binary_Input_Count();
count += Binary_Value_Count();
count += Analog_Value_Count();
#endif
count += Analog_Value_Count();
return count;
}
@@ -136,6 +136,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
object_count = 1;
/* FIXME: add objects as needed */
/* analog input objects */
#if 0
if (!status) {
/* array index starts at 1, and 1 for the device object */
object_index -= object_count;
@@ -146,7 +147,6 @@ bool Device_Object_List_Identifier(unsigned array_index,
status = true;
}
}
#if 0
/* binary value objects */
if (!status) {
object_index -= object_count;
@@ -158,6 +158,7 @@ bool Device_Object_List_Identifier(unsigned array_index,
status = true;
}
}
#endif
/* analog value objects */
if (!status) {
/* 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;
}
}
#if 0
/* binary input objects */
if (!status) {
/* normalize the index since
@@ -267,9 +269,9 @@ int Device_Encode_Property_APDU(uint8_t * apdu,
}
/* FIXME: indicate the objects that YOU support */
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);
#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_INPUT, true);
#endif
+5 -5
View File
@@ -38,9 +38,9 @@
#include "rp.h"
/* demo objects */
#include "device.h"
#include "ai.h"
#if 0
#include "av.h"
#if 0
#include "ai.h"
#include "bi.h"
#include "bv.h"
#endif
@@ -74,9 +74,9 @@ int Encode_Property_APDU(
error_class, error_code);
}
break;
case OBJECT_ANALOG_INPUT:
if (Analog_Input_Valid_Instance(object_instance)) {
apdu_len = Analog_Input_Encode_Property_APDU(
case OBJECT_ANALOG_VALUE:
if (Analog_Value_Valid_Instance(object_instance)) {
apdu_len = Analog_Value_Encode_Property_APDU(
&apdu[0],
object_instance,
property,