Skip to content

Commit

Permalink
activated calculate true wind fix sailoog#95
Browse files Browse the repository at this point in the history
performance could be better
  • Loading branch information
e-sailing committed Nov 29, 2017
1 parent 57ce613 commit 32abfc1
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 18 deletions.
25 changes: 13 additions & 12 deletions SK-base_d.py
Original file line number Diff line number Diff line change
Expand Up @@ -622,14 +622,16 @@ def read_Calc(self):
self.last_heading = ''
self.heading_time = ''

#self.environment_wind_angleApparent = self.setlist(['environment.wind.angleApparent', [0, 0, 0, 0]])
#self.environment_wind_speedApparent = self.setlist(['environment.wind.speedApparent', [0, 0, 0, 0]])
#if self.calcWindTrueWater:
# self.navigation_speedThroughWater = self.setlist(['navigation.speedThroughWater', [0, 0, 0, 0]])
#if self.calcWindTrueGround:
# self.navigation_courseOverGroundTrue = self.setlist(['navigation.courseOverGroundTrue', [0, 0, 0, 0]])
# self.navigation_speedOverGround = self.setlist(['navigation.speedOverGround', [0, 0, 0, 0]])
# self.navigation_headingMagnetic = self.setlist(['navigation.headingMagnetic', [0, 0, 0, 0]])
if self.calcWindTrueWater:
self.navigation_speedThroughWater = self.setlist(['navigation.speedThroughWater', [0, 0, 0, 0]])
self.environment_wind_angleApparent = self.setlist(['environment.wind.angleApparent', [0, 0, 0, 0]])
self.environment_wind_speedApparent = self.setlist(['environment.wind.speedApparent', [0, 0, 0, 0]])
if self.calcWindTrueGround:
self.environment_wind_angleApparent = self.setlist(['environment.wind.angleApparent', [0, 0, 0, 0]])
self.environment_wind_speedApparent = self.setlist(['environment.wind.speedApparent', [0, 0, 0, 0]])
self.navigation_courseOverGroundTrue = self.setlist(['navigation.courseOverGroundTrue', [0, 0, 0, 0]])
self.navigation_speedOverGround = self.setlist(['navigation.speedOverGround', [0, 0, 0, 0]])
self.navigation_headingMagnetic = self.setlist(['navigation.headingMagnetic', [0, 0, 0, 0]])

def Action_set(self, item, cond):
if cond:
Expand Down Expand Up @@ -845,7 +847,7 @@ def Action_Calc_cycle(self, tick2a):
SignalK='{"updates":[{"$source":"OPcalculations","values":['
SignalK+=Erg[0:-1]+']}]}\n'
self.sock.sendto(SignalK, ('127.0.0.1', 55557))
'''

if self.calcWindTrueWater | self.calcWindTrueGround:
Erg = ''
if self.calcWindTrueWater:
Expand All @@ -868,7 +870,7 @@ def Action_Calc_cycle(self, tick2a):
beta2 = -90
Erg += '{"path": "environment.wind.angleTrueWater","value":'+str(0.017453293*beta2)+'},'
Erg += '{"path": "environment.wind.speedTrue","value":'+str(speed)+'},'
if self.calcWindTrueGround:
beta1 = self.environment_wind_angleApparent[1][2] + self.navigation_headingMagnetic[1][2]
x1 = self.environment_wind_speedApparent[1][2] * math.sin(beta1)
Expand All @@ -894,11 +896,10 @@ def Action_Calc_cycle(self, tick2a):

Erg += '{"path": "environment.wind.angleTrueGround","value":'+str(0.017453293*beta3)+'},'
Erg += '{"path": "environment.wind.speedOverGround","value":'+str(speed)+'},'
SignalK='{"updates":[{"$source":"OPcalculations","values":['
SignalK+=Erg[0:-1]+']}]}\n'
self.sock.sendto(SignalK, ('127.0.0.1', 55557))
'''

def signal_handler(signal_, frame):
print 'You pressed Ctrl+C!'
Expand Down
25 changes: 19 additions & 6 deletions tools/calculate.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ def __init__(self):
tw_box = wx.StaticBox(panel, -1, _(' True wind speed and direction '))
self.true_wind = wx.CheckBox(panel, -1, label=_('Use Speed Through Water'))
self.true_wind.Bind(wx.EVT_CHECKBOX, self.on_select_tw)
tw_requires = wx.StaticText(panel, label=_('Requires: STW, AWS, AWA.'))
tw_requires = wx.StaticText(panel, label=_('Requires: SignalK STW, AWS, AWA.'))
self.true_wind2 = wx.CheckBox(panel, -1, label=_('Use Speed Over Ground'))
self.true_wind2.Bind(wx.EVT_CHECKBOX, self.on_select_tw)
tw_requires2 = wx.StaticText(panel, label=_('Requires: SOG, COG, HDT, AWS, AWA.'))
self.true_wind2.Bind(wx.EVT_CHECKBOX, self.on_select_tg)
tw_requires2 = wx.StaticText(panel, label=_('Requires: SignalK SOG, COG, HDT, AWS, AWA.'))
tw_accu_label = wx.StaticText(panel, label=_('Accuracy (sec)'))
self.tw_accu= wx.ComboBox(panel, choices=rate_list, style=wx.CB_READONLY)
tw_rate_label = wx.StaticText(panel, label=_('Rate (sec)'))
Expand All @@ -91,8 +91,8 @@ def __init__(self):
button_ok =wx.Button(panel, label=_('OK'))
self.Bind(wx.EVT_BUTTON, self.on_ok, button_ok)

self.true_wind.Disable()
self.true_wind2.Disable()
#self.true_wind.Disable()
#self.true_wind2.Disable()

mg_boxSizer = wx.StaticBoxSizer(mg_box, wx.VERTICAL)
mg_boxSizer.Add(self.mag_var, 0, wx.ALL | wx.EXPAND, 5)
Expand Down Expand Up @@ -249,9 +249,22 @@ def on_select_tw(self,e):
sender = e.GetEventObject()
if sender.GetValue():
self.true_wind2.SetValue(False)
self.true_wind.SetValue(False)
self.true_wind.SetValue(True)
sender.SetValue(True)
else:
self.true_wind.SetValue(False)
sender.SetValue(False)

def on_select_tg(self,e):
sender = e.GetEventObject()
if sender.GetValue():
self.true_wind.SetValue(False)
self.true_wind2.SetValue(True)
sender.SetValue(True)
else:
self.true_wind2.SetValue(False)
sender.SetValue(False)

def on_select_th(self,e):
sender = e.GetEventObject()
if sender.GetValue():
Expand Down

0 comments on commit 32abfc1

Please sign in to comment.