static int Update_Analog_Input_Read_Property(BACNET_READ_PROPERTY_DATA *rpdata) { static int index; word_object *object; int instance_no = bacnet_Analog_Input_Instance_To_Index(rpdata -> object_instance); if(rpdata->object_property != bacnet_PROP_PRESENT_VALUE) { goto not_pv; } pthread_mutex_lock(&list_lock); if(list_heads[instance_no] == NULL) { pthread_mutex_unlock(&list_lock); goto not_pv; } object = list_get_first(&list_heads[instance_no]); pthread_mutex_unlock(&list_lock); printf("AI_Present_Value request for instance %i\n", instance_no); //bacnet_Analog_Input_Present_Value_Set(0, 20); // For testing and debugging purposes only printf("-------------- %i:%04X\n", instance_no, object->value); bacnet_Analog_Input_Present_Value_Set(instance_no, object->value); free(object); not_pv: return bacnet_Analog_Input_Read_Property(rpdata); }
static int Update_Analog_Input_Read_Property( BACNET_READ_PROPERTY_DATA *rpdata) { static int index; int instance_no = bacnet_Analog_Input_Instance_To_Index( rpdata->object_instance); if (rpdata->object_property != bacnet_PROP_PRESENT_VALUE) goto not_pv; printf("AI_Present_Value request for instance %i\n", instance_no); // do work here /* Update the values to be sent to the BACnet client here. * The data should be read from the head of a linked list. You are required * to implement this list functionality. * * bacnet_Analog_Input_Present_Value_Set() * First argument: Instance No * Second argument: data to be sent * * Without reconfiguring libbacnet, a maximum of 4 values may be sent */ bacnet_Analog_Input_Present_Value_Set(0, test_data[index++]); /* bacnet_Analog_Input_Present_Value_Set(1, test_data[index++]); */ /* bacnet_Analog_Input_Present_Value_Set(2, test_data[index++]); */ if (index == NUM_TEST_DATA) index = 0; not_pv: return bacnet_Analog_Input_Read_Property(rpdata); }
static int Update_Analog_Input_Read_Property( BACNET_READ_PROPERTY_DATA *rpdata) { static int index; int instance_no = bacnet_Analog_Input_Instance_To_Index( rpdata->object_instance); if (rpdata->object_property != bacnet_PROP_PRESENT_VALUE) goto not_pv; printf("AI_Present_Value request for instance %i\n", instance_no); //ANALOG INPUT FOR 2 INSTANCES bacnet_Analog_Input_Present_Value_Set(0, tab_reg[index++]); bacnet_Analog_Input_Present_Value_Set(1, tab_reg[index++]); // printing the data on tab reg printf("modbus data 0 %d\n",tabreg[0]); printf("modbus data 1 %d\n",tabreg[1]); if (index == NUM_TEST_DATA) index = 0; not_pv: return bacnet_Analog_Input_Read_Property(rpdata); }
static int Update_Analog_Input_Read_Property( BACNET_READ_PROPERTY_DATA *rpdata) { static int index; /* Update the values to be sent to the BACnet client here. * The data should be read from the tail of a linked list. You are required * to implement this list functionality. * * bacnet_Analog_Input_Present_Value_Set() * First argument: Instance No * Second argument: data to be sent * * Without reconfiguring libbacnet, a maximum of 4 values may be sent */ bacnet_Analog_Input_Present_Value_Set(0, test_data[index++]); /* bacnet_Analog_Input_Present_Value_Set(1, test_data[index++]); */ /* bacnet_Analog_Input_Present_Value_Set(2, test_data[index++]); */ if (index == NUM_TEST_DATA) index = 0; return bacnet_Analog_Input_Read_Property(rpdata); }