def command(): global last_sequence_num sequence, command = read_link_command() if sequence < 0: return False # ignore repeated commands (including roll over logic) if sequence != last_sequence_num: # execute command events.log('remote command', "executed: (%d) %s" % (sequence, command)) execute_command(command) # register that we've received this message correctly remote_link_node.setInt('sequence_num', sequence) last_sequence_num = sequence timestamp = status_node.getFloat('frame_time') remote_link_node.setFloat('last_message_sec', timestamp) return True
if t_initial[3:6] != t_repeated[3:6]: raise tests.TestError("repeated timer time of day does not match") #sys.modules["Tools.Notifications"] = FakeNotifications #sys.modules["Tools.NumericalTextInput.NumericalTextInput"] = FakeNotifications # required stuff for timer (we try to keep this minimal) enigma.init_nav() enigma.init_record_config() enigma.init_parental_control() from events import log import calendar import os # we are operating in CET/CEST os.environ['TZ'] = 'CET' time.tzset() #log(test_timer, test_name = "test_timer_repeating", base_time = calendar.timegm((2007, 3, 1, 12, 0, 0)), repeat=0x7f, sim_length = 86400 * 7) log(test_timer, test_name="test_timer_repeating_dst_skip", base_time=calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start=3600, repeat=0x7f, sim_length=86400 * 7) #log(test_timer, test_name = "test_timer_repeating_dst_start", base_time = calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start = 10000, repeat=0x7f, sim_length = 86400 * 7)
def execute_command(command): global route_request if command == '': # no valid tokens return tokens = command.split(',') if tokens[0] == 'hb' and len(tokens) == 1: # heart beat, no action needed pass elif tokens[0] == 'home' and len(tokens) == 5: # specify new home location lon = float(tokens[1]) lat = float(tokens[2]) # alt_ft = float( tokens[3] ) azimuth_deg = float(tokens[4]) home_node.setFloat('longitude_deg', lon) home_node.setFloat('latitude_deg', lat) home_node.setFloat('azimuth_deg', azimuth_deg) home_node.setBool('valid', True) elif tokens[0] == 'route' and len(tokens) >= 5: route_request = tokens[1:] elif tokens[0] == 'route_cont' and len(tokens) >= 5: route_request += tokens[1:] elif tokens[0] == 'route_end' and len(tokens) == 1: route_node.setString('route_request', ','.join(route_request)) task_node.setString('command_request', 'task,route') elif tokens[0] == 'task': task_node.setString('command_request', command) elif tokens[0] == 'ap' and len(tokens) == 3: # specify an autopilot target if tokens[1] == 'agl-ft': agl_ft = float(tokens[2]) targets_node.setFloat('altitude_agl_ft', agl_ft) elif tokens[1] == 'msl-ft': msl_ft = float(tokens[2]) targets_node.setFloat('target_msl_ft', msl_ft) elif tokens[1] == 'speed-kt': speed_kt = float(tokens[2]) targets_node.setFloat('airspeed_kt', speed_kt) elif tokens[0] == 'fcs-update': decode_fcs_update(command) elif tokens[0] == 'get' and len(tokens) == 2: # absolute path parts = tokens[1].split('/') node_path = '/'.join(parts[0:-1]) if node_path == '': node_path = '/' node = getNode(node_path, True) name = parts[-1] value = node.getString(name) if value == '': value = 'undefined' # print tokens[0], '=', value events.log('get', '%s,%s' % (tokens[1], value), send_to_remote=True) elif tokens[0] == 'set' and len(tokens) >= 3: if tokens[1][0] == '/': # absolute path parts = tokens[1].split('/') node_path = '/'.join(parts[0:-1]) if node_path == '': node_path = '/' node = getNode(node_path, True) name = parts[-1] value = ' '.join(tokens[2:]) node.setString(name, value) else: # expecting a full path name to set pass elif tokens[0] == 'la' and len(tokens) == 5: if tokens[1] == 'ned': # set ned-vector lookat mode point_node = getNode('/pointing', True) point_node.setString('lookat_mode', 'ned_vector') # specify new lookat ned coordinates vector_node = getNode('/pointing/vector', True) north = float(tokens[2]) east = float(tokens[3]) down = float(tokens[4]) vector_node.setFloat('north', north) vector_node.setFloat('east', east) vector_node.setFloat('down', down) elif tokens[1] == 'wgs84': # set wgs84 lookat mode point_node = getNode('/pointing', True) point_node.setString('lookat_mode', 'wgs84') # specify new lookat ned coordinates wgs84_node = getNode('/pointing/wgs84', True) pos_node = getNode('/position', True) lon = float(tokens[2]) lat = float(tokens[3]) wgs84_node.setFloat('longitude_deg', lon) wgs84_node.setFloat('latitude_deg', lat) ground = pos_node.getFloat('altitude_ground_m') wgs84_node.setFloat('altitude_m', ground)
t_repeated = time.localtime(timers[0].begin) print(t_initial) print(t_repeated) if t_initial[3:6] != t_repeated[3:6]: raise tests.TestError("repeated timer time of day does not match") # required stuff for timer (we try to keep this minimal) enigma.init_nav() enigma.init_record_config() enigma.init_parental_control() from events import log import calendar import os # we are operating in CET/CEST os.environ['TZ'] = 'CET' time.tzset() #log(test_timer, test_name = "test_timer_repeating", base_time = calendar.timegm((2007, 3, 1, 12, 0, 0)), repeat=0x7f, sim_length = 86400 * 7) log(test_timer, test_name="test_timer_repeating_dst_skip", base_time=calendar.timegm((2007, 3, 20, 0, 0, 0)), timer_start=3600, repeat=0x7f, sim_length=86400 * 7) #log(test_timer, test_name = "test_timer_repeating_dst_start", base_time = calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start = 10000, repeat=0x7f, sim_length = 86400 * 7)
t_repeated = time.localtime(timers[0].begin) print t_initial print t_repeated if t_initial[3:6] != t_repeated[3:6]: raise tests.TestError("repeated timer time of day does not match") import FakeNotifications #sys.modules["Tools.Notifications"] = FakeNotifications #sys.modules["Tools.NumericalTextInput.NumericalTextInput"] = FakeNotifications # required stuff for timer (we try to keep this minimal) enigma.init_nav() enigma.init_record_config() enigma.init_parental_control() from events import log import calendar import os # we are operating in CET/CEST os.environ['TZ'] = 'CET' time.tzset() #log(test_timer, test_name = "test_timer_repeating", base_time = calendar.timegm((2007, 3, 1, 12, 0, 0)), repeat=0x7f, sim_length = 86400 * 7) log(test_timer, test_name = "test_timer_repeating_dst_skip", base_time = calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start = 3600, repeat=0x7f, sim_length = 86400 * 7) #log(test_timer, test_name = "test_timer_repeating_dst_start", base_time = calendar.timegm((2007, 03, 20, 0, 0, 0)), timer_start = 10000, repeat=0x7f, sim_length = 86400 * 7)
def log(self, message): send_event_to_port( events.log(self.name, message), self._logger_port )
def _log_error(self, message): send_event_to_port( events.log('Service Error', message), self._logger_port)