merge
authorEdouard Tisserant <edouard@beremiz.fr>
Thu, 28 Nov 2024 14:27:58 +0100
changeset 4051 8816aee01b07
parent 4050 b27df24a0ea8 (current diff)
parent 4049 80fc760d4a4a (diff)
child 4054 079099299603
merge
--- a/exemples/svghmi_foreach/svghmi_0@svghmi/svghmi.svg	Thu Nov 28 14:13:03 2024 +0100
+++ b/exemples/svghmi_foreach/svghmi_0@svghmi/svghmi.svg	Thu Nov 28 14:27:58 2024 +0100
@@ -220,7 +220,7 @@
        sodipodi:role="line">8888</tspan></text>
   <g
      id="g6077"
-     inkscape:label="HMI:ForEach:PUMP@/@range@position@size"
+     inkscape:label="HMI:ForEach:PUMP@/@position@range@size"
      transform="translate(-3180.7865,1314.0878)">
     <g
        id="g6130"
@@ -937,7 +937,7 @@
        style="fill:#000000;fill-opacity:1;stroke-width:0.5px">8888</tspan></text>
   <g
      transform="translate(-1160.7865,1314.0878)"
-     inkscape:label="HMI:ForEach:PUMP@/@range@position@size"
+     inkscape:label="HMI:ForEach:PUMP@/@position@range@size"
      id="g18442">
     <g
        transform="translate(32.987139)"
--- a/modbus/mb_runtime.c	Thu Nov 28 14:13:03 2024 +0100
+++ b/modbus/mb_runtime.c	Thu Nov 28 14:27:58 2024 +0100
@@ -688,6 +688,9 @@
 			int res = 0;
 			pthread_attr_t attr;
 			res |= pthread_attr_init(&attr);
+#ifdef MODBUS_STACK_SIZE
+			res |= pthread_attr_setstacksize(&attr, MODBUS_STACK_SIZE);
+#endif
 			res |= pthread_create(&(client_nodes[index].timer_thread_id), &attr, &__mb_client_timer_thread, (void *)((char *)NULL + index));
 			if (res !=  0) {
 				fprintf(stderr, "Modbus plugin: Error (%%d) starting timer thread for modbus client node %%s\n", res, client_nodes[index].location);
@@ -701,6 +704,9 @@
 			int res = 0;
 			pthread_attr_t attr;
 			res |= pthread_attr_init(&attr);
+#ifdef MODBUS_STACK_SIZE
+			res |= pthread_attr_setstacksize(&attr, MODBUS_STACK_SIZE);
+#endif
 			res |= pthread_create(&(client_nodes[index].thread_id), &attr, &__mb_client_thread, (void *)((char *)NULL + index));
 			if (res !=  0) {
 				fprintf(stderr, "Modbus plugin: Error (%%d) starting thread for modbus client node %%s\n", res, client_nodes[index].location);
@@ -728,6 +734,9 @@
 			int res = 0;
 			pthread_attr_t attr;
 			res |= pthread_attr_init(&attr);
+#ifdef MODBUS_STACK_SIZE
+			res |= pthread_attr_setstacksize(&attr, MODBUS_STACK_SIZE);
+#endif
 			res |= pthread_create(&(server_nodes[index].thread_id), &attr, &__mb_server_thread, (void *)&(server_nodes[index]));
 			if (res !=  0) {
 				fprintf(stderr, "Modbus plugin: Error (%%d) starting modbus server thread for node %%s\n", res, server_nodes[index].location);
--- a/svghmi/gen_index_xhtml.xslt	Thu Nov 28 14:13:03 2024 +0100
+++ b/svghmi/gen_index_xhtml.xslt	Thu Nov 28 14:27:58 2024 +0100
@@ -4681,7 +4681,7 @@
 </xsl:text>
     <xsl:text>    sub(new_offset, relativeness, container_id){
 </xsl:text>
-    <xsl:text>        let position_given = this.indexes.length &gt; 2;
+    <xsl:text>        let position_given = this.indexes.length &gt; 1;
 </xsl:text>
     <xsl:text>
 </xsl:text>
@@ -4713,9 +4713,13 @@
 </xsl:text>
     <xsl:text>        // as soon as subribed apply range and size once for all
 </xsl:text>
-    <xsl:text>        this.apply_hmi_value(1, this.range);
-</xsl:text>
-    <xsl:text>        this.apply_hmi_value(3, this.size);
+    <xsl:text>        if(this.indexes.length &gt; 2)
+</xsl:text>
+    <xsl:text>            this.apply_hmi_value(2, this.range);
+</xsl:text>
+    <xsl:text>        if(this.indexes.length &gt; 3)
+</xsl:text>
+    <xsl:text>            this.apply_hmi_value(3, this.size);
 </xsl:text>
     <xsl:text>    }
 </xsl:text>
@@ -4779,7 +4783,7 @@
 </xsl:text>
     <xsl:text>        if(this.apply_position(new_position)){
 </xsl:text>
-    <xsl:text>            this.apply_hmi_value(2, this.position);
+    <xsl:text>            this.apply_hmi_value(1, this.position);
 </xsl:text>
     <xsl:text>        }
 </xsl:text>
@@ -4791,7 +4795,7 @@
 </xsl:text>
     <xsl:text>        // Only care about position, others are constants
 </xsl:text>
-    <xsl:text>        if(index == 2){
+    <xsl:text>        if(index == 1){
 </xsl:text>
     <xsl:text>            this.apply_position(value);
 </xsl:text>
@@ -4799,7 +4803,7 @@
 </xsl:text>
     <xsl:text>                // widget refused or apply different value, force it back
 </xsl:text>
-    <xsl:text>                this.apply_hmi_value(2, this.position);
+    <xsl:text>                this.apply_hmi_value(1, this.position);
 </xsl:text>
     <xsl:text>            }
 </xsl:text>
--- a/svghmi/widget_foreach.ysl2	Thu Nov 28 14:13:03 2024 +0100
+++ b/svghmi/widget_foreach.ysl2	Thu Nov 28 14:27:58 2024 +0100
@@ -29,6 +29,9 @@
     arg name="class_name" accepts="string" > HMI_CLASS name
 
     path name="root" accepts="HMI_NODE" >  where to find HMI_NODEs whose HMI_CLASS is class_name
+    path name="position" accepts="HMI_INT" > position of HMI_NODE mapped to first item, among similar siblings
+    path name="range" accepts="HMI_INT" count="optional" >  count of HMI_NODE siblings
+    path name="size" accepts="HMI_INT" count="optional" >  count of visible items
 }
 
 widget_defs("ForEach") {
@@ -125,7 +128,7 @@
     }
 
     sub(new_offset, relativeness, container_id){
-        let position_given = this.indexes.length > 2;
+        let position_given = this.indexes.length > 1;
 
         // sub() will call apply_cache() and then dispatch()
         // undefining position forces dispatch() to call apply_position()
@@ -141,8 +144,10 @@
             this.sub_items();
 
         // as soon as subribed apply range and size once for all
-        this.apply_hmi_value(1, this.range);
-        this.apply_hmi_value(3, this.size);
+        if(this.indexes.length > 2)
+            this.apply_hmi_value(2, this.range);
+        if(this.indexes.length > 3)
+            this.apply_hmi_value(3, this.size);
     }
 
     apply_position(new_position){
@@ -174,17 +179,17 @@
                 new_position = 0;
         }
         if(this.apply_position(new_position)){
-            this.apply_hmi_value(2, this.position);
+            this.apply_hmi_value(1, this.position);
         }
     }
 
     dispatch(value, oldval, index) {
         // Only care about position, others are constants
-        if(index == 2){
+        if(index == 1){
             this.apply_position(value);
             if(this.position != value){
                 // widget refused or apply different value, force it back
-                this.apply_hmi_value(2, this.position);
+                this.apply_hmi_value(1, this.position);
             }
         }
     }