Ran the indent and comment script to standardize the source files.
This commit is contained in:
+23
-24
@@ -114,8 +114,7 @@ int bacapp_encode_application_data(uint8_t * apdu,
|
|||||||
Return the number of octets consumed. */
|
Return the number of octets consumed. */
|
||||||
int bacapp_decode_data(uint8_t * apdu,
|
int bacapp_decode_data(uint8_t * apdu,
|
||||||
uint8_t tag_data_type,
|
uint8_t tag_data_type,
|
||||||
uint32_t len_value_type,
|
uint32_t len_value_type, BACNET_APPLICATION_DATA_VALUE * value)
|
||||||
BACNET_APPLICATION_DATA_VALUE * value)
|
|
||||||
{
|
{
|
||||||
int len = 0;
|
int len = 0;
|
||||||
int object_type = 0;
|
int object_type = 0;
|
||||||
@@ -156,8 +155,7 @@ int bacapp_decode_data(uint8_t * apdu,
|
|||||||
len = decode_bacnet_time(&apdu[0], &value->type.Time);
|
len = decode_bacnet_time(&apdu[0], &value->type.Time);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||||
len = decode_object_id(&apdu[0],
|
len = decode_object_id(&apdu[0], &object_type, &instance);
|
||||||
&object_type, &instance);
|
|
||||||
value->type.Object_Id.type = object_type;
|
value->type.Object_Id.type = object_type;
|
||||||
value->type.Object_Id.instance = instance;
|
value->type.Object_Id.instance = instance;
|
||||||
break;
|
break;
|
||||||
@@ -199,9 +197,7 @@ int bacapp_decode_application_data(uint8_t * apdu,
|
|||||||
len += tag_len;
|
len += tag_len;
|
||||||
value->tag = tag_number;
|
value->tag = tag_number;
|
||||||
len += bacapp_decode_data(&apdu[len],
|
len += bacapp_decode_data(&apdu[len],
|
||||||
tag_number,
|
tag_number, len_value_type, value);
|
||||||
len_value_type,
|
|
||||||
value);
|
|
||||||
}
|
}
|
||||||
value->next = NULL;
|
value->next = NULL;
|
||||||
}
|
}
|
||||||
@@ -209,8 +205,8 @@ int bacapp_decode_application_data(uint8_t * apdu,
|
|||||||
return len;
|
return len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_encode_context_data_value(uint8_t * apdu, uint8_t context_tag_number,
|
int bacapp_encode_context_data_value(uint8_t * apdu,
|
||||||
BACNET_APPLICATION_DATA_VALUE * value)
|
uint8_t context_tag_number, BACNET_APPLICATION_DATA_VALUE * value)
|
||||||
{
|
{
|
||||||
int apdu_len = 0; /* total length of the apdu, return value */
|
int apdu_len = 0; /* total length of the apdu, return value */
|
||||||
|
|
||||||
@@ -224,7 +220,8 @@ int bacapp_encode_context_data_value(uint8_t * apdu, uint8_t context_tag_number,
|
|||||||
value->type.Boolean);
|
value->type.Boolean);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
case BACNET_APPLICATION_TAG_UNSIGNED_INT:
|
||||||
apdu_len = encode_context_unsigned(&apdu[0], context_tag_number,
|
apdu_len =
|
||||||
|
encode_context_unsigned(&apdu[0], context_tag_number,
|
||||||
value->type.Unsigned_Int);
|
value->type.Unsigned_Int);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
case BACNET_APPLICATION_TAG_SIGNED_INT:
|
||||||
@@ -236,7 +233,8 @@ int bacapp_encode_context_data_value(uint8_t * apdu, uint8_t context_tag_number,
|
|||||||
value->type.Real);
|
value->type.Real);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_ENUMERATED:
|
case BACNET_APPLICATION_TAG_ENUMERATED:
|
||||||
apdu_len = encode_context_enumerated(&apdu[0], context_tag_number,
|
apdu_len =
|
||||||
|
encode_context_enumerated(&apdu[0], context_tag_number,
|
||||||
value->type.Enumerated);
|
value->type.Enumerated);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_DATE:
|
case BACNET_APPLICATION_TAG_DATE:
|
||||||
@@ -248,20 +246,24 @@ int bacapp_encode_context_data_value(uint8_t * apdu, uint8_t context_tag_number,
|
|||||||
&value->type.Time);
|
&value->type.Time);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
case BACNET_APPLICATION_TAG_OBJECT_ID:
|
||||||
apdu_len = encode_context_object_id(&apdu[0], context_tag_number,
|
apdu_len =
|
||||||
|
encode_context_object_id(&apdu[0], context_tag_number,
|
||||||
value->type.Object_Id.type,
|
value->type.Object_Id.type,
|
||||||
value->type.Object_Id.instance);
|
value->type.Object_Id.instance);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_OCTET_STRING:
|
case BACNET_APPLICATION_TAG_OCTET_STRING:
|
||||||
apdu_len = encode_context_octet_string(&apdu[0], context_tag_number,
|
apdu_len =
|
||||||
|
encode_context_octet_string(&apdu[0], context_tag_number,
|
||||||
&value->type.Octet_String);
|
&value->type.Octet_String);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
case BACNET_APPLICATION_TAG_CHARACTER_STRING:
|
||||||
apdu_len = encode_context_character_string(&apdu[0], context_tag_number,
|
apdu_len =
|
||||||
&value->type.Character_String);
|
encode_context_character_string(&apdu[0],
|
||||||
|
context_tag_number, &value->type.Character_String);
|
||||||
break;
|
break;
|
||||||
case BACNET_APPLICATION_TAG_BIT_STRING:
|
case BACNET_APPLICATION_TAG_BIT_STRING:
|
||||||
apdu_len = encode_context_bitstring(&apdu[0], context_tag_number,
|
apdu_len =
|
||||||
|
encode_context_bitstring(&apdu[0], context_tag_number,
|
||||||
&value->type.Bit_String);
|
&value->type.Bit_String);
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
@@ -280,8 +282,7 @@ int bacapp_encode_context_data_value(uint8_t * apdu, uint8_t context_tag_number,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* returns the fixed tag type for certain context tagged properties */
|
/* returns the fixed tag type for certain context tagged properties */
|
||||||
BACNET_APPLICATION_TAG bacapp_context_tag_type(
|
BACNET_APPLICATION_TAG bacapp_context_tag_type(BACNET_PROPERTY_ID property,
|
||||||
BACNET_PROPERTY_ID property,
|
|
||||||
uint8_t tag_number)
|
uint8_t tag_number)
|
||||||
{
|
{
|
||||||
BACNET_APPLICATION_TAG tag = MAX_BACNET_APPLICATION_TAG;
|
BACNET_APPLICATION_TAG tag = MAX_BACNET_APPLICATION_TAG;
|
||||||
@@ -345,14 +346,14 @@ BACNET_APPLICATION_TAG bacapp_context_tag_type(
|
|||||||
}
|
}
|
||||||
|
|
||||||
int bacapp_encode_context_data(uint8_t * apdu,
|
int bacapp_encode_context_data(uint8_t * apdu,
|
||||||
BACNET_APPLICATION_DATA_VALUE * value,
|
BACNET_APPLICATION_DATA_VALUE * value, BACNET_PROPERTY_ID property)
|
||||||
BACNET_PROPERTY_ID property)
|
|
||||||
{
|
{
|
||||||
int apdu_len = 0;
|
int apdu_len = 0;
|
||||||
BACNET_APPLICATION_TAG tag_data_type;
|
BACNET_APPLICATION_TAG tag_data_type;
|
||||||
|
|
||||||
if (value && apdu) {
|
if (value && apdu) {
|
||||||
tag_data_type = bacapp_context_tag_type(property, value->context_tag);
|
tag_data_type =
|
||||||
|
bacapp_context_tag_type(property, value->context_tag);
|
||||||
if (tag_data_type < MAX_BACNET_APPLICATION_TAG) {
|
if (tag_data_type < MAX_BACNET_APPLICATION_TAG) {
|
||||||
apdu_len = bacapp_encode_context_data_value(&apdu[0],
|
apdu_len = bacapp_encode_context_data_value(&apdu[0],
|
||||||
value->context_tag, value);
|
value->context_tag, value);
|
||||||
@@ -387,9 +388,7 @@ int bacapp_decode_context_data(uint8_t * apdu,
|
|||||||
value->tag = bacapp_context_tag_type(property, tag_number);
|
value->tag = bacapp_context_tag_type(property, tag_number);
|
||||||
if (value->tag < MAX_BACNET_APPLICATION_TAG) {
|
if (value->tag < MAX_BACNET_APPLICATION_TAG) {
|
||||||
len = bacapp_decode_data(&apdu[apdu_len],
|
len = bacapp_decode_data(&apdu[apdu_len],
|
||||||
value->tag,
|
value->tag, len_value_type, value);
|
||||||
len_value_type,
|
|
||||||
value);
|
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
} else {
|
} else {
|
||||||
/* FIXME: what now? */
|
/* FIXME: what now? */
|
||||||
|
|||||||
@@ -86,12 +86,10 @@ extern "C" {
|
|||||||
BACNET_PROPERTY_ID property);
|
BACNET_PROPERTY_ID property);
|
||||||
|
|
||||||
int bacapp_encode_context_data_value(uint8_t * apdu,
|
int bacapp_encode_context_data_value(uint8_t * apdu,
|
||||||
uint8_t context_tag_number,
|
uint8_t context_tag_number, BACNET_APPLICATION_DATA_VALUE * value);
|
||||||
BACNET_APPLICATION_DATA_VALUE * value);
|
|
||||||
|
|
||||||
BACNET_APPLICATION_TAG bacapp_context_tag_type(
|
BACNET_APPLICATION_TAG bacapp_context_tag_type(BACNET_PROPERTY_ID
|
||||||
BACNET_PROPERTY_ID property,
|
property, uint8_t tag_number);
|
||||||
uint8_t tag_number);
|
|
||||||
|
|
||||||
bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE * dest_value,
|
bool bacapp_copy(BACNET_APPLICATION_DATA_VALUE * dest_value,
|
||||||
BACNET_APPLICATION_DATA_VALUE * src_value);
|
BACNET_APPLICATION_DATA_VALUE * src_value);
|
||||||
|
|||||||
@@ -882,7 +882,8 @@ int encode_context_bitstring(uint8_t * apdu, int tag_number,
|
|||||||
|
|
||||||
/* bit string may use more than 1 octet for the tag, so find out how many */
|
/* bit string may use more than 1 octet for the tag, so find out how many */
|
||||||
bit_string_encoded_length += bitstring_bytes_used(bit_string);
|
bit_string_encoded_length += bitstring_bytes_used(bit_string);
|
||||||
len = encode_tag(&apdu[0], tag_number, true, bit_string_encoded_length);
|
len =
|
||||||
|
encode_tag(&apdu[0], tag_number, true, bit_string_encoded_length);
|
||||||
len += encode_bitstring(&apdu[len], bit_string);
|
len += encode_bitstring(&apdu[len], bit_string);
|
||||||
|
|
||||||
return len;
|
return len;
|
||||||
|
|||||||
@@ -49,8 +49,7 @@ uint8_t Send_Write_Property_Request_Data(uint32_t device_id,
|
|||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
BACNET_PROPERTY_ID object_property,
|
BACNET_PROPERTY_ID object_property,
|
||||||
uint8_t * application_data,
|
uint8_t * application_data,
|
||||||
int application_data_len,
|
int application_data_len, uint8_t priority, int32_t array_index)
|
||||||
uint8_t priority, int32_t array_index)
|
|
||||||
{
|
{
|
||||||
BACNET_ADDRESS dest;
|
BACNET_ADDRESS dest;
|
||||||
BACNET_ADDRESS my_address;
|
BACNET_ADDRESS my_address;
|
||||||
@@ -83,7 +82,8 @@ uint8_t Send_Write_Property_Request_Data(uint32_t device_id,
|
|||||||
data.object_property = object_property;
|
data.object_property = object_property;
|
||||||
data.array_index = array_index;
|
data.array_index = array_index;
|
||||||
data.application_data_len = application_data_len;
|
data.application_data_len = application_data_len;
|
||||||
memcpy(&data.application_data[0],&application_data[0], application_data_len);
|
memcpy(&data.application_data[0], &application_data[0],
|
||||||
|
application_data_len);
|
||||||
data.priority = priority;
|
data.priority = priority;
|
||||||
len = wp_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
len = wp_encode_apdu(&Handler_Transmit_Buffer[pdu_len],
|
||||||
invoke_id, &data);
|
invoke_id, &data);
|
||||||
@@ -130,8 +130,7 @@ uint8_t Send_Write_Property_Request(uint32_t device_id,
|
|||||||
int apdu_len = 0, len = 0;
|
int apdu_len = 0, len = 0;
|
||||||
|
|
||||||
while (object_value) {
|
while (object_value) {
|
||||||
len = bacapp_encode_data(
|
len = bacapp_encode_data(&application_data[apdu_len],
|
||||||
&application_data[apdu_len],
|
|
||||||
object_value);
|
object_value);
|
||||||
if ((len + apdu_len) < MAX_APDU) {
|
if ((len + apdu_len) < MAX_APDU) {
|
||||||
apdu_len += len;
|
apdu_len += len;
|
||||||
@@ -141,13 +140,9 @@ uint8_t Send_Write_Property_Request(uint32_t device_id,
|
|||||||
object_value = object_value->next;
|
object_value = object_value->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
return Send_Write_Property_Request_Data(
|
return Send_Write_Property_Request_Data(device_id,
|
||||||
device_id,
|
|
||||||
object_type,
|
object_type,
|
||||||
object_instance,
|
object_instance,
|
||||||
object_property,
|
object_property,
|
||||||
&application_data[0],
|
&application_data[0], apdu_len, priority, array_index);
|
||||||
apdu_len,
|
|
||||||
priority,
|
|
||||||
array_index);
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -157,10 +157,8 @@ unsigned Analog_Output_Present_Value_Priority(uint32_t object_instance)
|
|||||||
return priority;
|
return priority;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Analog_Output_Present_Value_Set(
|
bool Analog_Output_Present_Value_Set(uint32_t object_instance,
|
||||||
uint32_t object_instance,
|
float value, unsigned priority)
|
||||||
float value,
|
|
||||||
unsigned priority)
|
|
||||||
{
|
{
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
bool status = false;
|
bool status = false;
|
||||||
@@ -184,8 +182,7 @@ bool Analog_Output_Present_Value_Set(
|
|||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Analog_Output_Present_Value_Relinquish(
|
bool Analog_Output_Present_Value_Relinquish(uint32_t object_instance,
|
||||||
uint32_t object_instance,
|
|
||||||
int priority)
|
int priority)
|
||||||
{
|
{
|
||||||
unsigned index = 0;
|
unsigned index = 0;
|
||||||
@@ -366,10 +363,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
|||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
algorithm and may not be used for other purposes in any
|
algorithm and may not be used for other purposes in any
|
||||||
object. */
|
object. */
|
||||||
status = Analog_Output_Present_Value_Set(
|
status =
|
||||||
wp_data->object_instance,
|
Analog_Output_Present_Value_Set(wp_data->object_instance,
|
||||||
value.type.Real,
|
value.type.Real, wp_data->priority);
|
||||||
wp_data->priority);
|
|
||||||
if (wp_data->priority == 6) {
|
if (wp_data->priority == 6) {
|
||||||
/* Command priority 6 is reserved for use by Minimum On/Off
|
/* Command priority 6 is reserved for use by Minimum On/Off
|
||||||
algorithm and may not be used for other purposes in any
|
algorithm and may not be used for other purposes in any
|
||||||
@@ -384,9 +380,9 @@ bool Analog_Output_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
|||||||
level = AO_LEVEL_NULL;
|
level = AO_LEVEL_NULL;
|
||||||
object_index =
|
object_index =
|
||||||
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
Analog_Output_Instance_To_Index(wp_data->object_instance);
|
||||||
status = Analog_Output_Present_Value_Relinquish(
|
status =
|
||||||
wp_data->object_instance,
|
Analog_Output_Present_Value_Relinquish(wp_data->
|
||||||
wp_data->priority);
|
object_instance, wp_data->priority);
|
||||||
if (!status) {
|
if (!status) {
|
||||||
*error_class = ERROR_CLASS_PROPERTY;
|
*error_class = ERROR_CLASS_PROPERTY;
|
||||||
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
*error_code = ERROR_CODE_VALUE_OUT_OF_RANGE;
|
||||||
|
|||||||
@@ -40,13 +40,11 @@ extern "C" {
|
|||||||
uint32_t Analog_Output_Index_To_Instance(unsigned index);
|
uint32_t Analog_Output_Index_To_Instance(unsigned index);
|
||||||
char *Analog_Output_Name(uint32_t object_instance);
|
char *Analog_Output_Name(uint32_t object_instance);
|
||||||
float Analog_Output_Present_Value(uint32_t object_instance);
|
float Analog_Output_Present_Value(uint32_t object_instance);
|
||||||
unsigned Analog_Output_Present_Value_Priority(uint32_t object_instance);
|
unsigned Analog_Output_Present_Value_Priority(uint32_t
|
||||||
bool Analog_Output_Present_Value_Set(
|
object_instance);
|
||||||
uint32_t object_instance,
|
bool Analog_Output_Present_Value_Set(uint32_t object_instance,
|
||||||
float value,
|
float value, unsigned priority);
|
||||||
unsigned priority);
|
bool Analog_Output_Present_Value_Relinquish(uint32_t object_instance,
|
||||||
bool Analog_Output_Present_Value_Relinquish(
|
|
||||||
uint32_t object_instance,
|
|
||||||
int priority);
|
int priority);
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -258,8 +258,7 @@ struct tm {
|
|||||||
(uint8_t) tblock->tm_mon,
|
(uint8_t) tblock->tm_mon,
|
||||||
(uint8_t) tblock->tm_mday,
|
(uint8_t) tblock->tm_mday,
|
||||||
(uint8_t) tblock->tm_hour,
|
(uint8_t) tblock->tm_hour,
|
||||||
(uint8_t)tblock->tm_min,
|
(uint8_t) tblock->tm_min, (uint8_t) tblock->tm_sec, 0);
|
||||||
(uint8_t)tblock->tm_sec, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* convert the shed level request into an Analog Output Present_Value */
|
/* convert the shed level request into an Analog Output Present_Value */
|
||||||
@@ -271,18 +270,22 @@ static float Requested_Shed_Level_Value(int object_index)
|
|||||||
|
|
||||||
switch (Requested_Shed_Level[object_index].type) {
|
switch (Requested_Shed_Level[object_index].type) {
|
||||||
case BACNET_SHED_TYPE_PERCENT:
|
case BACNET_SHED_TYPE_PERCENT:
|
||||||
requested_level = (float)Requested_Shed_Level[object_index].value.percent;
|
requested_level =
|
||||||
|
(float) Requested_Shed_Level[object_index].value.percent;
|
||||||
break;
|
break;
|
||||||
case BACNET_SHED_TYPE_AMOUNT:
|
case BACNET_SHED_TYPE_AMOUNT:
|
||||||
/* Assumptions: wattage is linear with analog output level */
|
/* Assumptions: wattage is linear with analog output level */
|
||||||
requested_level = Full_Duty_Baseline[object_index] - Requested_Shed_Level[object_index].value.amount;
|
requested_level =
|
||||||
|
Full_Duty_Baseline[object_index] -
|
||||||
|
Requested_Shed_Level[object_index].value.amount;
|
||||||
requested_level /= Full_Duty_Baseline[object_index];
|
requested_level /= Full_Duty_Baseline[object_index];
|
||||||
requested_level *= 100.0;
|
requested_level *= 100.0;
|
||||||
break;
|
break;
|
||||||
case BACNET_SHED_TYPE_LEVEL:
|
case BACNET_SHED_TYPE_LEVEL:
|
||||||
default:
|
default:
|
||||||
for (i = 0; i < MAX_SHED_LEVELS; i++) {
|
for (i = 0; i < MAX_SHED_LEVELS; i++) {
|
||||||
if (Shed_Levels[object_index][i] <= Requested_Shed_Level[object_index].value.level)
|
if (Shed_Levels[object_index][i] <=
|
||||||
|
Requested_Shed_Level[object_index].value.level)
|
||||||
shed_level_index = i;
|
shed_level_index = i;
|
||||||
}
|
}
|
||||||
requested_level = Shed_Level_Values[shed_level_index];
|
requested_level = Shed_Level_Values[shed_level_index];
|
||||||
@@ -292,7 +295,8 @@ static float Requested_Shed_Level_Value(int object_index)
|
|||||||
return requested_level;
|
return requested_level;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Shed_Level_Copy(BACNET_SHED_LEVEL *dest, BACNET_SHED_LEVEL *src)
|
static void Shed_Level_Copy(BACNET_SHED_LEVEL * dest,
|
||||||
|
BACNET_SHED_LEVEL * src)
|
||||||
{
|
{
|
||||||
if (dest && src) {
|
if (dest && src) {
|
||||||
dest->type = src->type;
|
dest->type = src->type;
|
||||||
@@ -311,7 +315,8 @@ static void Shed_Level_Copy(BACNET_SHED_LEVEL *dest, BACNET_SHED_LEVEL *src)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void Shed_Level_Default_Set(BACNET_SHED_LEVEL *dest, BACNET_SHED_LEVEL_TYPE type)
|
static void Shed_Level_Default_Set(BACNET_SHED_LEVEL * dest,
|
||||||
|
BACNET_SHED_LEVEL_TYPE type)
|
||||||
{
|
{
|
||||||
if (dest) {
|
if (dest) {
|
||||||
dest->type = type;
|
dest->type = type;
|
||||||
@@ -410,7 +415,8 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Load_Control_State[object_index] == SHED_INACTIVE) {
|
if (Load_Control_State[object_index] == SHED_INACTIVE) {
|
||||||
printf("Load Control[%d]:Requested Shed Level=Default\n",object_index);
|
printf("Load Control[%d]:Requested Shed Level=Default\n",
|
||||||
|
object_index);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -431,7 +437,9 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
/* CancelShed */
|
/* CancelShed */
|
||||||
/* FIXME: stop shedding! i.e. relinquish */
|
/* FIXME: stop shedding! i.e. relinquish */
|
||||||
printf("Load Control[%d]:Current Time is after Start Time + Duration\n",object_index);
|
printf
|
||||||
|
("Load Control[%d]:Current Time is after Start Time + Duration\n",
|
||||||
|
object_index);
|
||||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -439,33 +447,28 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
/* current time prior to start time */
|
/* current time prior to start time */
|
||||||
/* ReconfigurePending */
|
/* ReconfigurePending */
|
||||||
Shed_Level_Copy(
|
Shed_Level_Copy(&Expected_Shed_Level[object_index],
|
||||||
&Expected_Shed_Level[object_index],
|
|
||||||
&Requested_Shed_Level[object_index]);
|
&Requested_Shed_Level[object_index]);
|
||||||
Shed_Level_Default_Set(
|
Shed_Level_Default_Set(&Actual_Shed_Level[object_index],
|
||||||
&Actual_Shed_Level[object_index],
|
|
||||||
Requested_Shed_Level[object_index].type);
|
Requested_Shed_Level[object_index].type);
|
||||||
} else if (diff > 0) {
|
} else if (diff > 0) {
|
||||||
/* current time after to start time */
|
/* current time after to start time */
|
||||||
printf("Load Control[%d]:Current Time is after Start Time\n",object_index);
|
printf("Load Control[%d]:Current Time is after Start Time\n",
|
||||||
|
object_index);
|
||||||
/* AbleToMeetShed */
|
/* AbleToMeetShed */
|
||||||
if (Able_To_Meet_Shed_Request(object_index)) {
|
if (Able_To_Meet_Shed_Request(object_index)) {
|
||||||
Shed_Level_Copy(
|
Shed_Level_Copy(&Expected_Shed_Level[object_index],
|
||||||
&Expected_Shed_Level[object_index],
|
|
||||||
&Requested_Shed_Level[object_index]);
|
&Requested_Shed_Level[object_index]);
|
||||||
Analog_Output_Present_Value_Set(object_index,
|
Analog_Output_Present_Value_Set(object_index,
|
||||||
Requested_Shed_Level_Value(object_index), 4);
|
Requested_Shed_Level_Value(object_index), 4);
|
||||||
Shed_Level_Copy(
|
Shed_Level_Copy(&Actual_Shed_Level[object_index],
|
||||||
&Actual_Shed_Level[object_index],
|
|
||||||
&Requested_Shed_Level[object_index]);
|
&Requested_Shed_Level[object_index]);
|
||||||
Load_Control_State[object_index] = SHED_COMPLIANT;
|
Load_Control_State[object_index] = SHED_COMPLIANT;
|
||||||
} else {
|
} else {
|
||||||
/* CannotMeetShed */
|
/* CannotMeetShed */
|
||||||
Shed_Level_Default_Set(
|
Shed_Level_Default_Set(&Expected_Shed_Level[object_index],
|
||||||
&Expected_Shed_Level[object_index],
|
|
||||||
Requested_Shed_Level[object_index].type);
|
Requested_Shed_Level[object_index].type);
|
||||||
Shed_Level_Default_Set(
|
Shed_Level_Default_Set(&Actual_Shed_Level[object_index],
|
||||||
&Actual_Shed_Level[object_index],
|
|
||||||
Requested_Shed_Level[object_index].type);
|
Requested_Shed_Level[object_index].type);
|
||||||
Load_Control_State[object_index] = SHED_NON_COMPLIANT;
|
Load_Control_State[object_index] = SHED_NON_COMPLIANT;
|
||||||
}
|
}
|
||||||
@@ -479,14 +482,17 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
diff = datetime_compare(&End_Time[object_index], &Current_Time);
|
diff = datetime_compare(&End_Time[object_index], &Current_Time);
|
||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
/* FinishedUnsuccessfulShed */
|
/* FinishedUnsuccessfulShed */
|
||||||
printf("Load Control[%d]:Current Time is after Start Time + Duration\n",object_index);
|
printf
|
||||||
|
("Load Control[%d]:Current Time is after Start Time + Duration\n",
|
||||||
|
object_index);
|
||||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (Load_Control_Request_Written[object_index] ||
|
if (Load_Control_Request_Written[object_index] ||
|
||||||
Start_Time_Property_Written[object_index]) {
|
Start_Time_Property_Written[object_index]) {
|
||||||
/* UnsuccessfulShedReconfigured */
|
/* UnsuccessfulShedReconfigured */
|
||||||
printf("Load Control[%d]:Control Property written\n",object_index);
|
printf("Load Control[%d]:Control Property written\n",
|
||||||
|
object_index);
|
||||||
Load_Control_Request_Written[object_index] = false;
|
Load_Control_Request_Written[object_index] = false;
|
||||||
Start_Time_Property_Written[object_index] = false;
|
Start_Time_Property_Written[object_index] = false;
|
||||||
Load_Control_State[object_index] = SHED_REQUEST_PENDING;
|
Load_Control_State[object_index] = SHED_REQUEST_PENDING;
|
||||||
@@ -494,14 +500,13 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
}
|
}
|
||||||
if (Able_To_Meet_Shed_Request(object_index)) {
|
if (Able_To_Meet_Shed_Request(object_index)) {
|
||||||
/* CanNowComplyWithShed */
|
/* CanNowComplyWithShed */
|
||||||
printf("Load Control[%d]:Able to meet Shed Request\n",object_index);
|
printf("Load Control[%d]:Able to meet Shed Request\n",
|
||||||
Shed_Level_Copy(
|
object_index);
|
||||||
&Expected_Shed_Level[object_index],
|
Shed_Level_Copy(&Expected_Shed_Level[object_index],
|
||||||
&Requested_Shed_Level[object_index]);
|
&Requested_Shed_Level[object_index]);
|
||||||
Analog_Output_Present_Value_Set(object_index,
|
Analog_Output_Present_Value_Set(object_index,
|
||||||
Requested_Shed_Level_Value(object_index), 4);
|
Requested_Shed_Level_Value(object_index), 4);
|
||||||
Shed_Level_Copy(
|
Shed_Level_Copy(&Actual_Shed_Level[object_index],
|
||||||
&Actual_Shed_Level[object_index],
|
|
||||||
&Requested_Shed_Level[object_index]);
|
&Requested_Shed_Level[object_index]);
|
||||||
Load_Control_State[object_index] = SHED_COMPLIANT;
|
Load_Control_State[object_index] = SHED_COMPLIANT;
|
||||||
}
|
}
|
||||||
@@ -514,7 +519,9 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
diff = datetime_compare(&End_Time[object_index], &Current_Time);
|
diff = datetime_compare(&End_Time[object_index], &Current_Time);
|
||||||
if (diff < 0) {
|
if (diff < 0) {
|
||||||
/* FinishedSuccessfulShed */
|
/* FinishedSuccessfulShed */
|
||||||
printf("Load Control[%d]:Current Time is after Start Time + Duration\n",object_index);
|
printf
|
||||||
|
("Load Control[%d]:Current Time is after Start Time + Duration\n",
|
||||||
|
object_index);
|
||||||
datetime_wildcard_set(&Start_Time[i]);
|
datetime_wildcard_set(&Start_Time[i]);
|
||||||
Load_Control_State[object_index] = SHED_INACTIVE;
|
Load_Control_State[object_index] = SHED_INACTIVE;
|
||||||
break;
|
break;
|
||||||
@@ -522,7 +529,8 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
if (Load_Control_Request_Written[object_index] ||
|
if (Load_Control_Request_Written[object_index] ||
|
||||||
Start_Time_Property_Written[object_index]) {
|
Start_Time_Property_Written[object_index]) {
|
||||||
/* UnsuccessfulShedReconfigured */
|
/* UnsuccessfulShedReconfigured */
|
||||||
printf("Load Control[%d]:Control Property written\n",object_index);
|
printf("Load Control[%d]:Control Property written\n",
|
||||||
|
object_index);
|
||||||
Load_Control_Request_Written[object_index] = false;
|
Load_Control_Request_Written[object_index] = false;
|
||||||
Start_Time_Property_Written[object_index] = false;
|
Start_Time_Property_Written[object_index] = false;
|
||||||
Load_Control_State[object_index] = SHED_REQUEST_PENDING;
|
Load_Control_State[object_index] = SHED_REQUEST_PENDING;
|
||||||
@@ -530,12 +538,11 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
}
|
}
|
||||||
if (!Able_To_Meet_Shed_Request(object_index)) {
|
if (!Able_To_Meet_Shed_Request(object_index)) {
|
||||||
/* CanNoLongerComplyWithShed */
|
/* CanNoLongerComplyWithShed */
|
||||||
printf("Load Control[%d]:Not able to meet Shed Request\n",object_index);
|
printf("Load Control[%d]:Not able to meet Shed Request\n",
|
||||||
Shed_Level_Default_Set(
|
object_index);
|
||||||
&Expected_Shed_Level[object_index],
|
Shed_Level_Default_Set(&Expected_Shed_Level[object_index],
|
||||||
Requested_Shed_Level[object_index].type);
|
Requested_Shed_Level[object_index].type);
|
||||||
Shed_Level_Default_Set(
|
Shed_Level_Default_Set(&Actual_Shed_Level[object_index],
|
||||||
&Actual_Shed_Level[object_index],
|
|
||||||
Requested_Shed_Level[object_index].type);
|
Requested_Shed_Level[object_index].type);
|
||||||
Load_Control_State[object_index] = SHED_NON_COMPLIANT;
|
Load_Control_State[object_index] = SHED_NON_COMPLIANT;
|
||||||
}
|
}
|
||||||
@@ -545,11 +552,9 @@ void Load_Control_State_Machine(int object_index)
|
|||||||
if (Start_Time_Property_Written[object_index]) {
|
if (Start_Time_Property_Written[object_index]) {
|
||||||
printf("Load Control[%d]:Start Time written\n", object_index);
|
printf("Load Control[%d]:Start Time written\n", object_index);
|
||||||
Start_Time_Property_Written[object_index] = false;
|
Start_Time_Property_Written[object_index] = false;
|
||||||
Shed_Level_Copy(
|
Shed_Level_Copy(&Expected_Shed_Level[object_index],
|
||||||
&Expected_Shed_Level[object_index],
|
|
||||||
&Requested_Shed_Level[object_index]);
|
&Requested_Shed_Level[object_index]);
|
||||||
Shed_Level_Default_Set(
|
Shed_Level_Default_Set(&Actual_Shed_Level[object_index],
|
||||||
&Actual_Shed_Level[object_index],
|
|
||||||
Requested_Shed_Level[object_index].type);
|
Requested_Shed_Level[object_index].type);
|
||||||
Load_Control_State[object_index] = SHED_REQUEST_PENDING;
|
Load_Control_State[object_index] = SHED_REQUEST_PENDING;
|
||||||
}
|
}
|
||||||
@@ -829,19 +834,22 @@ bool Load_Control_Write_Property(BACNET_WRITE_PROPERTY_DATA * wp_data,
|
|||||||
&value, PROP_REQUESTED_SHED_LEVEL);
|
&value, PROP_REQUESTED_SHED_LEVEL);
|
||||||
if (value.tag == 0) {
|
if (value.tag == 0) {
|
||||||
/* percent - Unsigned */
|
/* percent - Unsigned */
|
||||||
Requested_Shed_Level[object_index].type = BACNET_SHED_TYPE_PERCENT;
|
Requested_Shed_Level[object_index].type =
|
||||||
|
BACNET_SHED_TYPE_PERCENT;
|
||||||
Requested_Shed_Level[object_index].value.percent =
|
Requested_Shed_Level[object_index].value.percent =
|
||||||
value.type.Unsigned_Int;
|
value.type.Unsigned_Int;
|
||||||
status = true;
|
status = true;
|
||||||
} else if (value.tag == 1) {
|
} else if (value.tag == 1) {
|
||||||
/* level - Unsigned */
|
/* level - Unsigned */
|
||||||
Requested_Shed_Level[object_index].type = BACNET_SHED_TYPE_LEVEL;
|
Requested_Shed_Level[object_index].type =
|
||||||
|
BACNET_SHED_TYPE_LEVEL;
|
||||||
Requested_Shed_Level[object_index].value.level =
|
Requested_Shed_Level[object_index].value.level =
|
||||||
value.type.Unsigned_Int;
|
value.type.Unsigned_Int;
|
||||||
status = true;
|
status = true;
|
||||||
} else if (value.tag == 2) {
|
} else if (value.tag == 2) {
|
||||||
/* amount - REAL */
|
/* amount - REAL */
|
||||||
Requested_Shed_Level[object_index].type = BACNET_SHED_TYPE_AMOUNT;
|
Requested_Shed_Level[object_index].type =
|
||||||
|
BACNET_SHED_TYPE_AMOUNT;
|
||||||
Requested_Shed_Level[object_index].value.amount =
|
Requested_Shed_Level[object_index].value.amount =
|
||||||
value.type.Real;
|
value.type.Real;
|
||||||
status = true;
|
status = true;
|
||||||
@@ -967,7 +975,8 @@ void testLoadControlStateMachine(Test * pTest)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**/
|
/**/
|
||||||
status = Load_Control_Write_Property(&wp_data, &error_class, &error_code);
|
status =
|
||||||
|
Load_Control_Write_Property(&wp_data, &error_class, &error_code);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -62,7 +62,8 @@ static BACNET_PROPERTY_ID Target_Object_Property = PROP_ACKED_TRANSITIONS;
|
|||||||
/* array index value or BACNET_ARRAY_ALL */
|
/* array index value or BACNET_ARRAY_ALL */
|
||||||
static int32_t Target_Object_Property_Index = BACNET_ARRAY_ALL;
|
static int32_t Target_Object_Property_Index = BACNET_ARRAY_ALL;
|
||||||
#define MAX_PROPERTY_VALUES 16
|
#define MAX_PROPERTY_VALUES 16
|
||||||
static BACNET_APPLICATION_DATA_VALUE Target_Object_Property_Value[MAX_PROPERTY_VALUES];
|
static BACNET_APPLICATION_DATA_VALUE
|
||||||
|
Target_Object_Property_Value[MAX_PROPERTY_VALUES];
|
||||||
|
|
||||||
/* 0 if not set, 1..16 if set */
|
/* 0 if not set, 1..16 if set */
|
||||||
static uint8_t Target_Object_Property_Priority = 0;
|
static uint8_t Target_Object_Property_Priority = 0;
|
||||||
@@ -345,8 +346,8 @@ int main(int argc, char *argv[])
|
|||||||
if (found) {
|
if (found) {
|
||||||
if (invoke_id == 0) {
|
if (invoke_id == 0) {
|
||||||
invoke_id =
|
invoke_id =
|
||||||
Send_Write_Property_Request(
|
Send_Write_Property_Request
|
||||||
Target_Device_Object_Instance, Target_Object_Type,
|
(Target_Device_Object_Instance, Target_Object_Type,
|
||||||
Target_Object_Instance, Target_Object_Property,
|
Target_Object_Instance, Target_Object_Property,
|
||||||
&Target_Object_Property_Value[0],
|
&Target_Object_Property_Value[0],
|
||||||
Target_Object_Property_Priority,
|
Target_Object_Property_Priority,
|
||||||
|
|||||||
@@ -45,19 +45,13 @@ void INT0_Interrupt(void);
|
|||||||
void InterruptVectorHigh(void)
|
void InterruptVectorHigh(void)
|
||||||
{
|
{
|
||||||
/* jump to interrupt routine */
|
/* jump to interrupt routine */
|
||||||
_asm goto InterruptHandlerHigh
|
_asm goto InterruptHandlerHigh _endasm}
|
||||||
_endasm
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma code
|
#pragma code
|
||||||
#pragma code InterruptVectorLow = 0x18
|
#pragma code InterruptVectorLow = 0x18
|
||||||
void InterruptVectorLow(void)
|
void InterruptVectorLow(void)
|
||||||
{
|
{
|
||||||
/* jump to interrupt routine */
|
/* jump to interrupt routine */
|
||||||
_asm goto InterruptHandlerLow
|
_asm goto InterruptHandlerLow _endasm}
|
||||||
_endasm
|
|
||||||
}
|
|
||||||
|
|
||||||
#pragma code
|
#pragma code
|
||||||
#pragma interrupt InterruptHandlerHigh
|
#pragma interrupt InterruptHandlerHigh
|
||||||
void InterruptHandlerHigh(void)
|
void InterruptHandlerHigh(void)
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
/* define this to enable ICD */
|
/* define this to enable ICD */
|
||||||
/* #define USE_ICD */
|
/* #define USE_ICD */
|
||||||
|
|
||||||
// Configuration Bits
|
/* Configuration Bits */
|
||||||
#pragma config OSC = HS, OSCS = OFF
|
#pragma config OSC = HS, OSCS = OFF
|
||||||
#pragma config PWRT = ON
|
#pragma config PWRT = ON
|
||||||
#pragma config BOR = ON, BORV = 27
|
#pragma config BOR = ON, BORV = 27
|
||||||
@@ -106,7 +106,8 @@ static void BACnet_Service_Handlers_Init(void)
|
|||||||
#if 0
|
#if 0
|
||||||
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
apdu_set_confirmed_handler(SERVICE_CONFIRMED_WRITE_PROPERTY,
|
||||||
handler_write_property);
|
handler_write_property);
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
|
apdu_set_unconfirmed_handler
|
||||||
|
(SERVICE_UNCONFIRMED_UTC_TIME_SYNCHRONIZATION,
|
||||||
handler_timesync_utc);
|
handler_timesync_utc);
|
||||||
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
|
apdu_set_unconfirmed_handler(SERVICE_UNCONFIRMED_TIME_SYNCHRONIZATION,
|
||||||
handler_timesync);
|
handler_timesync);
|
||||||
@@ -122,8 +123,7 @@ void Reinitialize(void)
|
|||||||
uint8_t i;
|
uint8_t i;
|
||||||
char name = 0;
|
char name = 0;
|
||||||
|
|
||||||
_asm reset _endasm
|
_asm reset _endasm return;
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Global_Int(enum INT_STATE state)
|
void Global_Int(enum INT_STATE state)
|
||||||
|
|||||||
@@ -114,6 +114,11 @@ make -f indtext.mak
|
|||||||
./indtext >> test.log
|
./indtext >> test.log
|
||||||
make -f indtext.mak clean
|
make -f indtext.mak clean
|
||||||
|
|
||||||
|
make -f demo/object/lc.mak clean
|
||||||
|
make -f demo/object/lc.mak
|
||||||
|
./loadcontrol >> test.log
|
||||||
|
make -f demo/object/lc.mak clean
|
||||||
|
|
||||||
make -f demo/object/lsp.mak clean
|
make -f demo/object/lsp.mak clean
|
||||||
make -f demo/object/lsp.mak
|
make -f demo/object/lsp.mak
|
||||||
./lsp >> test.log
|
./lsp >> test.log
|
||||||
|
|||||||
Reference in New Issue
Block a user