-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #35, fix #351, updated minor_servos This branch will not be merged until the component is updated as well * Updated timer for tests * Upgraded minor_servos with setup table * Fixed CSV file * Updated air blade logic * Fix #353, added minor_servos minimal REST Api
- Loading branch information
1 parent
1a8db89
commit d5ffaf3
Showing
6 changed files
with
215 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import os | ||
import csv | ||
import json | ||
from http.server import BaseHTTPRequestHandler | ||
import pkg_resources | ||
|
||
|
||
def setup_import(servos, configurations): | ||
filename = os.environ.get('ACS_CDB', '/') | ||
filename = os.path.join( | ||
filename, | ||
'CDB', | ||
'alma', | ||
'DataBlock', | ||
'MinorServo', | ||
'Tabella Setup.csv' | ||
) | ||
if not os.path.exists(filename): | ||
filename = pkg_resources.resource_filename( | ||
'simulators', | ||
'minor_servos/setup.csv' | ||
) | ||
with open(filename, 'r', encoding='utf-8') as csvfile: | ||
reader = csv.reader(csvfile, delimiter=';') | ||
indexes = {} | ||
for line in reader: | ||
if not indexes: | ||
for servo in servos: | ||
temp = [e for e in line if e.startswith(servo)] | ||
indexes[servo] = [line.index(e) for e in temp] | ||
continue | ||
for servo, servo_indexes in indexes.items(): | ||
coordinates = [] | ||
for index in servo_indexes: | ||
coord = line[index] | ||
try: | ||
if servo == 'GREGORIAN_CAP': | ||
coord = int(coord) | ||
else: | ||
coord = float(coord) | ||
except ValueError: | ||
coord = None | ||
coordinates.append(coord) | ||
configurations[line[0]][servo] = coordinates | ||
|
||
|
||
class VBrainRequestHandler(BaseHTTPRequestHandler): | ||
|
||
emergency = 'INAF_SRT_OR7_EMG_RESET_CMD' | ||
alarm = 'INAF_SRT_OR7_RESET_CMD' | ||
baseurl = '/Exporting/json/ExecuteCommand?name' | ||
urls = [ | ||
f'{baseurl}={emergency}', | ||
f'{baseurl}={alarm}' | ||
] | ||
answer = {'Message': 'OUTPUT:GOOD', 'Status': 'Good'} | ||
|
||
def do_GET(self): | ||
try: | ||
if self.path in self.urls: | ||
self.send_response(200) | ||
self.send_header('Content-type', 'application/json') | ||
self.end_headers() | ||
self.wfile.write(json.dumps(self.answer).encode()) | ||
else: | ||
self.send_response(404) | ||
self.end_headers() | ||
except BrokenPipeError: # skip coverage | ||
pass | ||
|
||
def log_message(self, *_): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CONFIGURATION;PFP_TX;PFP_TZ;PFP_RTHETA;SRP_TX;SRP_TY;SRP_TZ;SRP_RX;SRP_RY;SRP_RZ;M3R_RZ;GFR_RZ;DR_GFR1;DR_GFR2;DR_GFR3;DR_PFP;GREGORIAN_CAP; | ||
Primario;0;0;0;-5;5;-120;0;0;0;*;*;*;*;*;*;1; | ||
Gregoriano1;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;-88.70659;*;*;*;*;2; | ||
Gregoriano2;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;-159.8899;*;*;*;*;2; | ||
Gregoriano3;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;90.97161;*;*;*;*;2; | ||
Gregoriano4;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;162.771;*;*;*;*;2; | ||
Gregoriano5;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;55.373967;*;*;*;*;2; | ||
Gregoriano6;0;0;0;-1.5;11.1393650793988;1.08830677049999;0.049894179898239;-0.036111111111111;0;*;-51.82117;*;*;*;*;2; | ||
Gregoriano7;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; | ||
Gregoriano8;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; | ||
BWG1;0;0;0;-1.5;11.1393650793988;0.358165166130078;0.049894179898239;-0.036111111111111;0;10;0;*;*;*;*;2; | ||
BWG2;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; | ||
BWG3;0;0;0;-1.5;11.1393650793988;-3.77159716192807;0.049894179898239;-0.036111111111111;0;20;0;*;*;*;*;2; | ||
BWG4;0;0;0;*;*;*;*;*;*;*;*;*;*;*;*;*; |
Empty file.
Oops, something went wrong.