public MissionWaypointTaskMsg(float velocity_range, float idle_velocity, ActionOnFinish finish_action, uint mission_exec_times, YawMode yaw_mode, TraceMode trace_mode, ActionOnRCLost rc_lost_action, GimbalPitchMode gimbal_pitch_mode, MissionWaypointMsg[] mission_waypoints) { _velocity_range = velocity_range; _idle_velocity = idle_velocity; _action_on_finish = finish_action; _mission_exec_times = mission_exec_times; _yaw_mode = yaw_mode; _trace_mode = trace_mode; _action_on_rc_lost = rc_lost_action; _gimbal_pitch_mode = gimbal_pitch_mode; _mission_waypoints = mission_waypoints; }
public MissionWaypointTaskMsg(JSONNode msg) { _velocity_range = msg["velocity_range"].AsFloat; _idle_velocity = msg["idle_velocity"].AsFloat; _action_on_finish = (ActionOnFinish)msg["action_on_finish"].AsInt; _mission_exec_times = (uint)msg["mission_exec_times"].AsInt; _yaw_mode = (YawMode)msg["yaw_mode"].AsInt; _trace_mode = (TraceMode)msg["trace_mode"].AsInt; _action_on_rc_lost = (ActionOnRCLost)msg["action_on_rc_lost"].AsInt; _gimbal_pitch_mode = (GimbalPitchMode)msg["gimbal_pitch_mode"].AsInt; JSONArray waypoints = msg["mission_waypoint"].AsArray; _mission_waypoints = new MissionWaypointMsg[waypoints.Count]; for (int i = 0; i < _mission_waypoints.Length; i++) { _mission_waypoints[i] = new MissionWaypointMsg(waypoints[i]); } }
public override void Run() { _app.GetDb().Dirty.Add(_elementToMove.ParentGroup); PwGroup pgParent = _elementToMove.ParentGroup; if (pgParent != _targetGroup) { if (pgParent != null) // Remove from parent { PwEntry entry = _elementToMove as PwEntry; if (entry != null) { pgParent.Entries.Remove(entry); _targetGroup.AddEntry(entry, true, true); } else { PwGroup group = (PwGroup)_elementToMove; if ((_targetGroup == group) || (_targetGroup.IsContainedIn(group))) { Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere)); return; } pgParent.Groups.Remove(group); _targetGroup.AddGroup(group, true, true); } } } _onFinishToRun = new ActionOnFinish((success, message) => { if (!success) { // Let's not bother recovering from a failure. _app.LockDatabase(false); } }, OnFinishToRun); // Save SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, false); save.SetStatusLogger(StatusLogger); save.Run(); }
public override void Run() { //check if we will run into problems. Then finish with error before we start doing anything. foreach (var _elementToMove in _elementsToMove) { PwGroup pgParent = _elementToMove.ParentGroup; if (pgParent != _targetGroup) { if (pgParent != null) { PwGroup group = _elementToMove as PwGroup; if (group != null) { if ((_targetGroup == group) || (_targetGroup.IsContainedIn(group))) { Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere)); return; } } } } } foreach (var elementToMove in _elementsToMove) { _app.GetDb().Dirty.Add(elementToMove.ParentGroup); PwGroup pgParent = elementToMove.ParentGroup; if (pgParent != _targetGroup) { if (pgParent != null) // Remove from parent { PwEntry entry = elementToMove as PwEntry; if (entry != null) { pgParent.Entries.Remove(entry); _targetGroup.AddEntry(entry, true, true); } else { PwGroup group = (PwGroup)elementToMove; if ((_targetGroup == group) || (_targetGroup.IsContainedIn(group))) { Finish(false, _app.GetResourceString(UiStringKey.CannotMoveGroupHere)); return; } pgParent.Groups.Remove(group); _targetGroup.AddGroup(group, true, true); } } } } _onFinishToRun = new ActionOnFinish(ActiveActivity, (success, message, activity) => { if (!success) { // Let's not bother recovering from a failure. _app.LockDatabase(false); } }, OnFinishToRun); // Save SaveDb save = new SaveDb(_ctx, _app, OnFinishToRun, false); save.SetStatusLogger(StatusLogger); save.Run(); }