Skip to content
Snippets Groups Projects
Commit d8b48ff6 authored by ft-Demo's avatar ft-Demo
Browse files

commit by robo pro coding

parent 08f985b5
No related branches found
No related tags found
No related merge requests found
......@@ -2,6 +2,7 @@ import threading
from lib.Axes1Ref import *
from lib.Axes2Ref import *
from lib.ColorCalib import *
from lib.controller import *
from lib.display import *
from lib.DPS import *
......
<xml xmlns="https://developers.google.com/blockly/xml" version="14">
<variables>
<variable id="2hXKDa]i2lK78Fcn!kS7">v</variable>
<variable id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</variable>
<variable id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</variable>
<variable id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</variable>
<variable id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</variable>
<variable id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</variable>
</variables>
<block type="util_python_imports" id="x9R(,!yKv%F:*-v(S5F)" x="0" y="0">
<field name="value">import logging</field>
</block>
<block type="procedures_defnoreturn" id="VSmATTY?.L[C{f,=c#1:" x="0" y="103">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="I@B?}jt30*H/Nrzr)p2."/>
</mutation>
<field name="NAME">set_calibvalue_white</field>
<field name="I@B?}jt30*H/Nrzr)p2.">v</field>
<statement name="STACK">
<block type="variables_set" id="a${YCHPG(AjwADE3zHI6">
<field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field>
<value name="VALUE">
<block type="variables_get" id="p=~K_g5Zv**:PM^83o6H">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="(h]YqJ@0g{:(ai*WF@?!" x="0" y="243">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="`,@l)KD{{wbrC!|u;.cC"/>
</mutation>
<field name="NAME">set_calibvalue_red</field>
<field name="`,@l)KD{{wbrC!|u;.cC">v</field>
<statement name="STACK">
<block type="variables_set" id="BBa*zP(r{37tQcU/Kxn?">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
<value name="VALUE">
<block type="variables_get" id="3jiT1mXL`X+gHmxkobxF">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="L]1+4A^?Yt^]vOcR=Sf5" x="0" y="383">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="|#3L}sF}`~w2aK|mn7._"/>
</mutation>
<field name="NAME">set_calibvalue_blue</field>
<field name="|#3L}sF}`~w2aK|mn7._">v</field>
<statement name="STACK">
<block type="variables_set" id="?MM-tl:E%H)cVd;-8OqZ">
<field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field>
<value name="VALUE">
<block type="variables_get" id="DeVn})_ksw.U{m1th0;0">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defreturn" id="cYBcy|]-F?s-:oG+Ch0Q" x="0" y="523">
<field name="NAME">get_calibvalue_list</field>
<value name="RETURN">
<block type="lists_create_with" id="@$jB[eQO!ql}q5LGgpF9">
<mutation items="3"/>
<value name="ADD0">
<block type="variables_get" id="V#st)gBU=4!v,6j5Zr0z">
<field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get" id="P8NBkGe1!xnMK]Kx|?,h">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
</block>
</value>
<value name="ADD2">
<block type="variables_get" id="gCp5RVPDngcJSq.J3;^U">
<field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field>
</block>
</value>
</block>
</value>
</block>
<block type="procedures_defnoreturn" id="By#/eOVl{%tWXHnq;[t8" x="0" y="702">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid=",],|#/r)~Xl=JL*8taHJ"/>
</mutation>
<field name="NAME">set_thresh_white_red</field>
<field name=",],|#/r)~Xl=JL*8taHJ">v</field>
<statement name="STACK">
<block type="variables_set" id="UD+uDG:i:wX*)5qZ@^}{">
<field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field>
<value name="VALUE">
<block type="variables_get" id="bRmRH4D6Oi=R]PPIe,e*">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="Z!dZf*!e$c:zz,}xl0R~" x="0" y="842">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="Nz7/7d0Ek!?Vdf4NY1ae"/>
</mutation>
<field name="NAME">set_thresh_red_blue</field>
<field name="Nz7/7d0Ek!?Vdf4NY1ae">v</field>
<statement name="STACK">
<block type="variables_set" id="-OcEtX|C/9dSL#-,18]v">
<field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field>
<value name="VALUE">
<block type="variables_get" id="bWou2ch7.W|QJQY[2VOJ">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defreturn" id="3{p]h$WzxQ#8708wyjj:" x="0" y="982">
<field name="NAME">get_thresh_list</field>
<value name="RETURN">
<block type="lists_create_with" id="_,dzXWzP31K6}|b;j]]-">
<mutation items="2"/>
<value name="ADD0">
<block type="variables_get" id="ug`[1g-@%4/SjaYx4}NK">
<field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get" id="EbxSGe}4-]w[}8NI8Fa}">
<field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field>
</block>
</value>
</block>
</value>
</block>
<block type="procedures_defnoreturn" id="G(e53s]+_0LtKYhM25sz" x="0" y="1132">
<field name="NAME">calculate_thresh</field>
<statement name="STACK">
<block type="variables_set" id="_*=Fb*]_gOn_Lz8Sfioz">
<field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field>
<value name="VALUE">
<block type="math_round" id="]NG|19#7?B^?/jS1O}KV">
<field name="OP">ROUND</field>
<field name="DECIMALS">0</field>
<value name="NUM">
<block type="math_arithmetic" id="U^ALKK03f|sdoI32b1+{">
<field name="OP">DIVIDE</field>
<value name="A">
<block type="math_arithmetic" id="5XFO~B:[o[C9ZOF|Zeq*">
<field name="OP">ADD</field>
<value name="A">
<block type="variables_get" id="XoDs~!=~yCdr~.Y/]h,-">
<field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="%kKzq$jcq0n=C5|M])4D">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="qwgU^#:ajwc4JS_SsD}[">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="yp`a}#gO/DclN@aT1*-m">
<field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field>
<value name="VALUE">
<block type="math_round" id="Eq1uHC2-adQSHRfTiRQ!">
<field name="OP">ROUND</field>
<field name="DECIMALS">0</field>
<value name="NUM">
<block type="math_arithmetic" id="el*K!Elt+,MePUqAP1JA">
<field name="OP">DIVIDE</field>
<value name="A">
<block type="math_arithmetic" id="b.yA5V#fe3MGn~b^_P3A">
<field name="OP">ADD</field>
<value name="A">
<block type="variables_get" id="o(my3Un1G.N:2E;H(mO{">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="Ow%Zf1rOO0*}|UYk#{uY">
<field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id=")}d.#^Fx=$r[SAo02Np=">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
</xml>
\ No newline at end of file
import logging
import math
v = None
calibvalue_white = None
calibvalue_red = None
calibvalue_blue = None
thresh_white_red = None
thresh_red_blue = None
def set_calibvalue_white(v):
global calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
calibvalue_white = v
def set_calibvalue_red(v):
global calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
calibvalue_red = v
def set_calibvalue_blue(v):
global calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
calibvalue_blue = v
def get_calibvalue_list():
global v, calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
return [calibvalue_white, calibvalue_red, calibvalue_blue]
def set_thresh_white_red(v):
global calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
thresh_white_red = v
def set_thresh_red_blue(v):
global calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
thresh_red_blue = v
def get_thresh_list():
global v, calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
return [thresh_white_red, thresh_red_blue]
def calculate_thresh():
global v, calibvalue_white, calibvalue_red, calibvalue_blue, thresh_white_red, thresh_red_blue
thresh_white_red = round((calibvalue_white + calibvalue_red) / 2)
thresh_red_blue = round((calibvalue_red + calibvalue_blue) / 2)
This diff is collapsed.
import json
import logging
import math
import paho.mqtt.client as mqtt
from datetime import datetime
from fischertechnik.mqtt.MqttClient import MqttClient
from lib.ColorCalib import *
from lib.display import *
from lib.DPS import *
from lib.HBW_AxesNRef import *
from lib.HBW_NodeRED import *
from lib.SLD import *
from lib.SLD_NodeRED import *
from lib.SSC_Lights import *
from lib.SSC_NodeRED import *
......@@ -30,7 +34,14 @@ payload = None
gtyp_Setup_x_Color_Sensor_Calibration = None
state_positioning = None
gtyp_Setup_i_Color_Sensor_Selection = None
gtyp_Setup_w_Actual_ColorValue = None
gtyp_Setup_w_Threshold_White_Red = None
gtyp_Setup_w_Threshold_Red_Blue = None
gtyp_SSC_w_Threshold_Red_Blue = None
gtyp_Setup_di_Pos_Rotate = None
gtyp_SLD_w_Threshold_Red_Blue = None
gtyp_SSC_w_Threshold_White_Red = None
gtyp_SLD_w_Threshold_White_Red = None
gtyp_Setup_di_Pos_Vertical = None
ts = None
controller_name = None
......@@ -38,7 +49,7 @@ gtyp_Setup_di_Pos_Horizontal = None
def processReceivedMessage(topic, m_decode):
global client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
logging.log(logging.TRACE, '%s %s', topic, m_decode)
if topic == 'gtyp_Setup/x_Set_Pos_Activ':
logging.debug('activate')
......@@ -121,12 +132,23 @@ def processReceivedMessage(topic, m_decode):
logging.debug('offset')
elif topic == 'gtyp_Setup/x_Set_Calib_Value_Color_Blue':
logging.debug('blue')
set_calibvalue_blue(gtyp_Setup_w_Actual_ColorValue)
client.publish(topic='gtyp_Setup/w_Calib_ColorValue_Blue', payload=(get_calibvalue_list())[2], qos=2, retain=False)
elif topic == 'gtyp_Setup/x_Set_Calib_Value_Color_Red':
logging.debug('red')
set_calibvalue_red(gtyp_Setup_w_Actual_ColorValue)
client.publish(topic='gtyp_Setup/w_Calib_ColorValue_Red', payload=(get_calibvalue_list())[1], qos=2, retain=False)
elif topic == 'gtyp_Setup/x_Set_Calib_Value_Color_White':
logging.debug('white')
set_calibvalue_white(gtyp_Setup_w_Actual_ColorValue)
client.publish(topic='gtyp_Setup/w_Calib_ColorValue_White', payload=(get_calibvalue_list())[0], qos=2, retain=False)
elif topic == 'gtyp_Setup/x_Calculate_Value_Color':
logging.debug('calculate')
calculate_thresh()
gtyp_Setup_w_Threshold_White_Red = (get_thresh_list())[0]
gtyp_Setup_w_Threshold_Red_Blue = (get_thresh_list())[1]
client.publish(topic='gtyp_Setup/w_Threshold_White_Red', payload=gtyp_Setup_w_Threshold_White_Red, qos=2, retain=False)
client.publish(topic='gtyp_Setup/w_Threshold_Red_Blue', payload=gtyp_Setup_w_Threshold_Red_Blue, qos=2, retain=False)
elif topic == 'gtyp_Setup/x_Color_Sensor_Calibration':
logging.debug('calibrate color sensor')
gtyp_Setup_x_Color_Sensor_Calibration = m_decode
......@@ -136,15 +158,32 @@ def processReceivedMessage(topic, m_decode):
else:
set_lights_mode(0)
display.set_attr("txt_status_indicator.active", str(False).lower())
gtyp_Setup_w_Actual_ColorValue = 0
elif topic == 'gtyp_Setup/i_Color_Sensor_Selection':
logging.debug('sensor selection')
gtyp_Setup_i_Color_Sensor_Selection = int(m_decode, 10)
if gtyp_Setup_i_Color_Sensor_Selection == 1:
logging.debug('1')
gtyp_Setup_w_Actual_ColorValue = round(readColorValue())
gtyp_SLD_w_Threshold_Red_Blue = (get_calib_data_SLD())[0]
gtyp_SLD_w_Threshold_White_Red = (get_calib_data_SLD())[1]
elif gtyp_Setup_i_Color_Sensor_Selection == 2:
logging.debug('2')
gtyp_Setup_w_Actual_ColorValue = readDPSColorValue()
gtyp_SSC_w_Threshold_Red_Blue = (get_calib_data_DPS())[0]
gtyp_SSC_w_Threshold_White_Red = (get_calib_data_DPS())[1]
else:
logging.debug('none')
gtyp_SSC_w_Threshold_Red_Blue = 0
gtyp_SSC_w_Threshold_White_Red = 0
gtyp_SLD_w_Threshold_Red_Blue = 0
gtyp_SLD_w_Threshold_White_Red = 0
gtyp_Setup_w_Actual_ColorValue = 0
client.publish(topic='gtyp_Setup/w_Actual_ColorValue', payload=gtyp_Setup_w_Actual_ColorValue, qos=2, retain=False)
client.publish(topic='gtyp_SLD/w_Threshold_White_Red', payload=gtyp_SLD_w_Threshold_White_Red, qos=2, retain=False)
client.publish(topic='gtyp_SLD/w_Threshold_Red_Blue', payload=gtyp_SLD_w_Threshold_Red_Blue, qos=2, retain=False)
client.publish(topic='gtyp_SSC/w_Threshold_White_Red', payload=gtyp_SSC_w_Threshold_White_Red, qos=2, retain=False)
client.publish(topic='gtyp_SSC/w_Threshold_Red_Blue', payload=gtyp_SSC_w_Threshold_Red_Blue, qos=2, retain=False)
elif topic == 'gtyp_Setup/x_Counter_Value_Calibration':
logging.debug('calibrate push out')
elif topic == 'gtyp_Setup/x_Set_CounterValues':
......@@ -162,7 +201,7 @@ def processReceivedMessage(topic, m_decode):
def initMQTTLocal():
global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
gtyp_Setup_x_Set_Pos_Activ = 0
gtyp_Setup_i_Pos_Selection = 0
gtyp_Setup_x_Color_Sensor_Calibration = 0
......@@ -183,7 +222,7 @@ def initMQTTLocal():
def thread_MQTTLocal():
global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, client, userdata, flags, rc, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
logging.debug('-')
#client.loop_forever()
client.loop_start()
......@@ -192,7 +231,7 @@ def thread_MQTTLocal():
def on_connect(client, userdata, flags, rc):
global topic, m_decode, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
print("Connection returned result: "+mqtt.connack_string(rc))
client.subscribe("#")
#client.subscribe("$SYS/#")
......@@ -209,23 +248,23 @@ def on_connect(client, userdata, flags, rc):
def on_disconnect(client, userdata, rc):
global topic, m_decode, flags, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, flags, mid, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
if rc != 0:
print("Unexpected disconnection.")
def on_publish(client, userdata, mid):
global topic, m_decode, flags, rc, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, flags, rc, granted_qos, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
#print("on_publish")
def on_subscribe(client, userdata, mid, granted_qos):
global topic, m_decode, flags, rc, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, flags, rc, msg, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
print("on_subscribe")
def on_message(client, userdata, msg):
global topic, m_decode, flags, rc, mid, granted_qos, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_di_Pos_Rotate, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
global topic, m_decode, flags, rc, mid, granted_qos, gtyp_Setup_x_Set_Pos_Activ, gtyp_Setup_i_Pos_Selection, payload, gtyp_Setup_x_Color_Sensor_Calibration, state_positioning, gtyp_Setup_i_Color_Sensor_Selection, gtyp_Setup_w_Actual_ColorValue, gtyp_Setup_w_Threshold_White_Red, gtyp_Setup_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_Red_Blue, gtyp_Setup_di_Pos_Rotate, gtyp_SLD_w_Threshold_Red_Blue, gtyp_SSC_w_Threshold_White_Red, gtyp_SLD_w_Threshold_White_Red, gtyp_Setup_di_Pos_Vertical, ts, controller_name, gtyp_Setup_di_Pos_Horizontal
print("Received message '" + str(msg.payload) + "' on topic '"
+ msg.topic + "' with QoS " + str(msg.qos))
......
......@@ -4,17 +4,16 @@
<variable id="x?rbx}Z!7+Jx9E.L=:pX">_code</variable>
<variable id="Hq*BSR/(QEo9c0kQRW{y">_active</variable>
<variable id="1X|m)*QO^oo}EfHf=nBO">speed</variable>
<variable id="2hXKDa]i2lK78Fcn!kS7">v</variable>
<variable id="78bW9521)(I[oMydfNIz">state_code</variable>
<variable id="[V))lfBm^j7t@3LJVWGf">state_active</variable>
<variable id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</variable>
<variable id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</variable>
<variable id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</variable>
<variable id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</variable>
<variable id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</variable>
<variable id="?]F?rtn:F#wq@5Ag|9yE">thresh_white_red_defaults</variable>
<variable id="Krv1?O$_~Yha=/]3-u{i">thresh_red_blue_defaults</variable>
<variable id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</variable>
<variable id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</variable>
<variable id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</variable>
<variable id="g%%DHmT#UX~.YdQn3gcf">_ts_state</variable>
<variable id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</variable>
<variable id="caAu/l+mpfP^b1#tA{Kr">detectedColorValue</variable>
<variable id="?Hi+81vv*K@yZim!8fD_">lastColorValue</variable>
<variable id="_?QtuoxDM2ZJ#rQLHhaQ">counter</variable>
......@@ -23,196 +22,7 @@
<block type="util_python_imports" id=".e$$DS-W;QA]vq3]8xZ(" x="0" y="0">
<field name="value">import logging</field>
</block>
<block type="procedures_defnoreturn" id="CpW/ole-H2rC#biYY(;s" x="0" y="103">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid=",],|#/r)~Xl=JL*8taHJ"/>
</mutation>
<field name="NAME">set_thresh_white_red</field>
<field name=",],|#/r)~Xl=JL*8taHJ">v</field>
<statement name="STACK">
<block type="variables_set" id="3*3|dp7u~ki(*nK_4Ekt">
<field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field>
<value name="VALUE">
<block type="variables_get" id="/o6UTd6e2cy=Pj`s9)(c">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="h5y$(R^WIO%kMWuCgE+;" x="0" y="243">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="Nz7/7d0Ek!?Vdf4NY1ae"/>
</mutation>
<field name="NAME">set_thresh_red_blue</field>
<field name="Nz7/7d0Ek!?Vdf4NY1ae">v</field>
<statement name="STACK">
<block type="variables_set" id="eNRG|p(-%_Yz!$K``W6e">
<field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field>
<value name="VALUE">
<block type="variables_get" id="2|LmmIczudHT]_cFHQ(?">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defreturn" id="qn64~^UH=QV4|-w^OiX3" x="0" y="383">
<field name="NAME">get_thresh_list</field>
<value name="RETURN">
<block type="lists_create_with" id="?W6`HZcED/e(AP1BFbYr">
<mutation items="2"/>
<value name="ADD0">
<block type="variables_get" id="m1@Y1bkb,1*Dg+eexmKl">
<field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get" id="a^.?2Q=ibO,1}0)/Gzic">
<field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field>
</block>
</value>
</block>
</value>
</block>
<block type="procedures_defnoreturn" id="]HGe}R8RwUwfQdy0ms1)" x="0" y="533">
<field name="NAME">calculate_thresh</field>
<statement name="STACK">
<block type="variables_set" id="N:HH93LfZOGlsAZG*0jY">
<field name="VAR" id="P?9)xi9bG(6)T87+%iT!">thresh_white_red</field>
<value name="VALUE">
<block type="math_arithmetic" id="[kHN2Ju34-JM]=ZC}~f?">
<field name="OP">DIVIDE</field>
<value name="A">
<block type="math_arithmetic" id="Fr%[L18*%c*+$xkRRmm`">
<field name="OP">ADD</field>
<value name="A">
<block type="variables_get" id="RSPH{qq0p*_4E(i!EK*8">
<field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="5*`ipxd4{J+n1q|w{zP|">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="LtL_9k`{^Y-{qpG{QxgS">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
<next>
<block type="variables_set" id="3S~xH!-(5jp{N@[Pb]w;">
<field name="VAR" id="c5f:;cPsd?218L=sb[nF">thresh_red_blue</field>
<value name="VALUE">
<block type="math_arithmetic" id="w,QV?:Z:8I@CqD-ihD0C">
<field name="OP">DIVIDE</field>
<value name="A">
<block type="math_arithmetic" id="wmEObo)Jdr;sB0A=s3aF">
<field name="OP">ADD</field>
<value name="A">
<block type="variables_get" id="]vb#C}h4E[V$hzr5g55@">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
</block>
</value>
<value name="B">
<block type="variables_get" id="IbH+K4}=A;gbp*8R,31%">
<field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field>
</block>
</value>
</block>
</value>
<value name="B">
<block type="math_number" id="h(o(_rZpB6ZmzlHuM9V}">
<field name="NUM">2</field>
</block>
</value>
</block>
</value>
</block>
</next>
</block>
</statement>
</block>
<block type="procedures_defreturn" id="9Cj-Yafy$tg0`VH?3)S=" x="0" y="713">
<field name="NAME">get_calibvalue_list</field>
<value name="RETURN">
<block type="lists_create_with" id="Wj)6C/61+mbvY6}p$eoh">
<mutation items="3"/>
<value name="ADD0">
<block type="variables_get" id="5v3ziq5pvqDqT/9ZVwP,">
<field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field>
</block>
</value>
<value name="ADD1">
<block type="variables_get" id="jWM[pB(F5IbtNLP-Bpb.">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
</block>
</value>
<value name="ADD2">
<block type="variables_get" id="Z@i#@^B6DW,*;PXxhc$4">
<field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field>
</block>
</value>
</block>
</value>
</block>
<block type="procedures_defnoreturn" id="~J*0~mN(wH1HdQ6+g*8O" x="0" y="892">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="I@B?}jt30*H/Nrzr)p2."/>
</mutation>
<field name="NAME">set_calibvalue_white</field>
<field name="I@B?}jt30*H/Nrzr)p2.">v</field>
<statement name="STACK">
<block type="variables_set" id="u,NtKTmx-[!KhZUdvkHW">
<field name="VAR" id="?hGLg[3H[9:g]?:4%%_%">calibvalue_white</field>
<value name="VALUE">
<block type="variables_get" id="2c{|eTtuT+eA#t@SrFza">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="uiAN]3!dL*HgM2PpP/Mr" x="0" y="1032">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="`,@l)KD{{wbrC!|u;.cC"/>
</mutation>
<field name="NAME">set_calibvalue_red</field>
<field name="`,@l)KD{{wbrC!|u;.cC">v</field>
<statement name="STACK">
<block type="variables_set" id="rAVx5ZwsP~^Ist#lCB4Q">
<field name="VAR" id="yo`fPT*$(K2EHr+p;E@^">calibvalue_red</field>
<value name="VALUE">
<block type="variables_get" id="h~F1rD.B2[TwE|gC@qJh">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="9]2A$:IB|S6O$D~zhA=2" x="0" y="1172">
<mutation>
<arg name="v" varid="2hXKDa]i2lK78Fcn!kS7" argid="|#3L}sF}`~w2aK|mn7._"/>
</mutation>
<field name="NAME">set_calibvalue_blue</field>
<field name="|#3L}sF}`~w2aK|mn7._">v</field>
<statement name="STACK">
<block type="variables_set" id="QtVj+{4OkTrFB5EM^Ye@">
<field name="VAR" id="u~VUTh^5;XCqV.t^iE,B">calibvalue_blue</field>
<value name="VALUE">
<block type="variables_get" id="|0z?+.gMKUwLyinAgUEX">
<field name="VAR" id="2hXKDa]i2lK78Fcn!kS7">v</field>
</block>
</value>
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="]$}!d~iPi$faCfYn-,02" x="0" y="1312">
<block type="procedures_defnoreturn" id="]$}!d~iPi$faCfYn-,02" x="0" y="101">
<field name="NAME">thread_SLD</field>
<statement name="STACK">
<block type="util_python" id="or=tulIX]{S?#ofKV+]h" inline="true">
......@@ -776,7 +586,7 @@
</block>
</statement>
</block>
<block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="3295">
<block type="procedures_defreturn" id="x=/1p3KO=Q%QK7t2K5l%" x="0" y="2030">
<field name="NAME">get_calib_data_SLD_defaults</field>
<statement name="STACK">
<block type="util_python" id="cO!#.ICg79WkS?A?cG[j" inline="true">
......@@ -799,7 +609,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="3460">
<block type="procedures_defreturn" id="b|1;0mU=wNNO2Ry{f6,Z" x="0" y="2191">
<field name="NAME">get_calib_data_SLD</field>
<statement name="STACK">
<block type="util_python" id="t;Zg(`vb3R)aQZ])LhpC" inline="true">
......@@ -822,7 +632,7 @@
</block>
</value>
</block>
<block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="3625">
<block type="procedures_defnoreturn" id="3Qf0~|~$oG8z5tP{6Km;" x="0" y="2352">
<mutation>
<arg name="_data" varid="$E/GDp,,dwQrGbs7N*=C" argid="^}Z*XZLpIfstV5L7ggN|"/>
</mutation>
......@@ -878,7 +688,7 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="3849">
<block type="procedures_defnoreturn" id="gsD|}/@_.f.D_8KfM;**" x="0" y="2571">
<mutation>
<arg name="_code" varid="x?rbx}Z!7+Jx9E.L=:pX" argid=",ZCb|vi(m3g0A4u*(!{`"/>
<arg name="_active" varid="Hq*BSR/(QEo9c0kQRW{y" argid="mqa@Al(.5xeP*B]Jl`8%"/>
......@@ -961,7 +771,7 @@
</block>
</statement>
</block>
<block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="4203">
<block type="procedures_defreturn" id="eO[xQ[akMe*EVjm,{7m0" x="0" y="2916">
<field name="NAME">get_state_code_SLD</field>
<statement name="STACK">
<block type="util_python" id="(HOmJd*Bw@nwPNCHY0mu" inline="true">
......@@ -974,7 +784,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="4339">
<block type="procedures_defreturn" id="wpN6M:c*2cKgK+MM+G.W" x="0" y="3049">
<field name="NAME">get_state_active_SLD</field>
<statement name="STACK">
<block type="util_python" id="Ht%%JB`?HUum}h9K*t-9" inline="true">
......@@ -987,7 +797,7 @@
</block>
</value>
</block>
<block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="4475">
<block type="procedures_defnoreturn" id="%z2U,T)U0wd2S}!Lot[s" x="0" y="3182">
<mutation>
<arg name="speed" varid="1X|m)*QO^oo}EfHf=nBO" argid="pePpK@*+w{Ry]Ltz(Z95"/>
</mutation>
......@@ -1013,7 +823,7 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="4650">
<block type="procedures_defnoreturn" id="IKFw+yZgK[}QgIvIQk]A" x="0" y="3353">
<field name="NAME">ejectWhite</field>
<statement name="STACK">
<block type="util_python" id="L9].u`N0?,H+tU)=o?Me" inline="true">
......@@ -1089,7 +899,7 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="5027">
<block type="procedures_defnoreturn" id="M^8-tj!Sv{KHcQSAS;$K" x="0" y="3720">
<field name="NAME">ejectRed</field>
<statement name="STACK">
<block type="util_python" id="?:UCrMJUl%q(jYcN8(IE" inline="true">
......@@ -1165,7 +975,7 @@
</block>
</statement>
</block>
<block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="5404">
<block type="procedures_defnoreturn" id="YLSy9_KOy{GM#LBmqJ8x" x="0" y="4087">
<field name="NAME">ejectBlue</field>
<statement name="STACK">
<block type="util_python" id="n-s%L0Ie7qkf@WU-[H8o" inline="true">
......@@ -1241,7 +1051,7 @@
</block>
</statement>
</block>
<block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="5781">
<block type="procedures_defreturn" id="0.,m:~DVx{zBe-|XxpG-" x="0" y="4454">
<field name="NAME">isColorSensorTriggered</field>
<statement name="STACK">
<block type="util_python" id="23n|f!bBfO#m?@_HlHB}" inline="true">
......@@ -1255,7 +1065,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="5917">
<block type="procedures_defreturn" id="}*yI=aY}$^7875;e4Wo_" x="0" y="4587">
<field name="NAME">isEjectionTriggered</field>
<statement name="STACK">
<block type="util_python" id="wrT1c1;%@kF-Riy28O;." inline="true">
......@@ -1269,7 +1079,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="6053">
<block type="procedures_defreturn" id="Fys9OK!K-FNH-W0o}@h," x="0" y="4720">
<field name="NAME">isWhite</field>
<statement name="STACK">
<block type="util_python" id="h?(Tr@S1VYchJ5e6())[" inline="true">
......@@ -1283,7 +1093,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="6189">
<block type="procedures_defreturn" id="iE@eN47vK?la`*X4EQ-8" x="0" y="4853">
<field name="NAME">isRed</field>
<statement name="STACK">
<block type="util_python" id="fN{]~9g]|*Kx,bpmy_i$" inline="true">
......@@ -1297,7 +1107,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="6325">
<block type="procedures_defreturn" id="w|KTmb#01-L]2ZG4mz)b" x="0" y="4986">
<field name="NAME">isBlue</field>
<statement name="STACK">
<block type="util_python" id="U(Y(8WN=vCJzgw~oLdbs" inline="true">
......@@ -1311,7 +1121,7 @@
</block>
</value>
</block>
<block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="6461">
<block type="procedures_defreturn" id="$]uSxm9]*Qu3iZl~w~MW" x="0" y="5119">
<field name="NAME">readColorValue</field>
<statement name="STACK">
<block type="util_python" id="JSm|]EZ0cs6:5)g-C23(" inline="true">
......
......@@ -6,70 +6,28 @@ from lib.controller import *
from numbers import Number
v = None
_data = None
_code = None
_active = None
speed = None
thresh_white_red = None
thresh_red_blue = None
calibvalue_white = None
calibvalue_red = None
calibvalue_blue = None
state_code = None
state_active = None
calibvalue_white = None
thresh_white_red_defaults = None
thresh_red_blue_defaults = None
thresh_white_red = None
thresh_red_blue = None
calibvalue_red = None
_ts_state = None
calibvalue_blue = None
detectedColorValue = None
lastColorValue = None
counter = None
lastStateCounterSwitch = None
def set_thresh_white_red(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
thresh_white_red = v
def set_thresh_red_blue(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
thresh_red_blue = v
def get_thresh_list():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
return [thresh_white_red, thresh_red_blue]
def calculate_thresh():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
thresh_white_red = (calibvalue_white + calibvalue_red) / 2
thresh_red_blue = (calibvalue_red + calibvalue_blue) / 2
def get_calibvalue_list():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
return [calibvalue_white, calibvalue_red, calibvalue_blue]
def set_calibvalue_white(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
calibvalue_white = v
def set_calibvalue_red(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
calibvalue_red = v
def set_calibvalue_blue(v):
global _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
calibvalue_blue = v
def thread_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
calibvalue_white = 0
calibvalue_red = 0
......@@ -126,26 +84,26 @@ def thread_SLD():
def get_calib_data_SLD_defaults():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
return [thresh_white_red_defaults, thresh_red_blue_defaults]
def get_calib_data_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
return [thresh_white_red, thresh_red_blue]
def set_calib_data_SLD(_data):
global v, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, _data)
thresh_white_red = _data[0]
thresh_red_blue = _data[1]
def _set_state_SLD(_code, _active):
global v, _data, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
if state_code != _code or state_active != _active:
_ts_state = 0
......@@ -154,26 +112,26 @@ def _set_state_SLD(_code, _active):
def get_state_code_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return state_code
def get_state_active_SLD():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return state_active
def setConvBeltSpeedSLD(speed):
global v, _data, _code, _active, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, 'speed: %d', speed)
TXT_SLD_E5_M1_encodermotor.set_speed(int(speed), Motor.CW)
TXT_SLD_E5_M1_encodermotor.start()
def ejectWhite():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
TXT_SLD_E5_O5_magnetic_valve.on()
time.sleep(0.5)
......@@ -187,7 +145,7 @@ def ejectWhite():
def ejectRed():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
TXT_SLD_E5_O6_magnetic_valve.on()
time.sleep(0.5)
......@@ -201,7 +159,7 @@ def ejectRed():
def ejectBlue():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE, '-')
TXT_SLD_E5_O7_magnetic_valve.on()
time.sleep(0.5)
......@@ -215,37 +173,37 @@ def ejectBlue():
def isColorSensorTriggered():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I1_photo_transistor.is_dark()
def isEjectionTriggered():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I3_photo_transistor.is_dark()
def isWhite():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I6_photo_transistor.is_dark()
def isRed():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I7_photo_transistor.is_dark()
def isBlue():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I8_photo_transistor.is_dark()
def readColorValue():
global v, _data, _code, _active, speed, thresh_white_red, thresh_red_blue, calibvalue_white, calibvalue_red, calibvalue_blue, state_code, state_active, thresh_white_red_defaults, thresh_red_blue_defaults, _ts_state, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
global _data, _code, _active, speed, state_code, state_active, calibvalue_white, thresh_white_red_defaults, thresh_red_blue_defaults, thresh_white_red, thresh_red_blue, calibvalue_red, _ts_state, calibvalue_blue, detectedColorValue, lastColorValue, counter, lastStateCounterSwitch
logging.log(logging.TRACE0, '-')
return TXT_SLD_E5_I2_color_sensor.get_voltage()
......
......@@ -3,7 +3,6 @@ import threading
import time
from lib.controller import *
from lib.Sound import *
def beep():
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment