Commit e9064502 authored by Tammo Jan Dijkema's avatar Tammo Jan Dijkema
Browse files

Add satellite and sun

parent eab6dc01
......@@ -2,6 +2,8 @@
HostName: consoledemo.dmz.camras.nl
Port_Read_Status : 11020
Port_Read_J2000 : 11030
Port_Read_Sat : 11060
Port_Read_Sun : 11070
Port_Read_Moon : 11080
Port_Read_Model : 11090
Port_Write_J2000 : 11031
......
......@@ -131,6 +131,18 @@ class Telescope:
thread_read_moon.daemon = True
thread_read_moon.start()
self._event_sun = threading.Event()
thread_read_sun = threading.Thread(target=self._readsun, args=(
consoleHost, config.getint('Console', 'Port_Read_Sun')))
thread_read_sun.daemon = True
thread_read_sun.start()
self._event_sat = threading.Event()
thread_read_sat = threading.Thread(target=self._readsat, args=(
consoleHost, config.getint('Console', 'Port_Read_Sat')))
thread_read_sat.daemon = True
thread_read_sat.start()
def _readj2000(self, consoleHost, j2000_read_port):
"""
Poll the socket with the J2000 info, store its values in class members
......@@ -229,6 +241,67 @@ class Telescope:
self.offset_el = (float(vals[2]) * u.rad).to(u.deg)
self._event_status.set()
def _readsun(self, host, port):
"""
Poll the socket with the sun, store the values in class members
:param host: Hostname
:param port: Port at which the model is running
:return: None
"""
try:
sunsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sunsocket.connect((host, port))
except socket.error:
raise IOError("Cannot connect to sun server " + host + " at port " + str(port))
while True:
readable, writable, exceptional = select.select(
[sunsocket], [], [])
if len(exceptional) > 0:
raise IOError("Error with sun read socket")
msg = readable[0].recv(4096).decode("UTF-8")
# Read the flags, they look like "enabled=0,refraction=1,dt_model=0"
switches = [kv.split("=") for kv in msg.strip().split(",")]
if self.tracker == "console/suntracker":
self.tracking_enabled = bool(int(switches[0][1]))
self.model_enabled = bool(int(switches[1][1]))
self._event_sun.set()
def _readsat(self, host, port):
"""
Poll the socket with the sat, store the values in class members
:param host: Hostname
:param port: Port at which the model is running
:return: None
"""
try:
satsocket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
satsocket.connect((host, port))
except socket.error:
raise IOError("Cannot connect to sat server " + host + " at port " + str(port))
while True:
readable, writable, exceptional = select.select(
[satsocket], [], [])
if len(exceptional) > 0:
raise IOError("Error with sat read socket")
msg = readable[0].recv(4096).decode("UTF-8")
vals = msg.strip().split(",")
# Read the flags, they look like "enabled=0,refraction=1,dt_model=0"
switches = [kv.split("=") for kv in vals]
if self.tracker == "console/sattracker":
self.tracking_enabled = bool(int(switches[0][1]))
self.refraction_enabled = bool(int(switches[1][1]))
self.model_enabled = bool(int(switches[2][1]))
self.satname = switches[3][1]
self.tle = switches[4][1]
self._event_sat.set()
def _readmoon(self, host, port):
"""
Poll the socket with the moon, store the values in class members
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment