From e7f4e4d1775dd9d3b249947f88f6d1e0e9258bf7 Mon Sep 17 00:00:00 2001 From: ft-Demo <fischertechnik-team@fischer.de> Date: Wed, 7 Dec 2022 08:22:25 +0000 Subject: [PATCH] commit by robo pro coding --- FactoryCalib.blockly | 2 +- FactoryCalib.py | 2 +- lib/Axes1Ref.blockly | 56 ++++---- lib/Axes2Ref.blockly | 40 +++--- lib/Axes2Ref.py | 2 +- lib/File.blockly | 307 ++++++++++++++++++++++++++++--------------- lib/File.py | 43 ++++-- lib/Sound.blockly | 21 ++- lib/Sound.py | 5 + 9 files changed, 307 insertions(+), 171 deletions(-) diff --git a/FactoryCalib.blockly b/FactoryCalib.blockly index ea3f4dd..6336768 100644 --- a/FactoryCalib.blockly +++ b/FactoryCalib.blockly @@ -8,7 +8,7 @@ <field name="instance_name">txt_label_version</field> <value name="value"> <shadow type="text" id="T9nyAyJIRL7l_Nn(S-rd"> - <field name="TEXT">Version 2022/11/23</field> + <field name="TEXT">Version 2022/12/07</field> </shadow> </value> <next> diff --git a/FactoryCalib.py b/FactoryCalib.py index b21795d..1ff4478 100644 --- a/FactoryCalib.py +++ b/FactoryCalib.py @@ -27,7 +27,7 @@ from lib.VGR_NodeRED import * controller_name = None -display.set_attr("txt_label_version.text", str('Version 2022/11/23')) +display.set_attr("txt_label_version.text", str('Version 2022/12/07')) controller_name = os.uname()[1] display.set_attr("txt_label_message2.text", str('<b>http://{}.local:1880/ui</b>'.format(controller_name))) initlib_log(5) diff --git a/lib/Axes1Ref.blockly b/lib/Axes1Ref.blockly index cdd2468..522911f 100644 --- a/lib/Axes1Ref.blockly +++ b/lib/Axes1Ref.blockly @@ -94,6 +94,9 @@ <field name="VAR" id="hF{~;iv5~-F[D/zq8KGa">abspos</field> <value name="VALUE"> <block type="lists_repeat" id="K6PxiIy!M0ZPM%eXY3I%"> + <value name="ITEM"> + <block type="logic_null" id="`TS]8T[BJXJ}BZVu(ixr"/> + </value> <value name="NUM"> <block type="lists_length" id="K=`CbVrWx}_yD!zbtu9V"> <value name="VALUE"> @@ -103,9 +106,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="logic_null" id="`TS]8T[BJXJ}BZVu(ixr"/> - </value> </block> </value> <next> @@ -172,6 +172,11 @@ <field name="VAR" id=".q*ZC?*x[^Y-V.dD]@}z">ts0</field> <value name="VALUE"> <block type="lists_repeat" id="Pk1K%uW1[1:bdhf91-!p"> + <value name="ITEM"> + <block type="math_number" id="P#k{MGjVQFY=M;]uf]:P"> + <field name="NUM">0</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="~nF#}P]7Zb*Q61/gJAT_"> <value name="VALUE"> @@ -181,11 +186,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="math_number" id="P#k{MGjVQFY=M;]uf]:P"> - <field name="NUM">0</field> - </block> - </value> </block> </value> <next> @@ -193,6 +193,11 @@ <field name="VAR" id="x[CFf2N|A$X*-BIQVMJ{">tsdiff</field> <value name="VALUE"> <block type="lists_repeat" id="Ds5[1`B~G}n|v1K,%94)"> + <value name="ITEM"> + <block type="math_number" id="v_DvTro|~Jo)XD%v8e`0"> + <field name="NUM">0</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="uEji:1XMW+s4F1%`z:Z:"> <value name="VALUE"> @@ -202,11 +207,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="math_number" id="v_DvTro|~Jo)XD%v8e`0"> - <field name="NUM">0</field> - </block> - </value> </block> </value> <next> @@ -222,6 +222,11 @@ <field name="VAR" id="#Bi@HCw~R7NGj-Fa6uOG">_ref_valid</field> <value name="VALUE"> <block type="lists_repeat" id="J|MdM4nvD:NI76lJQa$1"> + <value name="ITEM"> + <block type="logic_boolean" id="hBVZ{yC}}YN{IJQ%r-^w"> + <field name="BOOL">FALSE</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="}F;][tV@s?9iTdvRD$gE"> <value name="VALUE"> @@ -231,11 +236,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="logic_boolean" id="hBVZ{yC}}YN{IJQ%r-^w"> - <field name="BOOL">FALSE</field> - </block> - </value> </block> </value> <next> @@ -243,6 +243,11 @@ <field name="VAR" id="x[1RApOQsWgR.d$ChaMI">_ref_last</field> <value name="VALUE"> <block type="lists_repeat" id="q0]F4gB16zUyY)|%:eLU"> + <value name="ITEM"> + <block type="logic_boolean" id="wwQ}Yxne{;9`b*@l4Oge"> + <field name="BOOL">FALSE</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="jL1:ynfF2hhteBWZd+3?"> <value name="VALUE"> @@ -252,11 +257,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="logic_boolean" id="wwQ}Yxne{;9`b*@l4Oge"> - <field name="BOOL">FALSE</field> - </block> - </value> </block> </value> </block> @@ -503,6 +503,11 @@ <field name="VAR" id="#Bi@HCw~R7NGj-Fa6uOG">_ref_valid</field> <value name="VALUE"> <block type="lists_repeat" id="r{d2)?o1(d?6$u%f+z/x"> + <value name="ITEM"> + <block type="logic_boolean" id="(D~LN$^U)uMbV^@RG2R!"> + <field name="BOOL">FALSE</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="5:^H{hP%VW$^t^H2pjAf"> <value name="VALUE"> @@ -512,11 +517,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="logic_boolean" id="(D~LN$^U)uMbV^@RG2R!"> - <field name="BOOL">FALSE</field> - </block> - </value> </block> </value> <next> diff --git a/lib/Axes2Ref.blockly b/lib/Axes2Ref.blockly index 382bf99..4962353 100644 --- a/lib/Axes2Ref.blockly +++ b/lib/Axes2Ref.blockly @@ -54,52 +54,52 @@ <mutation items="10"/> <value name="ADD0"> <block type="math_number" id="!O$+W(9]5e-PF7,h{?7L"> - <field name="NUM">6.4</field> + <field name="NUM">12.8</field> </block> </value> <value name="ADD1"> <block type="math_number" id="EUAd?fxmbY]UoX@aPuQH"> - <field name="NUM">6.4</field> + <field name="NUM">12.8</field> </block> </value> <value name="ADD2"> <block type="math_number" id="1O{$={}+$7|*4X09Srfs"> - <field name="NUM">23</field> + <field name="NUM">46</field> </block> </value> <value name="ADD3"> <block type="math_number" id="QqR2)/eoSwuC%G{U_EHb"> - <field name="NUM">23</field> + <field name="NUM">46</field> </block> </value> <value name="ADD4"> <block type="math_number" id="7W@3%lGpG,#a|!,1,V}#"> - <field name="NUM">4.9</field> + <field name="NUM">9.8</field> </block> </value> <value name="ADD5"> <block type="math_number" id="O)1J)bPRHfI=Wi1xQo,n"> - <field name="NUM">4.9</field> + <field name="NUM">9.8</field> </block> </value> <value name="ADD6"> <block type="math_number" id="*BRj^X(`KgQS~Te-7Q:e"> - <field name="NUM">3.6</field> + <field name="NUM">7.2</field> </block> </value> <value name="ADD7"> <block type="math_number" id="sO(CR_vTm2^6yrlzHQS`"> - <field name="NUM">2.8</field> + <field name="NUM">5.6</field> </block> </value> <value name="ADD8"> <block type="math_number" id=":zQ,^J3E4aMX4GCCs;v@"> - <field name="NUM">2.8</field> + <field name="NUM">5.6</field> </block> </value> <value name="ADD9"> <block type="math_number" id="Ldyr3~qWZ}q{kES:4z{O"> - <field name="NUM">3.6</field> + <field name="NUM">7.2</field> </block> </value> </block> @@ -109,6 +109,11 @@ <field name="VAR" id=".q*ZC?*x[^Y-V.dD]@}z">ts0</field> <value name="VALUE"> <block type="lists_repeat" id="}guL~w/95g18fV1gfD./"> + <value name="ITEM"> + <block type="math_number" id="jCES`geC@3@ae$Pe%eUa"> + <field name="NUM">0</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="dl~/xQH|W],#~~i)~a3i"> <value name="VALUE"> @@ -118,11 +123,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="math_number" id="jCES`geC@3@ae$Pe%eUa"> - <field name="NUM">0</field> - </block> - </value> </block> </value> <next> @@ -130,6 +130,11 @@ <field name="VAR" id="x[CFf2N|A$X*-BIQVMJ{">tsdiff</field> <value name="VALUE"> <block type="lists_repeat" id="}.{W_*s]aWl+=8+d6g,I"> + <value name="ITEM"> + <block type="math_number" id="2fWJ/Y0c|9Y}=+D5ij,a"> + <field name="NUM">0</field> + </block> + </value> <value name="NUM"> <block type="lists_length" id="ZlsZ)(fsuj|iBco:=uQG"> <value name="VALUE"> @@ -139,11 +144,6 @@ </value> </block> </value> - <value name="ITEM"> - <block type="math_number" id="2fWJ/Y0c|9Y}=+D5ij,a"> - <field name="NUM">0</field> - </block> - </value> </block> </value> <next> diff --git a/lib/Axes2Ref.py b/lib/Axes2Ref.py index 9190827..b763665 100644 --- a/lib/Axes2Ref.py +++ b/lib/Axes2Ref.py @@ -47,7 +47,7 @@ def initlib_Axes2Ref(): # 9: MPO turntab con # MPO_E4_M1, MPO_E4_I3 # 10: MPO turntab sa2 # MPO_E4_M1, MPO_E4_I2 SPEED = 512 - TIMEOUT_S = [6.4, 6.4, 23, 23, 4.9, 4.9, 3.6, 2.8, 2.8, 3.6] + TIMEOUT_S = [12.8, 12.8, 46, 46, 9.8, 9.8, 7.2, 5.6, 5.6, 7.2] ts0 = [0] * len(TIMEOUT_S) tsdiff = [0] * len(TIMEOUT_S) _b_exit = False diff --git a/lib/File.blockly b/lib/File.blockly index dc684be..658a354 100644 --- a/lib/File.blockly +++ b/lib/File.blockly @@ -6,13 +6,15 @@ <variable id="x=];gL%,6(c61g@B$oNn">_dps</variable> <variable id="Q-A7f6ROh#LwMnou6o4D">_sld</variable> <variable id="~VV%d%niWCJE,.rkhq+F">fileCalib</variable> - <variable id="eY(=*Fw9.P6A3KQ4bbnw">calib_data_SSC</variable> <variable id="q/.=RAMZ%`q2./=6O!Ce">calib_json</variable> + <variable id="^X8gRF/HEmrlytunn7;)">ts</variable> + <variable id="eY(=*Fw9.P6A3KQ4bbnw">calib_data_SSC</variable> + <variable id="?4vu=X6vfI.yt{~f3K1D">calib_map</variable> <variable id="eiA!#mepCT:$%cp$vq+P">calib_data_HBW</variable> <variable id="0*rgTj2O4/)Q@i|9XZ`3">calib_data_VGR</variable> - <variable id="?4vu=X6vfI.yt{~f3K1D">calib_map</variable> <variable id="}+G;?`L|R%?sGFhd=Dy@">calib_data_DPS</variable> <variable id="I(%pOg6My*c;G}[1Dc^C">calib_data_SLD</variable> + <variable id="a*v8UOjM9uFtoNA^u;d2">file</variable> </variables> <block type="util_python_imports" id="V6K{0l(G9rYO[ebX(2Rg" x="0" y="0"> <field name="value">import json&#10;import logging&#10;import subprocess</field> @@ -36,6 +38,16 @@ <next> <block type="procedures_callnoreturn" id="+HOdbBAO$PjY@PD,sb71"> <mutation name="readFileFactoryCalib"/> + <next> + <block type="util_python" id="1?sde^K5BnwCi7g2uPi!" inline="true"> + <field name="value">#write copy to usb stick .../sda/FactoryCalib.json</field> + <next> + <block type="util_python" id="+6M}sQ`xs?.77FX78B6:" inline="true"> + <field name="value">print('cp /opt/ft/workspaces/FactoryCalib.json /opt/ft/workspaces/ext_usb/sda/FactoryCalib.json')&#10;subprocess.Popen(['cp', '/opt/ft/workspaces/FactoryCalib.json', '/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json'])</field> + </block> + </next> + </block> + </next> </block> </next> </block> @@ -51,8 +63,8 @@ </block> </statement> <next> - <block type="util_python" id="nG6^o?=pHg9+gzdIJ2He"> - <field name="value">subprocess.Popen(['chmod', '777', '/opt/ft/workspaces/FactoryCalib.json'])&#10;subprocess.Popen(['chmod', '777', '/opt/ft/workspaces/FactoryCalib_backup.json'])</field> + <block type="util_python" id="nG6^o?=pHg9+gzdIJ2He" inline="true"> + <field name="value">#subprocess.Popen(['chown', 'ftgui:ftgui', '/opt/ft/workspaces/FactoryCalib.json'])&#10;subprocess.Popen(['chmod', '777', '/opt/ft/workspaces/FactoryCalib.json'])</field> </block> </next> </block> @@ -60,7 +72,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="9Z{MMF)f,(DCE7$ihs`S" x="0" y="535"> + <block type="procedures_defnoreturn" id="9Z{MMF)f,(DCE7$ihs`S" x="0" y="598"> <field name="NAME">readFileFactoryCalib</field> <statement name="STACK"> <block type="util_python" id="tW.WQlx#F;@qe7F:B)~N" inline="true"> @@ -191,7 +203,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="PO#vu;tpeZM?Spos_0:|" x="0" y="1199"> + <block type="procedures_defnoreturn" id="PO#vu;tpeZM?Spos_0:|" x="0" y="1262"> <mutation> <arg name="_ssc" varid="P,VPr)jxSS=4^Bb4`$z%" argid="77dJ)@CT,%;66$#+SWwt"/> <arg name="_hbw" varid="EZUyvqIqrfYH8;AG`eYh" argid="V*Tl-]nWEQ?=k^8N%m1%"/> @@ -209,92 +221,214 @@ <block type="util_python" id="v55a07Ihv}6ZEf)HyifD" inline="true"> <field name="value">logging.log(logging.TRACE, '-')</field> <next> - <block type="variables_set" id="`+zWEW|6E2:z*lV2?SHV"> - <field name="VAR" id="eY(=*Fw9.P6A3KQ4bbnw">calib_data_SSC</field> - <value name="VALUE"> - <block type="variables_get" id="W|gtHSr479+ZZ)R@Cdq2"> - <field name="VAR" id="P,VPr)jxSS=4^Bb4`$z%">_ssc</field> - </block> - </value> + <block type="util_python" id="B:j}V{X%vShCS]qXA(@9" inline="true"> + <field name="value">controller_name = os.uname()[1]</field> <next> - <block type="variables_set" id="?R~(%^}9Pn@,`/h8xN2!"> - <field name="VAR" id="eiA!#mepCT:$%cp$vq+P">calib_data_HBW</field> + <block type="variables_set" id="ImO5aP!y6hBm%Tl}O@_6"> + <field name="VAR" id="^X8gRF/HEmrlytunn7;)">ts</field> <value name="VALUE"> - <block type="variables_get" id="EotcS`xNAjwJN$|p#%Wq"> - <field name="VAR" id="EZUyvqIqrfYH8;AG`eYh">_hbw</field> + <block type="import_function_return" id="+WHPMk!,~9*Tw`}hpp9P"> + <mutation parentId="$)Q!],s(azR.@p50io5,"/> + <field name="name">timestamp_utcnow</field> + <data>$)Q!],s(azR.@p50io5,</data> </block> </value> <next> - <block type="variables_set" id="U0OI#+?h,`re}mIvXWcY"> - <field name="VAR" id="0*rgTj2O4/)Q@i|9XZ`3">calib_data_VGR</field> + <block type="variables_set" id="`+zWEW|6E2:z*lV2?SHV"> + <field name="VAR" id="eY(=*Fw9.P6A3KQ4bbnw">calib_data_SSC</field> <value name="VALUE"> - <block type="variables_get" id="5N^N3jFmt=Lz1}f}]l~C"> - <field name="VAR" id="GV9^=wxY+%D`Ki:9F)Q~">_vgr</field> + <block type="variables_get" id="W|gtHSr479+ZZ)R@Cdq2"> + <field name="VAR" id="P,VPr)jxSS=4^Bb4`$z%">_ssc</field> </block> </value> <next> - <block type="variables_set" id=":CN2*Ui`s??c2nV*BVX6"> - <field name="VAR" id="}+G;?`L|R%?sGFhd=Dy@">calib_data_DPS</field> + <block type="variables_set" id="?R~(%^}9Pn@,`/h8xN2!"> + <field name="VAR" id="eiA!#mepCT:$%cp$vq+P">calib_data_HBW</field> <value name="VALUE"> - <block type="variables_get" id="dGaMNvh)oHKK2?`%e@At"> - <field name="VAR" id="x=];gL%,6(c61g@B$oNn">_dps</field> + <block type="variables_get" id="EotcS`xNAjwJN$|p#%Wq"> + <field name="VAR" id="EZUyvqIqrfYH8;AG`eYh">_hbw</field> </block> </value> <next> - <block type="variables_set" id="@U$G@XK5%b7f[5:VbSl."> - <field name="VAR" id="I(%pOg6My*c;G}[1Dc^C">calib_data_SLD</field> + <block type="variables_set" id="U0OI#+?h,`re}mIvXWcY"> + <field name="VAR" id="0*rgTj2O4/)Q@i|9XZ`3">calib_data_VGR</field> <value name="VALUE"> - <block type="variables_get" id="|vx.kNS?}/y[](,]~/Zr"> - <field name="VAR" id="Q-A7f6ROh#LwMnou6o4D">_sld</field> + <block type="variables_get" id="5N^N3jFmt=Lz1}f}]l~C"> + <field name="VAR" id="GV9^=wxY+%D`Ki:9F)Q~">_vgr</field> </block> </value> <next> - <block type="procedures_callnoreturn" id="p~,;F5r(Q5iGwe%UF|h."> - <mutation name="printData"/> + <block type="variables_set" id=":CN2*Ui`s??c2nV*BVX6"> + <field name="VAR" id="}+G;?`L|R%?sGFhd=Dy@">calib_data_DPS</field> + <value name="VALUE"> + <block type="variables_get" id="dGaMNvh)oHKK2?`%e@At"> + <field name="VAR" id="x=];gL%,6(c61g@B$oNn">_dps</field> + </block> + </value> <next> - <block type="util_python" id="J$_UW[6VMM,O)BY0~oH."> - <field name="value">calib_map = {\&#10;"SSC" : {\&#10;"poslist" : calib_data_SSC[0]\&#10;},\&#10;"HBW" : {\&#10;"poslist" : calib_data_HBW[0]\&#10;},\&#10;"VGR" : {\&#10;"poslist" : calib_data_VGR[0],\&#10;"discard" : calib_data_VGR[1],\&#10;"offset" : calib_data_VGR[2]\&#10;},\&#10;"DPS" : {\&#10;"thresh_white_red" : calib_data_DPS[0],\&#10;"thresh_red_blue" : calib_data_DPS[1]\&#10;},\&#10;"SLD" : {\&#10;"thresh_white_red" : calib_data_SLD[0],\&#10;"thresh_red_blue" : calib_data_SLD[1]\&#10;}\&#10;}</field> + <block type="variables_set" id="@U$G@XK5%b7f[5:VbSl."> + <field name="VAR" id="I(%pOg6My*c;G}[1Dc^C">calib_data_SLD</field> + <value name="VALUE"> + <block type="variables_get" id="|vx.kNS?}/y[](,]~/Zr"> + <field name="VAR" id="Q-A7f6ROh#LwMnou6o4D">_sld</field> + </block> + </value> <next> - <block type="variables_set" id="Vs+(RVZO1m8oluxpEqTW"> - <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> - <value name="VALUE"> - <block type="util_to_json" id="pbPl`ePrH~I`?:RzBc!h"> - <value name="value"> - <block type="variables_get" id=";-u!b]_r;)hs?:Z$Q{a8"> - <field name="VAR" id="?4vu=X6vfI.yt{~f3K1D">calib_map</field> - </block> - </value> - </block> - </value> + <block type="procedures_callnoreturn" id="p~,;F5r(Q5iGwe%UF|h."> + <mutation name="printData"/> <next> - <block type="variables_set" id="|[Ku+J#7*J6txvI*ZIK="> - <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> - <value name="VALUE"> - <block type="open_file" id="-lz|v.D,MYI?d6AgC#(Y"> - <field name="path">/opt/ft/workspaces/FactoryCalib.json</field> - <field name="mode">w</field> - </block> - </value> + <block type="util_python" id="J$_UW[6VMM,O)BY0~oH."> + <field name="value">calib_map = {\&#10;"UID" : controller_name,\&#10;"ts" : ts,\&#10;"SSC" : {\&#10;"poslist" : calib_data_SSC[0]\&#10;},\&#10;"HBW" : {\&#10;"poslist" : calib_data_HBW[0]\&#10;},\&#10;"VGR" : {\&#10;"poslist" : calib_data_VGR[0],\&#10;"discard" : calib_data_VGR[1],\&#10;"offset" : calib_data_VGR[2]\&#10;},\&#10;"DPS" : {\&#10;"thresh_white_red" : calib_data_DPS[0],\&#10;"thresh_red_blue" : calib_data_DPS[1]\&#10;},\&#10;"SLD" : {\&#10;"thresh_white_red" : calib_data_SLD[0],\&#10;"thresh_red_blue" : calib_data_SLD[1]\&#10;}\&#10;}</field> <next> - <block type="write_file" id="Xyd9UH|T;|}=~oUv=wf)"> - <field name="new line">FALSE</field> - <value name="value"> - <block type="variables_get" id="CMrJYzPm5.0@AS7XIg?e"> - <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> - </block> - </value> - <value name="name"> - <block type="variables_get" id="vm#_]i|r^b6:=z^SU,I2"> - <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + <block type="variables_set" id="Vs+(RVZO1m8oluxpEqTW"> + <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> + <value name="VALUE"> + <block type="util_to_json" id="pbPl`ePrH~I`?:RzBc!h"> + <value name="value"> + <block type="variables_get" id=";-u!b]_r;)hs?:Z$Q{a8"> + <field name="VAR" id="?4vu=X6vfI.yt{~f3K1D">calib_map</field> + </block> + </value> </block> </value> <next> - <block type="close_file" id="-H+C5cQki$wy-J!r(azo"> - <value name="name"> - <block type="variables_get" id="v,htJLbJzRgC$tNB{mNt"> - <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + <block type="variables_set" id="|[Ku+J#7*J6txvI*ZIK="> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + <value name="VALUE"> + <block type="open_file" id="-lz|v.D,MYI?d6AgC#(Y"> + <field name="path">/opt/ft/workspaces/FactoryCalib.json</field> + <field name="mode">w</field> </block> </value> + <next> + <block type="write_file" id="Xyd9UH|T;|}=~oUv=wf)"> + <field name="new line">FALSE</field> + <value name="value"> + <block type="variables_get" id="CMrJYzPm5.0@AS7XIg?e"> + <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> + </block> + </value> + <value name="name"> + <block type="variables_get" id="vm#_]i|r^b6:=z^SU,I2"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + </block> + </value> + <next> + <block type="close_file" id="-H+C5cQki$wy-J!r(azo"> + <value name="name"> + <block type="variables_get" id="v,htJLbJzRgC$tNB{mNt"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + </block> + </value> + <next> + <block type="util_python" id=":$+Pe._w42=pGv!!r+M3" inline="true"> + <field name="value">#write backup to usb stick</field> + <next> + <block type="util_python" id="h+c/cbWJp[TLFFN9`$$q" inline="true"> + <field name="value">file = open('/opt/ft/workspaces/ext_usb/sda/'+controller_name, 'w', encoding='utf8')&#10;file.close()</field> + <next> + <block type="variables_set" id="Hh])TIbceD-T4s=U(Ju{"> + <field name="VAR" id="a*v8UOjM9uFtoNA^u;d2">file</field> + <value name="VALUE"> + <block type="open_file" id="8O[+A-:lXCVITgnNnQGD"> + <field name="path">/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json</field> + <field name="mode">w</field> + </block> + </value> + <next> + <block type="variables_set" id="eUP8hbOa+CNHbJPufDoP"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + <value name="VALUE"> + <block type="open_file" id="_u]3(uYacxd)2TO`%-D="> + <field name="path">/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json</field> + <field name="mode">w</field> + </block> + </value> + <next> + <block type="write_file" id="Qc^18_nP]mh:/Y],,!RI"> + <field name="new line">FALSE</field> + <value name="value"> + <block type="variables_get" id="i~,3dtDvV~5c3@$0K:/6"> + <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> + </block> + </value> + <value name="name"> + <block type="variables_get" id="RItd:yN}I+w|iw;2m.yL"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + </block> + </value> + <next> + <block type="close_file" id="E8sa,97/zQk1H]x73H}P"> + <value name="name"> + <block type="variables_get" id="}]`xothGm[@CVqzdL5`8"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + </block> + </value> + <next> + <block type="util_python" id="Izs2GXFiON#$#Yl{Q8;1" inline="true"> + <field name="value">#write backup if usb stick available</field> + <next> + <block type="controls_if" id="09=a@^dj}r4pu#WD/eA6"> + <value name="IF0"> + <block type="exist_file" id="I7|+c5i*^F2*?:6N5#yo"> + <field name="path">/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json</field> + </block> + </value> + <statement name="DO0"> + <block type="variables_set" id="K*DH,4qh!p;ur/6|~F[h"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + <value name="VALUE"> + <block type="open_file" id="yVNjYQ8Th%ZaX#4A|f~J"> + <field name="path">/opt/ft/workspaces/FactoryCalib_backup.json</field> + <field name="mode">w</field> + </block> + </value> + <next> + <block type="write_file" id="5Aks_^CG:3r|wT@(n;^X"> + <field name="new line">FALSE</field> + <value name="value"> + <block type="variables_get" id="RRF]jvzKJCYMj;YbDg/T"> + <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> + </block> + </value> + <value name="name"> + <block type="variables_get" id="PjAAgZ}`zVf?!(S#FKKf"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + </block> + </value> + <next> + <block type="close_file" id="^8,Y3Of?qgB2|tPVM4+l"> + <value name="name"> + <block type="variables_get" id="$N{1fKu=_KJ=vM|ZrGd{"> + <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> + </block> + </value> + </block> + </next> + </block> + </next> + </block> + </statement> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> + </block> + </next> </block> </next> </block> @@ -320,7 +454,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="tVMP(UyYD{#akqawgAD)" x="0" y="2275"> + <block type="procedures_defnoreturn" id="tVMP(UyYD{#akqawgAD)" x="0" y="2859"> <field name="NAME">printData</field> <statement name="STACK"> <block type="util_python" id="?2BTA(iUoYy2fTZ{kwC]" inline="true"> @@ -333,7 +467,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="W_Tm2ceF76n#%|aA^wY=" x="0" y="2544"> + <block type="procedures_defnoreturn" id="W_Tm2ceF76n#%|aA^wY=" x="0" y="3128"> <field name="NAME">writeFileFactoryCalib_current</field> <statement name="STACK"> <block type="util_python" id=":#2-+xit`bp;61|s@=sM" inline="true"> @@ -387,7 +521,7 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="D4S#AhC`3g4!*EYi+(|," x="0" y="2835"> + <block type="procedures_defnoreturn" id="D4S#AhC`3g4!*EYi+(|," x="0" y="3419"> <field name="NAME">writeFileFactoryCalib_defaults</field> <statement name="STACK"> <block type="util_python" id="~Y`c%9oJ)a#:TlTdG*+N" inline="true"> @@ -427,41 +561,6 @@ <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> </block> </value> - <next> - <block type="variables_set" id="K*DH,4qh!p;ur/6|~F[h"> - <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> - <value name="VALUE"> - <block type="open_file" id="yVNjYQ8Th%ZaX#4A|f~J"> - <field name="path">/opt/ft/workspaces/FactoryCalib_backup.json</field> - <field name="mode">w</field> - </block> - </value> - <next> - <block type="write_file" id="5Aks_^CG:3r|wT@(n;^X"> - <field name="new line">FALSE</field> - <value name="value"> - <block type="variables_get" id="RRF]jvzKJCYMj;YbDg/T"> - <field name="VAR" id="q/.=RAMZ%`q2./=6O!Ce">calib_json</field> - </block> - </value> - <value name="name"> - <block type="variables_get" id="PjAAgZ}`zVf?!(S#FKKf"> - <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> - </block> - </value> - <next> - <block type="close_file" id="^8,Y3Of?qgB2|tPVM4+l"> - <value name="name"> - <block type="variables_get" id="$N{1fKu=_KJ=vM|ZrGd{"> - <field name="VAR" id="~VV%d%niWCJE,.rkhq+F">fileCalib</field> - </block> - </value> - </block> - </next> - </block> - </next> - </block> - </next> </block> </next> </block> diff --git a/lib/File.py b/lib/File.py index e9deb00..66f5379 100644 --- a/lib/File.py +++ b/lib/File.py @@ -6,6 +6,7 @@ from lib.DPS import * from lib.HBW_AxesNRef import * from lib.SLD import * from lib.SSC_PTU_Axes1Ref import * +from lib.Time import * from lib.VGR_Axes1Ref import * from os.path import exists @@ -16,30 +17,35 @@ _vgr = None _dps = None _sld = None fileCalib = None -calib_data_SSC = None calib_json = None +ts = None +calib_data_SSC = None +calib_map = None calib_data_HBW = None calib_data_VGR = None -calib_map = None calib_data_DPS = None calib_data_SLD = None +file2 = None def loadFileFactoryCalib(): - global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_data_SSC, calib_json, calib_data_HBW, calib_data_VGR, calib_map, calib_data_DPS, calib_data_SLD + global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_json, ts, calib_data_SSC, calib_map, calib_data_HBW, calib_data_VGR, calib_data_DPS, calib_data_SLD, file2 logging.log(logging.TRACE, '-') if exists('/opt/ft/workspaces/FactoryCalib.json'): logging.log(logging.DEBUG, 'load calibration values') readFileFactoryCalib() + #write copy to usb stick .../sda/FactoryCalib.json + print('cp /opt/ft/workspaces/FactoryCalib.json /opt/ft/workspaces/ext_usb/sda/FactoryCalib.json') + subprocess.Popen(['cp', '/opt/ft/workspaces/FactoryCalib.json', '/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json']) else: logging.log(logging.DEBUG, 'use default calibration values') writeFileFactoryCalib_defaults() + #subprocess.Popen(['chown', 'ftgui:ftgui', '/opt/ft/workspaces/FactoryCalib.json']) subprocess.Popen(['chmod', '777', '/opt/ft/workspaces/FactoryCalib.json']) - subprocess.Popen(['chmod', '777', '/opt/ft/workspaces/FactoryCalib_backup.json']) def readFileFactoryCalib(): - global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_data_SSC, calib_json, calib_data_HBW, calib_data_VGR, calib_map, calib_data_DPS, calib_data_SLD + global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_json, ts, calib_data_SSC, calib_map, calib_data_HBW, calib_data_VGR, calib_data_DPS, calib_data_SLD, file2 logging.log(logging.TRACE, '-') fileCalib = open('/opt/ft/workspaces/FactoryCalib.json', 'r', encoding='utf8') calib_json = fileCalib.read() @@ -60,8 +66,10 @@ def readFileFactoryCalib(): def writeFileFactoryCalib(_ssc, _hbw, _vgr, _dps, _sld): - global fileCalib, calib_data_SSC, calib_json, calib_data_HBW, calib_data_VGR, calib_map, calib_data_DPS, calib_data_SLD + global fileCalib, calib_json, ts, calib_data_SSC, calib_map, calib_data_HBW, calib_data_VGR, calib_data_DPS, calib_data_SLD, file2 logging.log(logging.TRACE, '-') + controller_name = os.uname()[1] + ts = timestamp_utcnow() calib_data_SSC = _ssc calib_data_HBW = _hbw calib_data_VGR = _vgr @@ -69,6 +77,8 @@ def writeFileFactoryCalib(_ssc, _hbw, _vgr, _dps, _sld): calib_data_SLD = _sld printData() calib_map = {\ + "UID" : controller_name,\ + "ts" : ts,\ "SSC" : {\ "poslist" : calib_data_SSC[0]\ },\ @@ -93,10 +103,22 @@ def writeFileFactoryCalib(_ssc, _hbw, _vgr, _dps, _sld): fileCalib = open('/opt/ft/workspaces/FactoryCalib.json', 'w', encoding='utf8') fileCalib.write(calib_json) fileCalib.close() + #write backup to usb stick + file = open('/opt/ft/workspaces/ext_usb/sda/'+controller_name, 'w', encoding='utf8') + file.close() + file2 = open('/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json', 'w', encoding='utf8') + fileCalib = open('/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json', 'w', encoding='utf8') + fileCalib.write(calib_json) + fileCalib.close() + #write backup if usb stick available + if exists('/opt/ft/workspaces/ext_usb/sda/FactoryCalib.json'): + fileCalib = open('/opt/ft/workspaces/FactoryCalib_backup.json', 'w', encoding='utf8') + fileCalib.write(calib_json) + fileCalib.close() def printData(): - global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_data_SSC, calib_json, calib_data_HBW, calib_data_VGR, calib_map, calib_data_DPS, calib_data_SLD + global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_json, ts, calib_data_SSC, calib_map, calib_data_HBW, calib_data_VGR, calib_data_DPS, calib_data_SLD, file2 logging.log(logging.TRACE, '-') print("SSC: ", calib_data_SSC) print("HBW: ", calib_data_HBW) @@ -106,21 +128,18 @@ def printData(): def writeFileFactoryCalib_current(): - global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_data_SSC, calib_json, calib_data_HBW, calib_data_VGR, calib_map, calib_data_DPS, calib_data_SLD + global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_json, ts, calib_data_SSC, calib_map, calib_data_HBW, calib_data_VGR, calib_data_DPS, calib_data_SLD, file2 logging.log(logging.TRACE, '-') writeFileFactoryCalib(get_calib_data_SSC(), get_calib_data_HBW(), get_calib_data_VGR(), get_calib_data_DPS(), get_calib_data_SLD()) def writeFileFactoryCalib_defaults(): - global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_data_SSC, calib_json, calib_data_HBW, calib_data_VGR, calib_map, calib_data_DPS, calib_data_SLD + global _ssc, _hbw, _vgr, _dps, _sld, fileCalib, calib_json, ts, calib_data_SSC, calib_map, calib_data_HBW, calib_data_VGR, calib_data_DPS, calib_data_SLD, file2 logging.log(logging.TRACE, '-') if exists('/opt/ft/workspaces/FactoryCalib.json'): fileCalib = open('/opt/ft/workspaces/FactoryCalib.json', 'r', encoding='utf8') calib_json = fileCalib.read() fileCalib.close() - fileCalib = open('/opt/ft/workspaces/FactoryCalib_backup.json', 'w', encoding='utf8') - fileCalib.write(calib_json) - fileCalib.close() writeFileFactoryCalib(get_calib_data_SSC_defaults(), get_calib_data_HBW_defaults(), get_calib_data_VGR_defaults(), get_calib_data_DPS_defaults(), get_calib_data_SLD_defaults()) diff --git a/lib/Sound.blockly b/lib/Sound.blockly index 84f6fc1..0c2868c 100644 --- a/lib/Sound.blockly +++ b/lib/Sound.blockly @@ -2,7 +2,7 @@ <block type="util_python_imports" id="gc{@hX#/dbc^}P{QV*,/" x="0" y="0"> <field name="value">import logging</field> </block> - <block type="procedures_defnoreturn" id="g#$Nkpc:!mK+0t)YGQv(" x="0" y="101"> + <block type="procedures_defnoreturn" id="g#$Nkpc:!mK+0t)YGQv(" x="0" y="103"> <field name="NAME">beep</field> <statement name="STACK"> <block type="util_python" id="{fH8*[TO%d%XFW*j8b#d" inline="true"> @@ -15,17 +15,30 @@ </block> </statement> </block> - <block type="procedures_defnoreturn" id="$85jmt,h,pz0rRv^q[al" x="0" y="244"> + <block type="procedures_defnoreturn" id="IIkg9RVO;{AX,6L,O[`L" x="0" y="249"> + <field name="NAME">beep_blocked</field> + <statement name="STACK"> + <block type="util_python" id="S4nH+G5m.zqupNwGGl.;" inline="true"> + <field name="value">logging.log(logging.TRACE, '-')</field> + <next> + <block type="procedures_callnoreturn" id="eF`+yzt~QE)]Ly9;jp8`"> + <mutation name="thread_sound"/> + </block> + </next> + </block> + </statement> + </block> + <block type="procedures_defnoreturn" id="$85jmt,h,pz0rRv^q[al" x="0" y="395"> <field name="NAME">thread_sound</field> <statement name="STACK"> <block type="sound_play_audio_file" id="oXR+PF+C0YNR+k63|B=S"> <field name="soundfile_name">06_Car_horn_short.wav</field> <field name="checkbox">FALSE</field> <next> - <block type="util_wait_for" id="k{9}Awc.DGB@^~!F/I]{"> + <block type="util_wait_for" id="+UWV5cv^]x?6A2]G/969"> <field name="format">ms</field> <value name="value"> - <shadow type="math_number" id="utosu0_34q?8SSL%f]yD"> + <shadow type="math_number" id="4:Fp*Sd^/e$]9khhBd!k"> <field name="NUM">200</field> </shadow> </value> diff --git a/lib/Sound.py b/lib/Sound.py index 45df036..41724c0 100644 --- a/lib/Sound.py +++ b/lib/Sound.py @@ -10,6 +10,11 @@ def beep(): threading.Thread(target=thread_sound, daemon=True).start() +def beep_blocked(): + logging.log(logging.TRACE, '-') + thread_sound() + + def thread_sound(): TXT_SSC_M.get_loudspeaker().play("06_Car_horn_short.wav", False) time.sleep(0.2) -- GitLab