Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FactoryCalib
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fischertechnik examples
Training models
FactoryCalib
Commits
af64207a
Commit
af64207a
authored
2 years ago
by
ft-Demo
Browse files
Options
Downloads
Patches
Plain Diff
commit by robo pro coding
parent
ef2a19c4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
lib/SLD.blockly
+605
-417
605 additions, 417 deletions
lib/SLD.blockly
lib/SLD.py
+56
-19
56 additions, 19 deletions
lib/SLD.py
with
661 additions
and
436 deletions
lib/SLD.blockly
+
605
−
417
View file @
af64207a
This diff is collapsed.
Click to expand it.
lib/SLD.py
+
56
−
19
View file @
af64207a
...
...
@@ -13,6 +13,9 @@ _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
thresh_white_red_defaults
=
None
...
...
@@ -25,18 +28,52 @@ lastStateCounterSwitch = None
def
set_thresh_white_red
(
v
):
global
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE
,
'
-
'
)
calibvalue_white
=
0
calibvalue_red
=
0
calibvalue_blue
=
0
thresh_white_red_defaults
=
1150
thresh_white_red
=
thresh_white_red_defaults
thresh_red_blue_defaults
=
1600
...
...
@@ -89,26 +126,26 @@ def thread_SLD():
def
get_calib_data_SLD_defaults
():
global
v
,
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE0
,
'
-
'
)
if
state_code
!=
_code
or
state_active
!=
_active
:
_ts_state
=
0
...
...
@@ -117,26 +154,26 @@ def _set_state_SLD(_code, _active):
def
get_state_code_SLD
():
global
v
,
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE0
,
'
-
'
)
return
state_code
def
get_state_active_SLD
():
global
v
,
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE0
,
'
-
'
)
return
state_active
def
setConvBeltSpeedSLD
(
speed
):
global
v
,
_data
,
_code
,
_active
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE
,
'
-
'
)
TXT_SLD_E5_O5_magnetic_valve
.
on
()
time
.
sleep
(
0.5
)
...
...
@@ -150,7 +187,7 @@ def ejectWhite():
def
ejectRed
():
global
v
,
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE
,
'
-
'
)
TXT_SLD_E5_O6_magnetic_valve
.
on
()
time
.
sleep
(
0.5
)
...
...
@@ -164,7 +201,7 @@ def ejectRed():
def
ejectBlue
():
global
v
,
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE
,
'
-
'
)
TXT_SLD_E5_O7_magnetic_valve
.
on
()
time
.
sleep
(
0.5
)
...
...
@@ -178,37 +215,37 @@ def ejectBlue():
def
isColorSensorTriggered
():
global
v
,
_data
,
_code
,
_active
,
speed
,
thresh_white_red
,
thresh_red_blue
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
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
,
state_code
,
state_active
,
thresh_white_red_defaults
,
thresh_red_blue_defaults
,
_ts_state
,
detectedColorValue
,
lastColorValue
,
counter
,
lastStateCounterSwitch
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
logging
.
log
(
logging
.
TRACE0
,
'
-
'
)
return
TXT_SLD_E5_I2_color_sensor
.
get_voltage
()
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment