@@ -149,6 +149,32 def down_conv_bits(value): | |||
|
149 | 149 | |
|
150 | 150 | return bits |
|
151 | 151 | |
|
152 | def up_conv_value(bits): | |
|
153 | ||
|
154 | if bits == "000": value=1.0 | |
|
155 | if bits == "001": value=2.0 | |
|
156 | if bits == "010": value=3.0 | |
|
157 | if bits == "011": value=0.0 | |
|
158 | if bits == "100": value=0.5 | |
|
159 | if bits == "101": value=1.5 | |
|
160 | if bits == "110": value=2.5 | |
|
161 | if bits == "111": value=3.5 | |
|
162 | ||
|
163 | return value | |
|
164 | ||
|
165 | def down_conv_value(bits): | |
|
166 | ||
|
167 | if bits == "000": value=1.0 | |
|
168 | if bits == "001": value=2.0 | |
|
169 | if bits == "010": value=3.0 | |
|
170 | if bits == "011": value=0.0 | |
|
171 | if bits == "100": value=0.5 | |
|
172 | if bits == "101": value=1.5 | |
|
173 | if bits == "110": value=2.5 | |
|
174 | if bits == "111": value=3.5 | |
|
175 | ||
|
176 | return value | |
|
177 | ||
|
152 | 178 | def ip2position(module_number): |
|
153 | 179 | j=0 |
|
154 | 180 | i=0 |
@@ -451,7 +477,6 class ABSConfiguration(Configuration): | |||
|
451 | 477 | Read out-bits (up-down) of 1 abs module NOT for Configuration |
|
452 | 478 | """ |
|
453 | 479 | |
|
454 | parameters = {} | |
|
455 | 480 | ip_address = self.device.ip_address |
|
456 | 481 | ip_address = ip_address.split('.') |
|
457 | 482 | module_seq = (ip_address[0],ip_address[1],ip_address[2]) |
@@ -460,23 +485,47 class ABSConfiguration(Configuration): | |||
|
460 | 485 | module_port = self.device.port_address |
|
461 | 486 | read_route = 'http://'+module_ip+':'+str(module_port)+'/read' |
|
462 | 487 | |
|
488 | module_status = json.loads(self.module_status) | |
|
463 | 489 | print(read_route) |
|
464 | 490 | |
|
465 | answer = '' | |
|
466 | 491 | module_bits = '' |
|
467 | 492 | |
|
468 | 493 | try: |
|
469 |
r_ |
|
|
470 |
answer = r_ |
|
|
471 |
|
|
|
472 | module_bits = answer['allbits'] | |
|
494 | r_read = requests.get(read_route, timeout=0.5) | |
|
495 | answer = r_read.json() | |
|
496 | module_bits = answer['allbits'] | |
|
473 | 497 | except: |
|
474 | #message = "Could not read ABS parameters" | |
|
475 | answer = r_write.json() | |
|
476 | return 0 | |
|
498 | return {} | |
|
477 | 499 | |
|
478 | 500 | return module_bits |
|
479 | 501 | |
|
502 | def read_device(self): | |
|
503 | ||
|
504 | parms = {} | |
|
505 | # Reads active modules. | |
|
506 | module_status = json.loads(self.module_status) | |
|
507 | total = 0 | |
|
508 | for status in module_status: | |
|
509 | if module_status[status] != 0: | |
|
510 | module_bits = self.read_module(int(status)) | |
|
511 | bits={} | |
|
512 | if module_bits: | |
|
513 | bits = (str(module_bits['um2']) + str(module_bits['um1']) + str(module_bits['um0']) + | |
|
514 | str(module_bits['dm2']) + str(module_bits['dm1']) + str(module_bits['dm0']) ) | |
|
515 | parms[str(status)] = bits | |
|
516 | ||
|
517 | total +=1 | |
|
518 | ||
|
519 | if total==0: | |
|
520 | self.message = "No ABS Module detected. Please select 'Status'." | |
|
521 | return False | |
|
522 | ||
|
523 | ||
|
524 | ||
|
525 | self.message = "ABS Modules have been read" | |
|
526 | #monitoreo_tx = JROABSClnt_01CeCnMod000000MNTR10 | |
|
527 | return parms | |
|
528 | ||
|
480 | 529 | |
|
481 | 530 | def absmodule_status(self): |
|
482 | 531 | """ |
@@ -81,7 +81,8 class CGSConfiguration(Configuration): | |||
|
81 | 81 | except: |
|
82 | 82 | self.device.status = 0 |
|
83 | 83 | self.device.save() |
|
84 | return self.device.status | |
|
84 | self.message = 'Could not read CGS status' | |
|
85 | return False | |
|
85 | 86 | |
|
86 | 87 | response = str(r.text) |
|
87 | 88 | response = response.split(";") |
@@ -104,7 +105,7 class CGSConfiguration(Configuration): | |||
|
104 | 105 | self.device.save() |
|
105 | 106 | |
|
106 | 107 | |
|
107 |
return |
|
|
108 | return True | |
|
108 | 109 | |
|
109 | 110 | |
|
110 | 111 | def read_device(self): |
@@ -157,7 +158,7 class CGSConfiguration(Configuration): | |||
|
157 | 158 | r = requests.post(route, post_data, timeout=0.5) |
|
158 | 159 | except: |
|
159 | 160 | self.message = "Could not write CGS parameters" |
|
160 |
return |
|
|
161 | return False | |
|
161 | 162 | |
|
162 | 163 | text = r.text |
|
163 | 164 | text = text.split(',') |
@@ -167,12 +168,16 class CGSConfiguration(Configuration): | |||
|
167 | 168 | status = text[1] |
|
168 | 169 | if title == "okay": |
|
169 | 170 | self.message = status |
|
170 |
|
|
|
171 | self.device.status = 3 | |
|
172 | self.device.save() | |
|
173 | return True | |
|
171 | 174 | else: |
|
172 | 175 | self.message = title + ", " + status |
|
173 |
|
|
|
176 | self.device.status = 1 | |
|
177 | self.device.save() | |
|
178 | return False | |
|
174 | 179 | |
|
175 |
return |
|
|
180 | return False | |
|
176 | 181 | |
|
177 | 182 | |
|
178 | 183 | class Meta: |
@@ -29,7 +29,9 | |||
|
29 | 29 | <li><a href="{{ dev_conf.get_absolute_url_stop }}"><span class="glyphicon glyphicon-stop" aria-hidden="true"></span> Stop</a></li> |
|
30 | 30 | {% endif %} |
|
31 | 31 | <li><a href="{{ dev_conf.get_absolute_url_write }}"><span class="glyphicon glyphicon-download" aria-hidden="true"></span> Write</a></li> |
|
32 | {% if dev_conf.device.device_type.name != 'abs' %} | |
|
32 | 33 | <li><a href="{{ dev_conf.get_absolute_url_read }}"><span class="glyphicon glyphicon-upload" aria-hidden="true"></span> Read</a></li> |
|
34 | {% endif %} | |
|
33 | 35 | </ul> |
|
34 | 36 | </span> |
|
35 | 37 | {% endblock %} |
General Comments 0
You need to be logged in to leave comments.
Login now