I am working on a code and I need some help. First, I have 5 devices connected by wires, each device has a XY location and status like the following:
device_name=['device1', 'device2', 'device3', 'device4', 'device5',]
device_status=[0,0,0,0,0]
loc=[(5,2),(10,2),(10,6),(5,7),(8,10)]
and the wires data:(name,from,to,status)
wire1 =("wire 1 _ 2", device_name[0],device_name[1],0 )
wire2 =("wire 1 _ 5", device_name[0], device_name[4],0)
wire3 =("wire 2 _ 3", device_name[1], device_name[2],0)
wire4 =("wire 3 _ 5", device_name[2], device_name[4],0)
wire5 =("wire 5 _ 4", device_name[4], device_name[3],0)
wire6 =("wire 5 _ 2", device_name[2], device_name[1],0)
I defined the wires in that way(beginner), I'm sure it's not the best, so feel free to edit.
I worked on a code that can update the device_status like next:
device_status=[0,1,1,1,0]
my question is how can I update the wiring status if any of "from" or "to" device status changed, following the updated device status in my example above. I expect to have something like that:
"wire 1 _ 2" 1
"wire 1 _ 5" 0
"wire 2 _ 3" 1
"wire 3 _ 5" 1
"wire 5 _ 4" 1
"wire 5 _ 2" 0
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire