#include "plt.h" #include "mdl.h" void mdl_sim() { } void mdl_prepare() { MDL.smoke_alarm = 0; MDL.switch_statu = 0; MDL.temperature_alarm = 0; MDL.press_low_alarm = 0; } void from_modbus_to_dev() { //usHoldingRegisters[0x6020] = uab; return 0; } int from_dev_to_modbus() { // uab = usHoldingRegisters[0x6020]; return 0; } void update_states() { } static void *mdl_thrd_main(void *param) { mdl_prepare(); from_dev_to_modbus(); while (1) { from_modbus_to_dev(); mdl_sim(); from_dev_to_modbus(); usleep(10000); /* 10ms */ } return NULL; } int mdl_init() { log_dbg("%s, ++", __func__); int ret = 0; pthread_t xthrd; if (pthread_create(&xthrd, NULL, mdl_thrd_main, NULL) != 0) { log_dbg("%s, pthread_create fail", __func__); ret = -1; } log_dbg("%s, --, ret: %d", __func__, ret); return ret; }