mirror of
https://github.com/stargieg/bacnet-stack
synced 2025-10-26 23:35:52 +08:00
add ao server support
This commit is contained in:
parent
20996d026b
commit
607b558ce0
|
|
@ -499,6 +499,28 @@ float Analog_Value_Present_Value(
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned Analog_Value_Present_Value_Priority(
|
||||||
|
uint32_t object_instance)
|
||||||
|
{
|
||||||
|
ANALOG_VALUE_DESCR *CurrentAV;
|
||||||
|
unsigned index = 0; /* instance to index conversion */
|
||||||
|
unsigned i = 0; /* loop counter */
|
||||||
|
unsigned priority = 0; /* return value */
|
||||||
|
|
||||||
|
index = Analog_Value_Instance_To_Index(object_instance);
|
||||||
|
if (index < max_analog_values_int) {
|
||||||
|
CurrentAV = &AV_Descr[index];
|
||||||
|
for (i = 0; i < BACNET_MAX_PRIORITY; i++) {
|
||||||
|
if (CurrentAV->Priority_Array[priority] != ANALOG_LEVEL_NULL) {
|
||||||
|
priority = i + 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return priority;
|
||||||
|
}
|
||||||
|
|
||||||
bool Analog_Value_Present_Value_Set(
|
bool Analog_Value_Present_Value_Set(
|
||||||
uint32_t object_instance,
|
uint32_t object_instance,
|
||||||
float value,
|
float value,
|
||||||
|
|
@ -521,12 +543,42 @@ bool Analog_Value_Present_Value_Set(
|
||||||
However, if Out of Service is TRUE, then don't set the
|
However, if Out of Service is TRUE, then don't set the
|
||||||
physical output. This comment may apply to the
|
physical output. This comment may apply to the
|
||||||
main loop (i.e. check out of service before changing output) */
|
main loop (i.e. check out of service before changing output) */
|
||||||
|
if (priority == 8) {
|
||||||
|
CurrentAV->Priority_Array[15] = value;
|
||||||
|
}
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Analog_Value_Present_Value_Relinquish(
|
||||||
|
uint32_t object_instance,
|
||||||
|
unsigned priority)
|
||||||
|
{
|
||||||
|
ANALOG_VALUE_DESCR *CurrentAV;
|
||||||
|
unsigned index = 0;
|
||||||
|
bool status = false;
|
||||||
|
|
||||||
|
index = Analog_Value_Instance_To_Index(object_instance);
|
||||||
|
if (index < max_analog_values_int) {
|
||||||
|
CurrentAV = &AV_Descr[index];
|
||||||
|
if (priority && (priority <= BACNET_MAX_PRIORITY) &&
|
||||||
|
(priority != 6 /* reserved */ )) {
|
||||||
|
CurrentAV->Priority_Array[priority - 1] = ANALOG_LEVEL_NULL;
|
||||||
|
/* 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
bool Analog_Value_Out_Of_Service(
|
bool Analog_Value_Out_Of_Service(
|
||||||
uint32_t object_instance)
|
uint32_t object_instance)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -133,10 +133,10 @@ static object_functions_t My_Object_Table[] = {
|
||||||
Analog_Output_Property_Lists,
|
Analog_Output_Property_Lists,
|
||||||
NULL /* ReadRangeInfo */ ,
|
NULL /* ReadRangeInfo */ ,
|
||||||
NULL /* Iterator */ ,
|
NULL /* Iterator */ ,
|
||||||
NULL /* Value_Lists */ ,
|
Analog_Output_Encode_Value_List ,
|
||||||
NULL /* COV */ ,
|
Analog_Output_Change_Of_Value,
|
||||||
NULL /* COV Clear */ ,
|
Analog_Output_Change_Of_Value_Clear,
|
||||||
NULL /* Intrinsic Reporting */ },
|
Analog_Value_Intrinsic_Reporting},
|
||||||
{OBJECT_ANALOG_VALUE,
|
{OBJECT_ANALOG_VALUE,
|
||||||
Analog_Value_Init,
|
Analog_Value_Init,
|
||||||
Analog_Value_Count,
|
Analog_Value_Count,
|
||||||
|
|
|
||||||
|
|
@ -61,6 +61,7 @@
|
||||||
#endif /* defined(BACFILE) */
|
#endif /* defined(BACFILE) */
|
||||||
#include "ucix.h"
|
#include "ucix.h"
|
||||||
#include "av.h"
|
#include "av.h"
|
||||||
|
#include "ao.h"
|
||||||
#include "bi.h"
|
#include "bi.h"
|
||||||
#include "msv.h"
|
#include "msv.h"
|
||||||
|
|
||||||
|
|
@ -168,6 +169,7 @@ int main(
|
||||||
time_t chk_mtime = 0;
|
time_t chk_mtime = 0;
|
||||||
time_t ucimodtime_bacnet_bi = 0;
|
time_t ucimodtime_bacnet_bi = 0;
|
||||||
time_t ucimodtime_bacnet_av = 0;
|
time_t ucimodtime_bacnet_av = 0;
|
||||||
|
time_t ucimodtime_bacnet_ao = 0;
|
||||||
time_t ucimodtime_bacnet_mv = 0;
|
time_t ucimodtime_bacnet_mv = 0;
|
||||||
int uci_idx = 0;
|
int uci_idx = 0;
|
||||||
char *section;
|
char *section;
|
||||||
|
|
@ -292,6 +294,50 @@ int main(
|
||||||
ucix_cleanup(ctx);
|
ucix_cleanup(ctx);
|
||||||
}
|
}
|
||||||
/* update end */
|
/* update end */
|
||||||
|
/* update Analog Value from uci */
|
||||||
|
section = "bacnet_ao";
|
||||||
|
type = "ao";
|
||||||
|
chk_mtime = 0;
|
||||||
|
chk_mtime = check_uci_update(section, ucimodtime_bacnet_ao);
|
||||||
|
if(chk_mtime != 0) {
|
||||||
|
sleep(1);
|
||||||
|
ucimodtime_bacnet_ao = chk_mtime;
|
||||||
|
printf("Config changed, reloading %s\n",section);
|
||||||
|
ctx = ucix_init(section);
|
||||||
|
struct uci_itr_ctx itr;
|
||||||
|
value_tuple_t *cur;
|
||||||
|
itr.list = NULL;
|
||||||
|
itr.section = section;
|
||||||
|
itr.ctx = ctx;
|
||||||
|
ucix_for_each_section_type(ctx, section, type,
|
||||||
|
(void *)load_value, &itr);
|
||||||
|
for( cur = itr.list; cur; cur = cur->next ) {
|
||||||
|
printf("section %s idx %s \n", section, cur->idx);
|
||||||
|
val_f = strtof(cur->value,NULL);
|
||||||
|
uci_idx = atoi(cur->idx);
|
||||||
|
printf("idx %s ",cur->idx);
|
||||||
|
printf("value %s\n",cur->value);
|
||||||
|
pval_f = Analog_Output_Present_Value(uci_idx);
|
||||||
|
if ( val_f != pval_f ) {
|
||||||
|
Analog_Output_Present_Value_Set(uci_idx,val_f,16);
|
||||||
|
}
|
||||||
|
if (cur->Out_Of_Service == 0) {
|
||||||
|
if (Analog_Output_Out_Of_Service(uci_idx))
|
||||||
|
Analog_Output_Out_Of_Service_Set(uci_idx,0);
|
||||||
|
if (Analog_Output_Reliability(uci_idx))
|
||||||
|
Analog_Output_Reliability_Set(uci_idx,
|
||||||
|
RELIABILITY_NO_FAULT_DETECTED);
|
||||||
|
} else {
|
||||||
|
printf("idx %s ",cur->idx);
|
||||||
|
printf("Out_Of_Service\n");
|
||||||
|
Analog_Output_Out_Of_Service_Set(uci_idx,1);
|
||||||
|
Analog_Output_Reliability_Set(uci_idx,
|
||||||
|
RELIABILITY_COMMUNICATION_FAILURE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ucix_cleanup(ctx);
|
||||||
|
}
|
||||||
|
/* update end */
|
||||||
|
|
||||||
/* update Multistate Value from uci */
|
/* update Multistate Value from uci */
|
||||||
section = "bacnet_mv";
|
section = "bacnet_mv";
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user