Edouard@2765: #include Edouard@2764: #include "iec_types_all.h" Edouard@2764: #include "POUS.h" Edouard@2764: #include "config.h" Edouard@2764: #include "beremiz.h" Edouard@2750: Edouard@2765: #define HMI_BUFFER_SIZE %(buffer_size)d Edouard@2765: Edouard@2765: /* PLC reads from that buffer */ Edouard@2765: static char rbuf[HMI_BUFFER_SIZE]; Edouard@2765: Edouard@2765: /* PLC writes to that buffer */ Edouard@2765: static char wbuf[HMI_BUFFER_SIZE]; Edouard@2765: Edouard@2765: static pthread_mutex_t wbuf_mutex = PTHREAD_MUTEX_INITIALIZER; Edouard@2765: static pthread_mutex_t rbuf_mutex = PTHREAD_MUTEX_INITIALIZER; Edouard@2765: Edouard@2764: %(extern_variables_declarations)s Edouard@2764: Edouard@2764: typedef const struct { Edouard@2764: void *ptr; Edouard@2764: __IEC_types_enum type; Edouard@2765: uint32_t buf_index; Edouard@2765: uint32_t flags; Edouard@2764: } hmi_tree_item_t; Edouard@2764: Edouard@2764: static hmi_tree_item_t hmi_tree_item[] = { Edouard@2764: %(variable_decl_array)s Edouard@2764: }; Edouard@2764: Edouard@2765: typedef void(*hmi_tree_iterator)(hmi_tree_item_t*); Edouard@2765: void traverse_hmi_tree(hmi_tree_iterator fp) Edouard@2765: { Edouard@2765: unsigned int i; Edouard@2765: for(i = 0; i < sizeof(hmi_tree_item)/sizeof(hmi_tree_item_t); i++){ Edouard@2765: hmi_tree_item_t *dsc = &hmi_tree_item[i]; Edouard@2765: if(dsc->type != UNKNOWN_ENUM) Edouard@2765: (*fp)(dsc); Edouard@2765: } Edouard@2765: } Edouard@2765: Edouard@2765: void read_iterator(hmi_tree_item_t *dsc){ Edouard@2765: /* todo */ Edouard@2765: } Edouard@2765: Edouard@2765: void write_iterator(hmi_tree_item_t *dsc){ Edouard@2765: /* todo */ Edouard@2765: } Edouard@2765: Edouard@2764: int __init_svghmi() Edouard@2764: { Edouard@2765: bzero(rbuf,sizeof(rbuf)); Edouard@2765: bzero(wbuf,sizeof(wbuf)); Edouard@2765: Edouard@2764: return 0; Edouard@2750: } Edouard@2764: Edouard@2764: void __cleanup_svghmi() Edouard@2764: { Edouard@2764: } Edouard@2764: Edouard@2764: void __retrieve_svghmi() Edouard@2764: { Edouard@2765: if(!pthread_mutex_lock(&rbuf_mutex)){ Edouard@2765: pthread_mutex_unlock(&rbuf_mutex); Edouard@2765: } Edouard@2764: } Edouard@2764: Edouard@2764: void __publish_svghmi() Edouard@2764: { Edouard@2765: if(!pthread_mutex_lock(&wbuf_mutex)){ Edouard@2765: pthread_mutex_unlock(&wbuf_mutex); Edouard@2765: } Edouard@2764: } Edouard@2764: