--- a/py_ext/pous.xml Fri Dec 16 13:41:03 2022 +0100
+++ b/py_ext/pous.xml Fri Dec 16 13:43:38 2022 +0100
@@ -1,10 +1,10 @@
<?xml version='1.0' encoding='utf-8'?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.plcopen.org/xml/tc6_0201" xmlns:xhtml="http://www.w3.org/1999/xhtml" xsi:schemaLocation="http://www.plcopen.org/xml/tc6_0201">
<fileHeader companyName="Beremiz" productName="Beremiz" productVersion="0.0" creationDateTime="2008-12-14T16:53:26"/>
- <contentHeader name="Beremiz non-standard POUs library" modificationDateTime="2014-03-17T08:07:24">
+ <contentHeader name="Beremiz non-standard POUs library" modificationDateTime="2022-12-16T11:59:30">
@@ -17,6 +17,1646 @@
+ <pou name="csv_read_by_string" pouType="functionBlock"> + <variable name="pyext_csv_update"> + <variable name="RESULT"> + <variable name="FILE_NAME"> + <variable name="COLUMN"> + <variable name="OLDCODE"> + <variable name="py_eval"> + <derived name="python_eval"/> + <variable name="R_TRIG0"> + <derived name="R_TRIG"/> + <variable name="R_TRIG1"> + <derived name="R_TRIG"/> + <block localId="7" typeName="CONCAT" executionOrderId="0" height="192" width="64"> + <position x="360" y="112"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="8"> + <position x="360" y="144"/> + <position x="320" y="144"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="9"> + <position x="360" y="168"/> + <position x="152" y="168"/> + <variable formalParameter="IN3"> + <relPosition x="0" y="80"/> + <connection refLocalId="10"> + <position x="360" y="192"/> + <position x="320" y="192"/> + <variable formalParameter="IN4"> + <relPosition x="0" y="104"/> + <connection refLocalId="11"> + <position x="360" y="216"/> + <position x="152" y="216"/> + <variable formalParameter="IN5"> + <relPosition x="0" y="128"/> + <connection refLocalId="12"> + <position x="360" y="240"/> + <position x="320" y="240"/> + <variable formalParameter="IN6"> + <relPosition x="0" y="152"/> + <connection refLocalId="13"> + <position x="360" y="264"/> + <position x="152" y="264"/> + <variable formalParameter="IN7"> + <relPosition x="0" y="176"/> + <connection refLocalId="14"> + <position x="360" y="288"/> + <position x="320" y="288"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <inVariable localId="8" executionOrderId="0" height="24" width="160" negated="false"> + <position x="160" y="128"/> + <relPosition x="160" y="16"/> + <expression>'CSVRdStr("'</expression> + <inVariable localId="9" executionOrderId="0" height="32" width="112" negated="false"> + <position x="40" y="152"/> + <relPosition x="112" y="16"/> + <expression>FILE_NAME</expression> + <inVariable localId="10" executionOrderId="0" height="24" width="112" negated="false"> + <position x="208" y="184"/> + <relPosition x="112" y="8"/> + <expression>'","'</expression> + <inVariable localId="11" executionOrderId="0" height="32" width="112" negated="false"> + <position x="40" y="200"/> + <relPosition x="112" y="16"/> + <expression>ROW</expression> + <inVariable localId="12" executionOrderId="0" height="24" width="112" negated="false"> + <position x="208" y="224"/> + <relPosition x="112" y="16"/> + <expression>'","'</expression> + <inVariable localId="13" executionOrderId="0" height="32" width="112" negated="false"> + <position x="40" y="248"/> + <relPosition x="112" y="16"/> + <expression>COLUMN</expression> + <inVariable localId="14" executionOrderId="0" height="24" width="112" negated="false"> + <position x="208" y="272"/> + <relPosition x="112" y="16"/> + <expression>'")'</expression> + <block localId="16" typeName="NE" executionOrderId="0" height="64" width="64"> + <position x="208" y="408"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="22"> + <position x="208" y="440"/> + <position x="168" y="440"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="21"> + <position x="208" y="464"/> + <position x="168" y="464"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <block localId="18" typeName="SEL" executionOrderId="0" height="96" width="64"> + <position x="680" y="376"/> + <variable formalParameter="G"> + <relPosition x="0" y="32"/> + <connection refLocalId="25"> + <position x="680" y="408"/> + <position x="624" y="408"/> + <variable formalParameter="IN0"> + <relPosition x="0" y="56"/> + <connection refLocalId="20"> + <position x="680" y="432"/> + <position x="632" y="432"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="80"/> + <connection refLocalId="4"> + <position x="680" y="456"/> + <position x="632" y="456"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <connector name="Code" localId="19" height="24" width="128"> + <position x="480" y="136"/> + <relPosition x="0" y="8"/> + <connection refLocalId="7" formalParameter="OUT"> + <position x="480" y="144"/> + <position x="424" y="144"/> + <outVariable localId="17" executionOrderId="0" height="32" width="66" negated="false"> + <position x="784" y="392"/> + <relPosition x="0" y="16"/> + <connection refLocalId="18" formalParameter="OUT"> + <position x="784" y="408"/> + <position x="744" y="408"/> + <expression>OLDCODE</expression> + <inVariable localId="20" executionOrderId="0" height="32" width="72" negated="false"> + <position x="560" y="416"/> + <relPosition x="72" y="16"/> + <expression>OLDCODE</expression> + <inVariable localId="21" executionOrderId="0" height="32" width="72" negated="false"> + <position x="96" y="448"/> + <relPosition x="72" y="16"/> + <expression>OLDCODE</expression> + <continuation name="Code" localId="4" height="24" width="128"> + <position x="504" y="448"/> + <relPosition x="128" y="8"/> + <continuation name="Code" localId="22" height="24" width="128"> + <position x="40" y="424"/> + <relPosition x="128" y="16"/> + <connector name="CodeChange" localId="23" height="24" width="120"> + <position x="328" y="432"/> + <relPosition x="0" y="8"/> + <connection refLocalId="16" formalParameter="OUT"> + <position x="328" y="440"/> + <position x="272" y="440"/> + <continuation name="CodeChange" localId="25" height="24" width="120"> + <position x="504" y="392"/> + <relPosition x="120" y="16"/> + <comment localId="26" height="40" width="232"> + <position x="48" y="40"/> + <xhtml:p><![CDATA[Generate python code line]]></xhtml:p> + <comment localId="27" height="48" width="312"> + <position x="40" y="328"/> + <xhtml:p><![CDATA[Detect changes in generated code line]]></xhtml:p> + <comment localId="28" height="48" width="520"> + <position x="48" y="512"/> + <xhtml:p><![CDATA[Execute python code on change or globally when CSV is updated]]></xhtml:p> + <block localId="1" width="104" height="80" typeName="python_eval" instanceName="py_eval" executionOrderId="0"> + <position x="552" y="600"/> + <variable formalParameter="TRIG"> + <relPosition x="0" y="32"/> + <connection refLocalId="15" formalParameter="OUT"> + <position x="552" y="632"/> + <position x="360" y="632"/> + <variable formalParameter="CODE"> + <relPosition x="0" y="64"/> + <connection refLocalId="2"> + <position x="552" y="664"/> + <position x="528" y="664"/> + <variable formalParameter="ACK"> + <relPosition x="104" y="32"/> + <variable formalParameter="RESULT"> + <relPosition x="104" y="64"/> + <inVariable localId="3" height="24" width="152" executionOrderId="0" negated="false"> + <position x="32" y="616"/> + <relPosition x="152" y="16"/> + <expression>pyext_csv_update</expression> + <outVariable localId="5" height="24" width="40" executionOrderId="0" negated="false"> + <position x="1216" y="632"/> + <relPosition x="0" y="8"/> + <connection refLocalId="38" formalParameter="Q1"> + <position x="1216" y="640"/> + <position x="1168" y="640"/> + <expression>ACK</expression> + <outVariable localId="6" height="24" width="64" executionOrderId="0" negated="false"> + <position x="688" y="704"/> + <relPosition x="0" y="8"/> + <connection refLocalId="1" formalParameter="RESULT"> + <position x="688" y="712"/> + <position x="672" y="712"/> + <position x="672" y="664"/> + <position x="656" y="664"/> + <expression>RESULT</expression> + <continuation name="Code" localId="2" height="24" width="128"> + <position x="400" y="648"/> + <relPosition x="128" y="16"/> + <continuation name="CodeChange" localId="24" height="24" width="120"> + <position x="64" y="648"/> + <relPosition x="120" y="16"/> + <block localId="15" typeName="OR" executionOrderId="0" height="64" width="64"> + <position x="296" y="600"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="32" formalParameter="Q"> + <position x="296" y="632"/> + <position x="272" y="632"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="24"> + <position x="296" y="656"/> + <position x="184" y="656"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <block localId="32" typeName="R_TRIG" instanceName="R_TRIG0" executionOrderId="0" height="48" width="64"> + <position x="208" y="600"/> + <variable formalParameter="CLK"> + <relPosition x="0" y="32"/> + <connection refLocalId="3"> + <position x="208" y="632"/> + <position x="184" y="632"/> + <variable formalParameter="Q"> + <relPosition x="64" y="32"/> + <block localId="33" typeName="LEFT" executionOrderId="0" height="64" width="56"> + <position x="736" y="632"/> + <variable formalParameter="IN"> + <relPosition x="0" y="32"/> + <connection refLocalId="1" formalParameter="RESULT"> + <position x="736" y="664"/> + <position x="656" y="664"/> + <variable formalParameter="L"> + <relPosition x="0" y="56"/> + <connection refLocalId="35"> + <position x="736" y="688"/> + <position x="712" y="688"/> + <variable formalParameter="OUT"> + <relPosition x="56" y="32"/> + <block localId="34" typeName="NE" executionOrderId="0" height="64" width="64"> + <position x="880" y="632"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="33" formalParameter="OUT"> + <position x="880" y="664"/> + <position x="792" y="664"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="36"> + <position x="880" y="688"/> + <position x="856" y="688"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <inVariable localId="35" executionOrderId="0" height="24" width="24" negated="false"> + <position x="688" y="672"/> + <relPosition x="24" y="16"/> + <expression>1</expression> + <inVariable localId="36" executionOrderId="0" height="24" width="40" negated="false"> + <position x="816" y="672"/> + <relPosition x="40" y="16"/> + <expression>'#'</expression> + <block localId="37" typeName="R_TRIG" instanceName="R_TRIG1" executionOrderId="0" height="48" width="64"> + <position x="880" y="576"/> + <variable formalParameter="CLK"> + <relPosition x="0" y="32"/> + <connection refLocalId="1" formalParameter="ACK"> + <position x="880" y="608"/> + <position x="688" y="608"/> + <position x="688" y="632"/> + <position x="656" y="632"/> + <variable formalParameter="Q"> + <relPosition x="64" y="32"/> + <block localId="38" typeName="SR" instanceName="SR0" executionOrderId="0" height="64" width="48"> + <position x="1120" y="608"/> + <variable formalParameter="S1"> + <relPosition x="0" y="32"/> + <connection refLocalId="39" formalParameter="OUT"> + <position x="1120" y="640"/> + <position x="1056" y="640"/> + <variable formalParameter="R" edge="rising"> + <relPosition x="0" y="56"/> + <connection refLocalId="15" formalParameter="OUT"> + <position x="1120" y="664"/> + <position x="1088" y="664"/> + <position x="1088" y="736"/> + <position x="376" y="736"/> + <position x="376" y="632"/> + <position x="360" y="632"/> + <variable formalParameter="Q1"> + <relPosition x="48" y="32"/> + <block localId="39" typeName="AND" executionOrderId="0" height="64" width="64"> + <position x="992" y="608"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="37" formalParameter="Q"> + <position x="992" y="640"/> + <position x="976" y="640"/> + <position x="976" y="608"/> + <position x="944" y="608"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="34" formalParameter="OUT"> + <position x="992" y="664"/> + <position x="944" y="664"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <pou name="csv_reload" pouType="functionBlock"> + <variable name="pyext_csv_update"> + <variable name="RESULT"> + <variable name="py_eval"> + <derived name="python_eval"/> + <variable name="R_TRIG0"> + <derived name="R_TRIG"/> + <variable name="F_TRIG0"> + <derived name="F_TRIG"/> + <block localId="1" width="104" height="80" typeName="python_eval" instanceName="py_eval" executionOrderId="0"> + <position x="232" y="328"/> + <variable formalParameter="TRIG"> + <relPosition x="0" y="32"/> + <connection refLocalId="3"> + <position x="232" y="360"/> + <position x="200" y="360"/> + <variable formalParameter="CODE"> + <relPosition x="0" y="64"/> + <connection refLocalId="8"> + <position x="232" y="392"/> + <position x="200" y="392"/> + <variable formalParameter="ACK"> + <relPosition x="104" y="32"/> + <variable formalParameter="RESULT"> + <relPosition x="104" y="64"/> + <inVariable localId="3" height="24" width="152" executionOrderId="0" negated="false"> + <position x="48" y="352"/> + <relPosition x="152" y="8"/> + <expression>TRIG</expression> + <outVariable localId="5" height="24" width="40" executionOrderId="0" negated="false"> + <position x="384" y="344"/> + <relPosition x="0" y="16"/> + <connection refLocalId="1" formalParameter="ACK"> + <position x="384" y="360"/> + <position x="336" y="360"/> + <expression>ACK</expression> + <outVariable localId="6" height="24" width="64" executionOrderId="0" negated="false"> + <position x="384" y="376"/> + <relPosition x="0" y="16"/> + <connection refLocalId="1" formalParameter="RESULT"> + <position x="384" y="392"/> + <position x="336" y="392"/> + <expression>RESULT</expression> + <inVariable localId="8" executionOrderId="0" height="24" width="176" negated="false"> + <position x="24" y="384"/> + <relPosition x="176" y="16"/> + <expression>'pyext_csv_reload()'</expression> + <outVariable localId="2" executionOrderId="0" height="24" width="146" negated="false"> + <position x="864" y="320"/> + <relPosition x="0" y="8"/> + <connection refLocalId="12" formalParameter="OUT"> + <position x="864" y="328"/> + <position x="816" y="328"/> + <expression>pyext_csv_update</expression> + <block localId="9" typeName="R_TRIG" instanceName="R_TRIG0" executionOrderId="0" height="48" width="64"> + <position x="472" y="224"/> + <variable formalParameter="CLK"> + <relPosition x="0" y="32"/> + <connection refLocalId="1" formalParameter="ACK"> + <position x="472" y="256"/> + <position x="368" y="256"/> + <position x="368" y="360"/> + <position x="336" y="360"/> + <variable formalParameter="Q"> + <relPosition x="64" y="32"/> + <block localId="10" typeName="F_TRIG" instanceName="F_TRIG0" executionOrderId="0" height="48" width="64"> + <position x="472" y="296"/> + <variable formalParameter="CLK"> + <relPosition x="0" y="32"/> + <connection refLocalId="1" formalParameter="ACK"> + <position x="472" y="328"/> + <position x="368" y="328"/> + <position x="368" y="360"/> + <position x="336" y="360"/> + <variable formalParameter="Q"> + <relPosition x="64" y="32"/> + <block localId="11" typeName="OR" executionOrderId="0" height="64" width="64"> + <position x="584" y="272"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="9" formalParameter="Q"> + <position x="584" y="304"/> + <position x="560" y="304"/> + <position x="560" y="256"/> + <position x="536" y="256"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="10" formalParameter="Q"> + <position x="584" y="328"/> + <position x="536" y="328"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <block localId="12" typeName="MOVE" executionOrderId="0" height="64" width="56"> + <position x="760" y="272"/> + <variable formalParameter="EN"> + <relPosition x="0" y="32"/> + <connection refLocalId="11" formalParameter="OUT"> + <position x="760" y="304"/> + <position x="648" y="304"/> + <variable formalParameter="IN"> + <relPosition x="0" y="56"/> + <connection refLocalId="13" formalParameter="OUT"> + <position x="760" y="328"/> + <position x="724" y="328"/> + <position x="724" y="256"/> + <position x="712" y="256"/> + <variable formalParameter="ENO"> + <relPosition x="56" y="32"/> + <variable formalParameter="OUT"> + <relPosition x="56" y="56"/> + <block localId="13" typeName="NOT" executionOrderId="0" height="48" width="56"> + <position x="656" y="224"/> + <variable formalParameter="IN"> + <relPosition x="0" y="32"/> + <connection refLocalId="9" formalParameter="Q"> + <position x="656" y="256"/> + <position x="536" y="256"/> + <variable formalParameter="OUT"> + <relPosition x="56" y="32"/> + <comment localId="14" height="72" width="664"> + <position x="368" y="136"/> + <xhtml:p><![CDATA[pyext_csv_update initial value is True so that all CSV blocks get at least updated once at start. +When calling csv_reload, return from python pyext_csv_reload makes a pulse on pyext_csv_update]]></xhtml:p> + <pou name="csv_read_by_int" pouType="functionBlock"> + <variable name="pyext_csv_update"> + <variable name="RESULT"> + <variable name="FILE_NAME"> + <variable name="COLUMN"> + <variable name="OLDCODE"> + <variable name="py_eval0"> + <derived name="python_eval"/> + <variable name="R_TRIG1"> + <derived name="R_TRIG"/> + <variable name="R_TRIG2"> + <derived name="R_TRIG"/> + <block localId="7" typeName="CONCAT" executionOrderId="0" height="192" width="64"> + <position x="520" y="112"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="8"> + <position x="520" y="144"/> + <position x="480" y="144"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="9"> + <position x="520" y="168"/> + <position x="312" y="168"/> + <variable formalParameter="IN3"> + <relPosition x="0" y="80"/> + <connection refLocalId="10"> + <position x="520" y="192"/> + <position x="480" y="192"/> + <variable formalParameter="IN4"> + <relPosition x="0" y="104"/> + <connection refLocalId="31" formalParameter="OUT"> + <position x="520" y="216"/> + <position x="320" y="216"/> + <variable formalParameter="IN5"> + <relPosition x="0" y="128"/> + <connection refLocalId="12"> + <position x="520" y="240"/> + <position x="480" y="240"/> + <variable formalParameter="IN6"> + <relPosition x="0" y="152"/> + <connection refLocalId="2" formalParameter="OUT"> + <position x="520" y="264"/> + <position x="320" y="264"/> + <variable formalParameter="IN7"> + <relPosition x="0" y="176"/> + <connection refLocalId="14"> + <position x="520" y="288"/> + <position x="480" y="288"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <inVariable localId="8" executionOrderId="0" height="24" width="160" negated="false"> + <position x="320" y="128"/> + <relPosition x="160" y="16"/> + <expression>'CSVRdInt("'</expression> + <inVariable localId="9" executionOrderId="0" height="32" width="112" negated="false"> + <position x="200" y="152"/> + <relPosition x="112" y="16"/> + <expression>FILE_NAME</expression> + <inVariable localId="10" executionOrderId="0" height="24" width="112" negated="false"> + <position x="368" y="184"/> + <relPosition x="112" y="8"/> + <expression>'",'</expression> + <inVariable localId="11" executionOrderId="0" height="32" width="112" negated="false"> + <position x="40" y="200"/> + <relPosition x="112" y="16"/> + <expression>ROW</expression> + <inVariable localId="12" executionOrderId="0" height="24" width="112" negated="false"> + <position x="368" y="224"/> + <relPosition x="112" y="16"/> + <expression>','</expression> + <inVariable localId="13" executionOrderId="0" height="32" width="112" negated="false"> + <position x="40" y="248"/> + <relPosition x="112" y="16"/> + <expression>COLUMN</expression> + <inVariable localId="14" executionOrderId="0" height="24" width="112" negated="false"> + <position x="368" y="272"/> + <relPosition x="112" y="16"/> + <expression>')'</expression> + <continuation name="Code" localId="4" height="24" width="128"> + <position x="504" y="496"/> + <relPosition x="128" y="16"/> + <block localId="16" typeName="NE" executionOrderId="0" height="64" width="64"> + <position x="208" y="456"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="22"> + <position x="208" y="488"/> + <position x="188" y="488"/> + <position x="188" y="480"/> + <position x="168" y="480"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="21"> + <position x="208" y="512"/> + <position x="168" y="512"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <outVariable localId="17" executionOrderId="0" height="32" width="66" negated="false"> + <position x="784" y="440"/> + <relPosition x="0" y="16"/> + <connection refLocalId="18" formalParameter="OUT"> + <position x="784" y="456"/> + <position x="744" y="456"/> + <expression>OLDCODE</expression> + <block localId="18" typeName="SEL" executionOrderId="0" height="96" width="64"> + <position x="680" y="424"/> + <variable formalParameter="G"> + <relPosition x="0" y="32"/> + <connection refLocalId="25"> + <position x="680" y="456"/> + <position x="652" y="456"/> + <position x="652" y="448"/> + <position x="624" y="448"/> + <variable formalParameter="IN0"> + <relPosition x="0" y="56"/> + <connection refLocalId="20"> + <position x="680" y="480"/> + <position x="632" y="480"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="80"/> + <connection refLocalId="4"> + <position x="680" y="504"/> + <position x="656" y="504"/> + <position x="656" y="512"/> + <position x="632" y="512"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <inVariable localId="20" executionOrderId="0" height="32" width="72" negated="false"> + <position x="560" y="464"/> + <relPosition x="72" y="16"/> + <expression>OLDCODE</expression> + <inVariable localId="21" executionOrderId="0" height="32" width="72" negated="false"> + <position x="96" y="496"/> + <relPosition x="72" y="16"/> + <expression>OLDCODE</expression> + <continuation name="Code" localId="22" height="24" width="128"> + <position x="40" y="472"/> + <relPosition x="128" y="8"/> + <connector name="CodeChange" localId="23" height="24" width="120"> + <position x="328" y="480"/> + <relPosition x="0" y="16"/> + <connection refLocalId="16" formalParameter="OUT"> + <position x="328" y="496"/> + <position x="300" y="496"/> + <position x="300" y="488"/> + <position x="272" y="488"/> + <continuation name="CodeChange" localId="25" height="24" width="120"> + <position x="504" y="440"/> + <relPosition x="120" y="8"/> + <comment localId="27" height="48" width="312"> + <position x="40" y="376"/> + <xhtml:p><![CDATA[Detect changes in generated code line]]></xhtml:p> + <comment localId="28" height="48" width="520"> + <position x="48" y="560"/> + <xhtml:p><![CDATA[Execute python code on change or globally when CSV is updated]]></xhtml:p> + <comment localId="29" height="40" width="232"> + <position x="64" y="32"/> + <xhtml:p><![CDATA[Generate python code line]]></xhtml:p> + <connector name="Code" localId="30" height="24" width="128"> + <position x="632" y="128"/> + <relPosition x="0" y="16"/> + <connection refLocalId="7" formalParameter="OUT"> + <position x="632" y="144"/> + <position x="584" y="144"/> + <block localId="31" typeName="INT_TO_STRING" executionOrderId="0" height="48" width="120"> + <position x="200" y="184"/> + <variable formalParameter="IN"> + <relPosition x="0" y="32"/> + <connection refLocalId="11"> + <position x="200" y="216"/> + <position x="152" y="216"/> + <variable formalParameter="OUT"> + <relPosition x="120" y="32"/> + <block localId="2" typeName="INT_TO_STRING" executionOrderId="0" height="48" width="120"> + <position x="200" y="232"/> + <variable formalParameter="IN"> + <relPosition x="0" y="32"/> + <connection refLocalId="13"> + <position x="200" y="264"/> + <position x="152" y="264"/> + <variable formalParameter="OUT"> + <relPosition x="120" y="32"/> + <block localId="40" width="104" height="80" typeName="python_eval" instanceName="py_eval0" executionOrderId="0"> + <position x="552" y="640"/> + <variable formalParameter="TRIG"> + <relPosition x="0" y="32"/> + <connection refLocalId="15" formalParameter="OUT"> + <position x="552" y="672"/> + <position x="360" y="672"/> + <variable formalParameter="CODE"> + <relPosition x="0" y="64"/> + <connection refLocalId="41"> + <position x="552" y="704"/> + <position x="528" y="704"/> + <variable formalParameter="ACK"> + <relPosition x="104" y="32"/> + <variable formalParameter="RESULT"> + <relPosition x="104" y="64"/> + <continuation name="Code" localId="41" height="24" width="128"> + <position x="400" y="688"/> + <relPosition x="128" y="16"/> + <inVariable localId="42" height="24" width="152" executionOrderId="0" negated="false"> + <position x="32" y="656"/> + <relPosition x="152" y="16"/> + <expression>pyext_csv_update</expression> + <outVariable localId="43" height="24" width="40" executionOrderId="0" negated="false"> + <position x="1216" y="672"/> + <relPosition x="0" y="16"/> + <connection refLocalId="38" formalParameter="Q1"> + <position x="1216" y="688"/> + <position x="1192" y="688"/> + <position x="1192" y="680"/> + <position x="1168" y="680"/> + <expression>ACK</expression> + <outVariable localId="44" height="24" width="64" executionOrderId="0" negated="false"> + <position x="688" y="744"/> + <relPosition x="0" y="8"/> + <connection refLocalId="40" formalParameter="RESULT"> + <position x="688" y="752"/> + <position x="672" y="752"/> + <position x="672" y="704"/> + <position x="656" y="704"/> + <expression>RESULT</expression> + <block localId="15" typeName="OR" executionOrderId="0" height="64" width="64"> + <position x="296" y="640"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="46" formalParameter="Q"> + <position x="296" y="672"/> + <position x="272" y="672"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="45"> + <position x="296" y="696"/> + <position x="240" y="696"/> + <position x="240" y="704"/> + <position x="184" y="704"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <continuation name="CodeChange" localId="45" height="24" width="120"> + <position x="64" y="688"/> + <relPosition x="120" y="16"/> + <block localId="46" typeName="R_TRIG" instanceName="R_TRIG1" executionOrderId="0" height="48" width="64"> + <position x="208" y="640"/> + <variable formalParameter="CLK"> + <relPosition x="0" y="32"/> + <connection refLocalId="42"> + <position x="208" y="672"/> + <position x="184" y="672"/> + <variable formalParameter="Q"> + <relPosition x="64" y="32"/> + <block localId="33" typeName="LEFT" executionOrderId="0" height="64" width="56"> + <position x="736" y="672"/> + <variable formalParameter="IN"> + <relPosition x="0" y="32"/> + <connection refLocalId="40" formalParameter="RESULT"> + <position x="736" y="704"/> + <position x="656" y="704"/> + <variable formalParameter="L"> + <relPosition x="0" y="56"/> + <connection refLocalId="35"> + <position x="736" y="728"/> + <position x="724" y="728"/> + <position x="724" y="720"/> + <position x="712" y="720"/> + <variable formalParameter="OUT"> + <relPosition x="56" y="32"/> + <block localId="34" typeName="NE" executionOrderId="0" height="64" width="64"> + <position x="880" y="672"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="33" formalParameter="OUT"> + <position x="880" y="704"/> + <position x="792" y="704"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="36"> + <position x="880" y="728"/> + <position x="868" y="728"/> + <position x="868" y="720"/> + <position x="856" y="720"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> + <inVariable localId="35" executionOrderId="0" height="24" width="24" negated="false"> + <position x="688" y="712"/> + <relPosition x="24" y="8"/> + <expression>1</expression> + <inVariable localId="36" executionOrderId="0" height="24" width="40" negated="false"> + <position x="816" y="712"/> + <relPosition x="40" y="8"/> + <expression>'#'</expression> + <block localId="37" typeName="R_TRIG" instanceName="R_TRIG2" executionOrderId="0" height="48" width="64"> + <position x="880" y="616"/> + <variable formalParameter="CLK"> + <relPosition x="0" y="32"/> + <connection refLocalId="40" formalParameter="ACK"> + <position x="880" y="648"/> + <position x="688" y="648"/> + <position x="688" y="672"/> + <position x="656" y="672"/> + <variable formalParameter="Q"> + <relPosition x="64" y="32"/> + <block localId="38" typeName="SR" instanceName="SR0" executionOrderId="0" height="64" width="48"> + <position x="1120" y="648"/> + <variable formalParameter="S1"> + <relPosition x="0" y="32"/> + <connection refLocalId="39" formalParameter="OUT"> + <position x="1120" y="680"/> + <position x="1056" y="680"/> + <variable formalParameter="R" edge="rising"> + <relPosition x="0" y="56"/> + <connection refLocalId="15" formalParameter="OUT"> + <position x="1120" y="704"/> + <position x="1088" y="704"/> + <position x="1088" y="776"/> + <position x="376" y="776"/> + <position x="376" y="672"/> + <position x="360" y="672"/> + <variable formalParameter="Q1"> + <relPosition x="48" y="32"/> + <block localId="39" typeName="AND" executionOrderId="0" height="64" width="64"> + <position x="992" y="648"/> + <variable formalParameter="IN1"> + <relPosition x="0" y="32"/> + <connection refLocalId="37" formalParameter="Q"> + <position x="992" y="680"/> + <position x="976" y="680"/> + <position x="976" y="648"/> + <position x="944" y="648"/> + <variable formalParameter="IN2"> + <relPosition x="0" y="56"/> + <connection refLocalId="34" formalParameter="OUT"> + <position x="992" y="704"/> + <position x="944" y="704"/> + <variable formalParameter="OUT"> + <relPosition x="64" y="32"/> <pou name="python_eval" pouType="functionBlock">
@@ -445,6 +2085,19 @@
+ <configuration name="configuration0"> + <variable name="pyext_csv_update"> + <simpleValue value="TRUE"/> --- a/py_ext/py_ext.py Fri Dec 16 13:41:03 2022 +0100
+++ b/py_ext/py_ext.py Fri Dec 16 13:43:38 2022 +0100
@@ -30,6 +30,98 @@
from py_ext.PythonFileCTNMixin import PythonFileCTNMixin
import util.paths as paths
+pyext_python_lib_code = """ +from collections import OrderedDict +def CSVRdInt(fname, rowidx, colidx): + Return value at row/column pointed by integer indexes + Assumes data starts at first row and first column, no headers. + data = csv_int_files.get(fname, None) + csvfile = open(fname, 'rb') + return "#FILE_NOT_FOUND" + dialect = csv.Sniffer().sniff(csvfile.read(1024)) + reader = csv.reader(csvfile, dialect) + csv_int_files[fname] = data + return "#ROW_NOT_FOUND" + return "#COL_NOT_FOUND" +def CSVRdStr(fname, rowname, colname): + Return value at row/column pointed by a pair of names as string + Assumes first row is column headers and first column is row name. + entry = csv_str_files.get(fname, None) + csvfile = open(fname, 'rb') + return "#FILE_NOT_FOUND" + dialect = csv.Sniffer().sniff(csvfile.read(1024)) + reader = csv.reader(csvfile, dialect) + headers = dict([(name, index) for index, name in enumerate(reader.next()[1:])]) + csv_str_files[fname] = (headers, data) + return "#ROW_NOT_FOUND" + colidx = headers[colname] + return "#COL_NOT_FOUND" + return "#COL_NOT_FOUND" + global csv_int_files, csv_str_files class PythonLibrary(POULibrary):
def GetLibraryPath(self):
@@ -57,7 +149,13 @@
pythonfile.write(plc_python_code)
- return (["py_ext"], [(Gen_Pythonfile_path, IECCFLAGS)], True), ""
+ runtimefile_path = os.path.join(buildpath, "runtime_00_pyext.py") + runtimefile = open(runtimefile_path, 'w') + runtimefile.write(pyext_python_lib_code) + return ((["py_ext"], [(Gen_Pythonfile_path, IECCFLAGS)], True), "", + ("runtime_00_pyext.py", open(runtimefile_path, "rb"))) class PythonFile(PythonFileCTNMixin):