--- a/svghmi/svghmi.c Thu Aug 22 14:58:53 2019 +0200
+++ b/svghmi/svghmi.c Fri Aug 23 13:01:37 2019 +0200
@@ -1,23 +1,57 @@
#include "iec_types_all.h"
+#define HMI_BUFFER_SIZE %(buffer_size)d +/* PLC reads from that buffer */ +static char rbuf[HMI_BUFFER_SIZE]; +/* PLC writes to that buffer */ +static char wbuf[HMI_BUFFER_SIZE]; +static pthread_mutex_t wbuf_mutex = PTHREAD_MUTEX_INITIALIZER; +static pthread_mutex_t rbuf_mutex = PTHREAD_MUTEX_INITIALIZER; %(extern_variables_declarations)s
- /* TODO : w/r buffer, flags, locks */
static hmi_tree_item_t hmi_tree_item[] = {
+typedef void(*hmi_tree_iterator)(hmi_tree_item_t*); +void traverse_hmi_tree(hmi_tree_iterator fp) + for(i = 0; i < sizeof(hmi_tree_item)/sizeof(hmi_tree_item_t); i++){ + hmi_tree_item_t *dsc = &hmi_tree_item[i]; + if(dsc->type != UNKNOWN_ENUM) +void read_iterator(hmi_tree_item_t *dsc){ +void write_iterator(hmi_tree_item_t *dsc){
+ bzero(rbuf,sizeof(rbuf)); + bzero(wbuf,sizeof(wbuf)); @@ -27,11 +61,15 @@
+ if(!pthread_mutex_lock(&rbuf_mutex)){ + pthread_mutex_unlock(&rbuf_mutex);
+ if(!pthread_mutex_lock(&wbuf_mutex)){ + pthread_mutex_unlock(&wbuf_mutex); --- a/svghmi/svghmi.py Thu Aug 22 14:58:53 2019 +0200
+++ b/svghmi/svghmi.py Fri Aug 23 13:01:37 2019 +0200
@@ -168,7 +168,7 @@
extern_variables_declarations = []
for node in hmi_tree_root.traverse():
if hasattr(node, "iectype"):
sz = DebugTypesSize.get(node.iectype, 0)
@@ -179,8 +179,9 @@
+ }[node.vartype] + ", " + + str(buf_index) + ", 0}"] extern_variables_declarations += [
"extern __IEC_" + node.iectype + "_" +
@@ -205,9 +206,7 @@
svghmi_c_code = svghmi_c_code % {
"variable_decl_array": ",\n".join(variable_decl_array),
"extern_variables_declarations": "\n".join(extern_variables_declarations),
+ "buffer_size": buf_index gen_svghmi_c_path = os.path.join(buildpath, "svghmi.c")