Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def add_mavlink_packet(self, msg):
'''add data to the graph'''
mtype = msg.get_type()
if mtype not in self.msg_types:
return
for i in range(len(self.fields)):
if mtype not in self.field_types[i]:
continue
f = self.fields[i]
self.values[i] = mavutil.evaluate_expression(f, self.state.master.messages)
if self.livegraph is not None:
self.livegraph.add_values(self.values)
def cmd_click(args):
'''synthesise click at lat/lon; no arguments is "unclick"'''
if len(args) == 0:
mpstate.click(None)
return
if len(args) < 2:
print("click LAT_EXPRESSION LNG_EXPRESSION")
return
lat = mavutil.evaluate_expression(args[0], mpstate.master().messages)
lng = mavutil.evaluate_expression(args[1], mpstate.master().messages)
mpstate.click((lat, lng))
if mtype not in field_types[i]:
continue
f = fields[i]
if f.endswith(":2"):
axes[i] = 2
f = f[:-2]
if f.endswith(":1"):
first_only[i] = True
f = f[:-2]
v = mavutil.evaluate_expression(f, vars)
if v is None:
continue
if args.xaxis is None:
xv = t
else:
xv = mavutil.evaluate_expression(args.xaxis, vars)
if xv is None:
continue
y[i].append(v)
x[i].append(xv)
mtype = msg.get_type()
for i in range(0, len(self.fields)):
if mtype not in self.field_types[i]:
continue
f = self.fields[i]
simple = self.simple_field[i]
if simple is not None:
v = getattr(vars[simple[0]], simple[1])
else:
v = mavutil.evaluate_expression(f, vars)
if v is None:
continue
if self.xaxis is None:
xv = t
else:
xv = mavutil.evaluate_expression(self.xaxis, vars)
if xv is None:
continue
try:
v_f = float(v)
xv_f = float(xv)
except Exception:
continue
self.y[i].append(v_f)
self.x[i].append(xv_f)
mtype = msg.get_type()
if args.flightmode is not None and (len(modes) == 0 or modes[-1][1] != flightmode):
modes.append((t, flightmode))
if mtype not in msg_types:
return
for i in range(0, len(fields)):
if mtype not in field_types[i]:
continue
f = fields[i]
if f.endswith(":2"):
axes[i] = 2
f = f[:-2]
if f.endswith(":1"):
first_only[i] = True
f = f[:-2]
v = mavutil.evaluate_expression(f, vars)
if v is None:
continue
if args.xaxis is None:
xv = t
else:
xv = mavutil.evaluate_expression(args.xaxis, vars)
if xv is None:
continue
y[i].append(v)
x[i].append(xv)
def add_data(t, msg, msg_types, vars, fields, field_types, position_field_type):
'''add some data'''
mtype = msg.get_type()
if mtype not in msg_types:
return
for i in range(0, len(fields)):
if mtype not in field_types[i]:
continue
f = fields[i]
v = mavutil.evaluate_expression(f, vars)
if v is None:
continue
# Check if we have position or state information
if f == mainstate_field:
# Handle main state information
# add_data.mainstate_current >= 0 : avoid starting a new linestring
# when mainstate comes after the first position data in the log
if (v != add_data.mainstate_current and
add_data.mainstate_current >= 0):
add_data.new_linestring = True
add_data.mainstate_current = v
else:
# Handle position information
# make sure lon, lat, alt is saved in the correct order in
# position_data (the same as in position_field_types)
def add_data(self, t, msg, vars):
'''add some data'''
mtype = msg.get_type()
for i in range(0, len(self.fields)):
if mtype not in self.field_types[i]:
continue
f = self.fields[i]
simple = self.simple_field[i]
if simple is not None:
v = getattr(vars[simple[0]], simple[1])
else:
v = mavutil.evaluate_expression(f, vars)
if v is None:
continue
if self.xaxis is None:
xv = t
else:
xv = mavutil.evaluate_expression(self.xaxis, vars)
if xv is None:
continue
try:
v_f = float(v)
xv_f = float(xv)
except Exception:
continue
self.y[i].append(v_f)
self.x[i].append(xv_f)