private static void ParseTask(JSONNode taskJson, ref TaskStrategy task, List <TaskStrategy> strategies) { task.Name = taskJson["Name"]; task.NodeName = taskJson["NodeName"]; if (taskJson["BeginDate"] == null) { task.BeginDate = DateTime.Today; } else { string dateString = taskJson["BeginDate"]; var culture = CultureInfo.CreateSpecificCulture("pt-PT"); var styles = DateTimeStyles.AdjustToUniversal | DateTimeStyles.AssumeLocal; DateTime date; if (DateTime.TryParse(dateString, culture, styles, out date)) { task.BeginDate = date; } } if (taskJson["DependsOn"] != null) { for (int i = 0; i < taskJson["DependsOn"].Count; i++) { foreach (var strategy in strategies) { if (string.Equals(strategy.Name, taskJson["DependsOn"][i])) { task.DependsOn.Add(strategy); } } } } }
public void Run() { //TaskQueue=Services.GetService<Queue<IProcess>>(); TaskQueue = new Queue <IProcess>(); //CurrentSessionParams.Context=Services.GetService<VDContext>(); TaskStrategy = Services.GetService <TaskStrategy>(); var serviceAccessor = Services.GetService <Func <ProcessState, ITask> >(); InitTask = serviceAccessor(ProcessState.Init); CleanTask = serviceAccessor(ProcessState.Clean); DownloadTask = serviceAccessor(ProcessState.Download); UnzipTask = serviceAccessor(ProcessState.Unzip); ImportDataTask = serviceAccessor(ProcessState.Import); TaskQueue.Enqueue(new Processable(() => TaskStrategy.ChangeStrategy(InitTask).PerformTask())); TaskQueue.Enqueue(new Processable(() => TaskStrategy.ChangeStrategy(CleanTask).PerformTask())); TaskQueue.Enqueue(new Processable(() => TaskStrategy.ChangeStrategy(DownloadTask).PerformTask())); TaskQueue.Enqueue(new Processable(() => TaskStrategy.ChangeStrategy(UnzipTask).PerformTask())); TaskQueue.Enqueue(new Processable(() => TaskStrategy.ChangeStrategy(ImportDataTask).PerformTask())); while (TaskQueue.Count > 0) { TaskQueue.Dequeue().Process(); } }
public Task(Action action, TaskStrategy mode) : this() { if (mode == TaskStrategy.Coroutine) { throw new ArgumentException("Action tasks may not be coroutines"); } this._action = action; this.Strategy = mode; }
public Task(IEnumerator action) : this() { if (action == null) { throw new ArgumentNullException("action"); } this._routine = action; this.Strategy = TaskStrategy.Coroutine; }
/// <summary> /// Creates a new background task /// </summary> /// <param name="action"></param> public UnityTask(Action action) { _action = action; #if UNITY_WEBGL Strategy = TaskStrategy.MainThread; #else Strategy = TaskStrategy.BackgroundThread; #endif }
public Task(Delegate action, object paramater, TaskStrategy mode) : this() { if (mode == TaskStrategy.Coroutine) { throw new ArgumentException("Action tasks may not be coroutines"); } this._action2 = action; this.Strategy = mode; this.Paramater = paramater; }
public Task(IEnumerator action, object param) : this() { if (action == null) { throw new ArgumentNullException("action"); } this._routine = action; this.Strategy = TaskStrategy.Coroutine; this.Paramater = param; }
/// <summary> /// Creates a new background task with a parameter /// </summary> /// <param name="action"></param> /// <param name="paramater"></param> public UnityTask(Delegate action, object paramater) : this() { _action2 = action; #if UNITY_WEBGL Strategy = TaskStrategy.MainThread; #else Strategy = TaskStrategy.BackgroundThread; #endif Paramater = paramater; }
private bool SaveCollSettings() { int newGrCollCycle; try { newGrCollCycle = int.Parse(this.txtGRCollCycle.Text.Trim()); } catch { MsgBox.Show("采集周期必须输入数字"); return(false); } if (newGrCollCycle < MIN_COLL_CYCLE) { MsgBox.Show("采集周期不能小于" + MIN_COLL_CYCLE + "分钟"); return(false); } if (newGrCollCycle > MAX_COLL_CYCLE) { MsgBox.Show("采集周期不能大于" + MIN_COLL_CYCLE + "分钟"); return(false); } XGConfig.Default.GrRealDataCollCycle = newGrCollCycle; // refresh task coll cycle // TasksCollection tasks = Singles.S.TaskScheduler.Tasks; foreach (Task t in tasks) { TaskStrategy s = t.TaskStrategy; CommCmdBase cmd = t.CommCmd; if (s is CycleTaskStrategy && cmd is GRCtrl.GRRealDataCommand) { CycleTaskStrategy cyc = s as CycleTaskStrategy; cyc.Cycle = GetCycle(newGrCollCycle); } } // TODO: update app.config file // return(true); }
private void SetCollCycle() { TasksCollection tasks = Singles.S.TaskScheduler.Tasks; foreach (Task t in tasks) { TaskStrategy s = t.TaskStrategy; if (s is CycleTaskStrategy) { CycleTaskStrategy cyc = s as CycleTaskStrategy; cyc.Cycle = GetCycle(); } } }
/// <summary> /// Creates a new task with a specific strategy /// </summary> public UnityTask(Func <TResult> function, TaskStrategy mode) : this() { if (function == null) { throw new ArgumentNullException("function"); } if (mode == TaskStrategy.Coroutine) { throw new ArgumentException("Mode can not be coroutine"); } _function = function; Strategy = mode; }
/// <summary> /// Creates a new task with a specific strategy /// </summary> public UnityTask(Delegate function, object param, TaskStrategy mode) : this() { if (function == null) { throw new ArgumentNullException("function"); } if (mode == TaskStrategy.Coroutine) { throw new ArgumentException("Mode can not be coroutine"); } _function2 = function; Paramater = param; Strategy = mode; }
public static List <TaskStrategy> FromJson(JSONNode json) { var strategies = new List <TaskStrategy>(); foreach (var tasksPair in json["Tasks"].AsArray) { var taskJson = tasksPair.Value.AsObject; TaskStrategy task = new TaskStrategy(); ParseTask(taskJson, ref task, strategies); strategies.Add(task); } foreach (var tasksPair in json["OnceADaysTasks"].AsArray) { var taskJson = tasksPair.Value.AsObject; TaskStrategy task = new OnceADayTaskStrategy(); ParseTask(taskJson, ref task, strategies); strategies.Add(task); } return(strategies); }
/// <summary> /// Creates a new background task /// </summary> /// <param name="action"></param> public AsyncTask(Action action) { _action = action; Strategy = TaskStrategy.BackgroundThread; }
/// <summary> /// Creates a new Task in a Faulted state /// </summary> /// <param name="ex"></param> public AsyncTask(Exception ex) { Exception = ex; Strategy = TaskStrategy.Custom; Status = TaskStatus.Faulted; }
/// <summary> /// Creates a new task /// </summary> public AsyncTask(TaskStrategy mode) { Strategy = mode; }
/// <summary> /// Creates a new Coroutine Task /// </summary> /// <param name="action"></param> public UnityTask(IEnumerator action) : this() { if (action == null) throw new ArgumentNullException("action"); _routine = action; Strategy = TaskStrategy.Coroutine; }
/// <summary> /// Creates a new Task /// </summary> /// <param name="action"></param> /// <param name="mode"></param> public UnityTask(Action action, TaskStrategy mode) : this() { if (mode == TaskStrategy.Coroutine) throw new ArgumentException("Action tasks may not be coroutines"); _action = action; Strategy = mode; }
/// <summary> /// Creates a new Task in a Faulted state /// </summary> /// <param name="ex"></param> public UnityTask(Exception ex) { Exception = ex; Strategy = TaskStrategy.Custom; Status = TaskStatus.Faulted; }
/// <summary> /// Creates a new task /// </summary> public UnityTask(TaskStrategy mode) { Strategy = mode; }
public Task(TaskStrategy mode) : this() { this.Strategy = mode; }
/// <summary> /// Creates a new task /// </summary> public UnityTask(TaskStrategy mode) : this() { Strategy = mode; }
public Task(Delegate action, object paramater) : this() { this._action2 = action; this.Strategy = TaskStrategy.BackgroundThread; this.Paramater = paramater; }
public override void InitStrategy(int robotId, int teamId) { //Initialisation des taches de la stratégie //Taches de bas niveau taskBrasGauche = new TaskBrasGauche(); taskBrasGauche.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; taskBrasGauche.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; OnMotorCurrentReceiveForwardEvent += taskBrasGauche.OnMotorCurrentReceive; taskBrasDroit = new TaskBrasDroit(); taskBrasDroit.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; taskBrasDroit.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; OnMotorCurrentReceiveForwardEvent += taskBrasDroit.OnMotorCurrentReceive; taskBrasCentre = new TaskBrasCentre(); taskBrasCentre.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; taskBrasCentre.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; OnMotorCurrentReceiveForwardEvent += taskBrasCentre.OnMotorCurrentReceive; taskBrasDrapeau = new TaskBrasDrapeau(); taskBrasDrapeau.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; taskBrasDrapeau.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; OnMotorCurrentReceiveForwardEvent += taskBrasDrapeau.OnMotorCurrentReceive; taskBalade = new TaskBalade(this); OnMotorCurrentReceiveForwardEvent += taskBalade.OnMotorCurrentReceive; taskBalade.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; taskDepose = new TaskDepose(this); OnMotorCurrentReceiveForwardEvent += taskDepose.OnMotorCurrentReceive; taskDepose.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; taskWindFlag = new TaskWindFlag(this); taskWindFlag.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; OnMotorCurrentReceiveForwardEvent += taskWindFlag.OnMotorCurrentReceive; taskWindFlag.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; taskStrategy = new TaskStrategy(this); OnIOValuesFromRobotEvent += taskStrategy.OnIOValuesFromRobotEvent; taskStrategy.OnMirrorModeEvent += OnMirrorMode; taskFinDeMatch = new TaskFinDeMatch(this); taskFinDeMatch.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; OnMotorCurrentReceiveForwardEvent += taskFinDeMatch.OnMotorCurrentReceive; taskFinDeMatch.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; taskPhare = new TaskPhare(this); taskPhare.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; OnMotorCurrentReceiveForwardEvent += taskPhare.OnMotorCurrentReceive; taskPhare.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; taskDistributeur = new TaskDistributeur(this); taskDistributeur.OnHerkulexPositionRequestEvent += OnHerkulexPositionRequestForwardEvent; taskDistributeur.OnPilotageVentouseEvent += OnSetSpeedConsigneToMotorEvent; OnMotorCurrentReceiveForwardEvent += taskDistributeur.OnMotorCurrentReceive; //On initialisae le timer de réglage récurrent //Il permet de modifier facilement les paramètre des asservissement durant l'exécution configTimer = new System.Timers.Timer(1000); configTimer.Elapsed += ConfigTimer_Elapsed; configTimer.Start(); //Config Eurobot des paramètre embarqués OnOdometryPointToMeter(1.211037464120243e-06); On4WheelsAngleSet(Toolbox.DegToRad(72), Toolbox.DegToRad(144), Toolbox.DegToRad(216), Toolbox.DegToRad(288)); On4WheelsToPolarSet(-3.967532e-01, -2.720655e-01, +2.720655e-01, 3.967532e-01, +3.776278e-01, -3.776278e-01, -3.776278e-01, 3.776278e-01, +2.106947e+00, +1.341329e+00, +1.341329e+00, +2.106947e+00); OnEnableDisableMotorCurrentData(true); }
public Task(Exception ex) { this.Exception = ex; this.Strategy = TaskStrategy.Custom; this.Status = TaskStatus.Faulted; }
public Task(Action action) : this() { this._action = action; this.Strategy = TaskStrategy.BackgroundThread; }