Added Binary Output objects to the demos.
This commit is contained in:
@@ -53,14 +53,14 @@ static uint8_t
|
||||
static bool Analog_Output_Out_Of_Service[MAX_ANALOG_OUTPUTS];
|
||||
|
||||
/* we need to have our arrays initialized before answering any calls */
|
||||
static bool Analog_Ouput_Initialized = false;
|
||||
static bool Analog_Output_Initialized = false;
|
||||
|
||||
void Analog_Output_Init(void)
|
||||
{
|
||||
unsigned i, j;
|
||||
|
||||
if (!Analog_Ouput_Initialized) {
|
||||
Analog_Ouput_Initialized = true;
|
||||
if (!Analog_Output_Initialized) {
|
||||
Analog_Output_Initialized = true;
|
||||
|
||||
/* initialize all the analog output priority arrays to NULL */
|
||||
for (i = 0; i < MAX_ANALOG_OUTPUTS; i++) {
|
||||
@@ -163,6 +163,7 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
float real_value = 1.414;
|
||||
unsigned object_index = 0;
|
||||
unsigned i = 0;
|
||||
bool state = false;
|
||||
|
||||
Analog_Output_Init();
|
||||
switch (property) {
|
||||
@@ -196,7 +197,9 @@ int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], EVENT_STATE_NORMAL);
|
||||
break;
|
||||
case PROP_OUT_OF_SERVICE:
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], false);
|
||||
object_index = Analog_Output_Instance_To_Index(object_instance);
|
||||
state = Analog_Output_Out_Of_Service[object_index];
|
||||
apdu_len = encode_tagged_boolean(&apdu[0], state);
|
||||
break;
|
||||
case PROP_UNITS:
|
||||
apdu_len = encode_tagged_enumerated(&apdu[0], UNITS_PERCENT);
|
||||
@@ -283,6 +286,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
case PROP_PRESENT_VALUE:
|
||||
if (wp_data->value.tag == BACNET_APPLICATION_TAG_REAL) {
|
||||
priority = wp_data->priority;
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
object. */
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||
(priority != 6 /* reserved */ ) &&
|
||||
(wp_data->value.type.Real >= 0.0) &&
|
||||
@@ -293,11 +299,16 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
object_instance);
|
||||
priority--;
|
||||
Analog_Output_Level[object_index][priority] = level;
|
||||
/* if Out of Service is TRUE, then don't set the */
|
||||
/* physical output. This comment may apply to the */
|
||||
/* main loop (i.e. check out of service before changing output) */
|
||||
/* 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
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else if (priority == 6) {
|
||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||
algorithm and may not be used for other purposes in any
|
||||
object. */
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
*error_code = ERROR_CODE_WRITE_ACCESS_DENIED;
|
||||
} else {
|
||||
@@ -312,6 +323,12 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
if (priority && (priority <= BACNET_MAX_PRIORITY)) {
|
||||
priority--;
|
||||
Analog_Output_Level[object_index][priority] = level;
|
||||
/* Note: you could set the physical output here to the next
|
||||
highest priority, or to the relinquish default if no
|
||||
priorities are set.
|
||||
However, if Out of Service is TRUE, then don't set the
|
||||
physical output. This comment may apply to the
|
||||
main loop (i.e. check out of service before changing output) */
|
||||
status = true;
|
||||
} else {
|
||||
*error_class = ERROR_CLASS_PROPERTY;
|
||||
|
||||
@@ -65,7 +65,7 @@ uint32_t Binary_Input_Index_To_Instance(unsigned index)
|
||||
|
||||
void Binary_Input_Init(void)
|
||||
{
|
||||
bool initialized = false;
|
||||
static bool initialized = false;
|
||||
unsigned i;
|
||||
|
||||
if (!initialized) {
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
*********************************************************************/
|
||||
#ifndef AO_H
|
||||
#define AO_H
|
||||
#ifndef BO_H
|
||||
#define BO_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
@@ -35,23 +35,23 @@
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
bool Analog_Output_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Analog_Output_Count(void);
|
||||
uint32_t Analog_Output_Index_To_Instance(unsigned index);
|
||||
char *Analog_Output_Name(uint32_t object_instance);
|
||||
bool Binary_Output_Valid_Instance(uint32_t object_instance);
|
||||
unsigned Binary_Output_Count(void);
|
||||
uint32_t Binary_Output_Index_To_Instance(unsigned index);
|
||||
char *Binary_Output_Name(uint32_t object_instance);
|
||||
|
||||
int Analog_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
int Binary_Output_Encode_Property_APDU(uint8_t * apdu,
|
||||
uint32_t object_instance,
|
||||
BACNET_PROPERTY_ID property,
|
||||
int32_t array_index,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
|
||||
bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
bool Binary_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
||||
BACNET_ERROR_CLASS * error_class, BACNET_ERROR_CODE * error_code);
|
||||
|
||||
#ifdef TEST
|
||||
#include "ctest.h"
|
||||
void testAnalogOutput(Test * pTest);
|
||||
void testBinaryOutput(Test * pTest);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include "apdu.h"
|
||||
#include "ai.h" /* object list dependency */
|
||||
#include "bi.h" /* object list dependency */
|
||||
#include "bo.h" /* object list dependency */
|
||||
#include "ao.h" /* object list dependency */
|
||||
#include "wp.h" /* write property handling */
|
||||
#include "device.h" /* me */
|
||||
@@ -320,6 +321,7 @@ unsigned Device_Object_List_Count(void)
|
||||
|
||||
count += Analog_Input_Count();
|
||||
count += Binary_Input_Count();
|
||||
count += Binary_Output_Count();
|
||||
count += Analog_Output_Count();
|
||||
#if BACFILE
|
||||
count += bacfile_count();
|
||||
@@ -362,12 +364,24 @@ bool Device_Object_List_Identifier(unsigned array_index,
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
/* analog output objects */
|
||||
/* binary output objects */
|
||||
if (!status) {
|
||||
/* normalize the index since
|
||||
we know it is not the previous objects */
|
||||
object_index -= Binary_Input_Count();
|
||||
/* is it a valid index for this object? */
|
||||
if (object_index < Binary_Output_Count()) {
|
||||
*object_type = OBJECT_BINARY_OUTPUT;
|
||||
*instance = Binary_Output_Index_To_Instance(object_index);
|
||||
status = true;
|
||||
}
|
||||
}
|
||||
/* analog output objects */
|
||||
if (!status) {
|
||||
/* normalize the index since
|
||||
we know it is not the previous objects */
|
||||
object_index -= Binary_Output_Count();
|
||||
/* is it a valid index for this object? */
|
||||
if (object_index < Analog_Output_Count()) {
|
||||
*object_type = OBJECT_ANALOG_OUTPUT;
|
||||
*instance = Analog_Output_Index_To_Instance(object_index);
|
||||
@@ -433,6 +447,9 @@ char *Device_Valid_Object_Id(int object_type, uint32_t object_instance)
|
||||
case OBJECT_BINARY_INPUT:
|
||||
name = Binary_Input_Name(object_instance);
|
||||
break;
|
||||
case OBJECT_BINARY_OUTPUT:
|
||||
name = Binary_Output_Name(object_instance);
|
||||
break;
|
||||
case OBJECT_ANALOG_OUTPUT:
|
||||
name = Analog_Output_Name(object_instance);
|
||||
break;
|
||||
@@ -822,6 +839,22 @@ uint32_t Binary_Input_Index_To_Instance(unsigned index)
|
||||
return index;
|
||||
}
|
||||
|
||||
char *Binary_Output_Name(uint32_t object_instance)
|
||||
{
|
||||
(void) object_instance;
|
||||
return "";
|
||||
}
|
||||
|
||||
unsigned Binary_Output_Count(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32_t Binary_Output_Index_To_Instance(unsigned index)
|
||||
{
|
||||
return index;
|
||||
}
|
||||
|
||||
char *Analog_Output_Name(uint32_t object_instance)
|
||||
{
|
||||
(void) object_instance;
|
||||
|
||||
Reference in New Issue
Block a user