Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
D
Device tango control led ring
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
PX2 Beamline
Device tango control led ring
Commits
863fc52b
Commit
863fc52b
authored
Sep 7, 2022
by
Damien JEANGERARD
Browse files
Options
Downloads
Patches
Plain Diff
Update led_controler.py
Migration python3
parent
722479d5
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
led_controler.py
+45
-24
45 additions, 24 deletions
led_controler.py
with
45 additions
and
24 deletions
led_controler.py
+
45
−
24
View file @
863fc52b
...
...
@@ -39,22 +39,35 @@
## (c) - Software Engineering Group - ESRF
##############################################################################
"""
Commander un ou des anneaux LED via un Arduino connecte a un reseau local. Par protocole de communication UDP
"""
"""
Gestion du beamstop en fonction de la position du detecteur
"""
from
__future__
import
print_function
from
builtins
import
str
__all__
=
[
"
led_controler
"
,
"
led_controlerClass
"
,
"
main
"
]
__docformat__
=
'
restructuredtext
'
# Add additional import
#----- PROTECTED REGION ID(led_controler.additionnal_import) ENABLED START -----#
import
PyTango
import
sys
from
socket
import
socket
,
AF_INET
,
SOCK_DGRAM
import
time
#sys.path.insert(0, '/nfs/ruche-proxima2a/proxima2a-soleil/gitRepos')
##sys.path.insert(0, '/nfs/ruche/proxima2a-soleil/gitRepos/')
#from beam_center import beam_center
#bc = beam_center()
# Add additional import
#----- PROTECTED REGION ID(led_controler.additionnal_import) ENABLED START -----#
#----- PROTECTED REGION END -----# // led_controler.additionnal_import
## Device States Description
## STANDBY :
## ON :
## OFF :
## ALARM :
class
led_controler
(
PyTango
.
Device_4Impl
):
#--------- Add you global variables here --------------------------
...
...
@@ -76,7 +89,7 @@ class led_controler (PyTango.Device_4Impl):
def
delete_device
(
self
):
self
.
debug_stream
(
"
In delete_device()
"
)
print
'
delete
'
print
(
'
delete
'
)
#----- PROTECTED REGION ID(led_controler.delete_device) ENABLED START -----#
#----- PROTECTED REGION END -----# // led_controler.delete_device
...
...
@@ -87,11 +100,10 @@ class led_controler (PyTango.Device_4Impl):
#----- PROTECTED REGION ID(led_controler.init_device) ENABLED START -----#
# Etat de l'anneau a l'init du device
self
.
attr_brightness_read
=
10
# Intensite
self
.
attr_sector_read
=
'
0
'
# Secteur de l'anneau utilise
self
.
attr_color_read
=
'
w
'
# Couleur
self
.
led_power
=
'
ON
'
# Etat du device
self
.
attr_brightness_read
=
10
self
.
attr_sector_read
=
'
0
'
self
.
attr_color_read
=
'
w
'
self
.
led_power
=
'
ON
'
# Parametre envoi UDP
self
.
sock_send
=
socket
(
AF_INET
,
SOCK_DGRAM
)
...
...
@@ -103,11 +115,12 @@ class led_controler (PyTango.Device_4Impl):
self
.
sock_rec
.
bind
(
adr_back
)
self
.
sock_rec
.
settimeout
(
1
)
print
'
adr_send :
'
,
self
.
adr_send
print
'
adr_back :
'
,
adr_back
print
'
nbr_de_leds :
'
,
self
.
nbr_de_leds
print
(
'
adr_send :
'
,
self
.
adr_send
)
print
(
'
adr_back :
'
,
adr_back
)
print
(
'
nbr_de_leds :
'
,
self
.
nbr_de_leds
)
self
.
send_command_udp
()
print
(
'
ok
'
)
#----- PROTECTED REGION END -----# // led_controler.init_device
...
...
@@ -259,7 +272,8 @@ class led_controler (PyTango.Device_4Impl):
#----- PROTECTED REGION END -----# // led_controler.INIT
self
.
init_device
()
# ???
argout
=
'
init
'
argout
=
'
ttttt
'
return
argout
def
is_INIT_allowed
(
self
):
...
...
@@ -268,6 +282,7 @@ class led_controler (PyTango.Device_4Impl):
def
OFF
(
self
):
self
.
debug_stream
(
"
OFF()
"
)
#----- PROTECTED REGION ID(led_controler.OFF) ENABLED START -----#
self
.
led_power
=
'
OFF
'
argout
=
self
.
send_command_udp
(
c
=
'
0
'
)
...
...
@@ -279,6 +294,7 @@ class led_controler (PyTango.Device_4Impl):
def
ON
(
self
):
self
.
debug_stream
(
"
ON()
"
)
#----- PROTECTED REGION ID(led_controler.ON) ENABLED START -----#
self
.
led_power
=
'
ON
'
argout
=
self
.
send_command_udp
()
...
...
@@ -333,16 +349,18 @@ class led_controler (PyTango.Device_4Impl):
def
send_command_udp
(
self
,
a
=
None
,
b
=
None
,
c
=
None
,
d
=
None
):
message
=
self
.
generate_message
(
a
,
b
,
c
,
d
)
self
.
sock_send
.
sendto
(
message
,
self
.
adr_send
)
# envoi du message
self
.
sock_send
.
sendto
(
bytes
(
message
,
"
utf-8
"
),
self
.
adr_send
)
# envoi du message
time
.
sleep
(
0.5
)
print
(
'
\n
Message sendto : %s
'
%
message
)
try
:
# attente retour du controleur
print
(
'
Ready for message
'
)
msg
,
addr
=
self
.
sock_rec
.
recvfrom
(
4096
)
print
(
msg
,
addr
)
argout
=
msg
if
msg
==
message
:
print
((
msg
,
addr
))
argout
=
msg
.
decode
(
'
utf-8
'
)
#if msg.decode('utf-8') == message:
if
argout
==
message
:
self
.
last_command
=
True
else
:
self
.
last_command
=
False
...
...
@@ -353,6 +371,9 @@ class led_controler (PyTango.Device_4Impl):
return
argout
#def posiBST3(self,outarg):
#self.dev_BST3Tx.position, self.dev_BST3Tz.position = outarg[0],outarg[1] #positionner le BST3 sur le faisceau axe Tx et Tz
class
led_controlerClass
(
PyTango
.
DeviceClass
):
#--------- Add you global class variables here --------------------------
#----- PROTECTED REGION ID(led_controler.global_class_variables) ENABLED START -----#
...
...
@@ -431,10 +452,10 @@ def main():
U
.
server_init
()
U
.
server_run
()
except
PyTango
.
DevFailed
,
e
:
print
'
-------> Received a DevFailed exception:
'
,
e
except
Exception
,
e
:
print
'
-------> An unforeseen exception occured....
'
,
e
except
PyTango
.
DevFailed
as
e
:
print
(
'
-------> Received a DevFailed exception:
'
,
e
)
except
Exception
as
e
:
print
(
'
-------> An unforeseen exception occured....
'
,
e
)
if
__name__
==
'
__main__
'
:
main
()
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