示例#1
0
    /// <summary>
    /// 尝试触发任务
    /// </summary>
    public bool TryTrigger(FAbilityTagContainer inTag)
    {
        if (TaskStatus != ETaskStatus.TS_UnAccepted)
        {
            return(false);
        }

        bool bRes = false;

        if (needTriggerTaskTags == null)
        {
            bRes       = true;
            TaskStatus = ETaskStatus.TS_Accepted;
        }
        else if (needTriggerTaskTags.Contains(inTag))
        {
            if (alreadyTriggerTaskTags == null)
            {
                alreadyTriggerTaskTags = new List <FAbilityTagContainer>();
            }

            alreadyTriggerTaskTags.Add(inTag);

            if (alreadyTriggerTaskTags.Count == needTriggerTaskTags.Count)
            {
                foreach (FAbilityTagContainer registerTag in registerEventTags)
                {
                    AbilityManager.Instance.RegisterEvent(registerTag, OnTriggerEvent);
                }
                bRes       = true;
                TaskStatus = ETaskStatus.TS_Accepted;
            }
        }
        return(bRes);
    }
示例#2
0
        public List <TaskInfo> EnumTasks(
            [Parameter("Filter tasks to the a particular type",
                       DefaultValue = ETaskType.All)]
            ETaskType taskTypeFilter,
            [Parameter("Filter tasks to the a particular status",
                       DefaultValue = ETaskStatus.All)]
            ETaskStatus taskStatusFilter,
            [Parameter("User name to filter by (blank for all)",
                       DefaultValue = null)]
            string taskUserName,
            [Parameter("Server name to filter by (blank for all servers in cluster)",
                       DefaultValue = null)]
            string taskServerName,
            IOutput output)
        {
            var tasks = GetTasks(taskTypeFilter, taskStatusFilter, taskUserName, taskServerName, false);

            output.SetHeader("Task Id", 12, "User Id", "Server", "Task Type", "Task Status", 14,
                             "% Complete", 10, "Description");
            foreach (var task in tasks)
            {
                output.WriteRecord(task.TaskId, task.User, task.Server, task.TaskType,
                                   task.TaskStatus, task.PercentageComplete, task.Description);
            }
            output.End();

            return(tasks);
        }
示例#3
0
        private void ButtonAddEdit_Click(object sender, RoutedEventArgs e)
        {
            string      task    = tbTask.Text;
            DateTime    dueDate = dpDueDate.SelectedDate.Value;
            ETaskStatus isDone  = (cbIsDone.IsChecked == true ? ETaskStatus.Done : ETaskStatus.Pending);

            if (EditedTodo == null)
            {
                Todo Todo = new Todo()
                {
                    Task = task, DueDate = dueDate, IsDone = isDone
                };
                // FIXME: handle SqlException
                Globals.Db.AddTodo(Todo);
            }
            else
            {
                EditedTodo.Task    = task;
                EditedTodo.DueDate = dueDate;
                EditedTodo.IsDone  = isDone;
                // FIXME: handle SqlException
                Globals.Db.UpdateTodo(EditedTodo);
            }
            DialogResult = true;
        }
示例#4
0
 public void SetStatus(ETaskStatus status, bool flashingfocus = false)
 {
     TaskStatus = status;
     if (ETaskStatus.TS_Focus == status)
     {
         m_Timer.Start(flashingfocus);
     }
     else
     {
         m_Timer.Stop();
     }
 }
 private void buttonPauseTask_Click(object sender, EventArgs e)
 {
     if (_statusTask == ETaskStatus.Pause)
     {
         _statusTask       = ETaskStatus.Start;
         Controller.Locked = true; //заблокируем
     }
     else
     {
         _statusTask       = ETaskStatus.Pause;
         Controller.Locked = false; //разблокируем
     }
 }
示例#6
0
    private static EColorStatus GetColorStatus(ETaskStatus taskstatus, bool flashon)
    {
        switch (taskstatus)
        {
        case ETaskStatus.TS_Pending: return(EColorStatus.CS_Pending);

        case ETaskStatus.TS_Focus: return(flashon ? EColorStatus.CS_Focus : EColorStatus.CS_Pending);

        case ETaskStatus.TS_Finished: return(EColorStatus.CS_Finished);

        default: return(EColorStatus.CS_Pending);
        }
    }
        public static string GetTaskStatus(this ETaskStatus value)
        {
            switch (value)
            {
            case ETaskStatus.CantStart:
                return("CantStart");

            case ETaskStatus.Completed:
                return("Completed");

            case ETaskStatus.NotCompleted:
                return("NotCompleted");

            default:
                return("None");
            }
        }
示例#8
0
        public async Task UpdateStatus(string caseId, ETaskStatus status, EFosteringApplicationForm form)
        {
            var fields = new FormFieldBuilder()
                         .AddField(form.GetFormStatusFieldName(), status.GetTaskStatus())
                         .Build();

            var response = await _verintServiceGateway.UpdateCaseIntegrationFormField(new IntegrationFormFieldsUpdateModel
            {
                CaseReference         = caseId,
                IntegrationFormName   = _applicationFormName,
                IntegrationFormFields = fields
            });

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception(
                          $"Application Service. UpdateStatus: Failed to update status. Verint service response: {response}");
            }
        }
示例#9
0
        private IActionResult ChangeTaskStatus(Guid id, ETaskStatus current, ETaskStatus next)
        {
            var task = _context.Find <Task>(id);

            if (task != null && task.Status == current)
            {
                task.Status = next;

                _context.Update(task);

                _context.SaveChanges();
            }

            Tasks = _context.Tasks.ToList();

            Request.QueryString = default;

            return(RedirectToPage("Index"));
        }
        private void buttonStartTask_Click(object sender, EventArgs e)
        {
            if (!Controller.Connected)
            {
                return;
            }

            if (Controller.Locked)
            {
                return;
            }

            if (_statusTask == ETaskStatus.Off)
            {
                if (listGkodeCommand.SelectedIndex == -1)
                {
                    return;
                }

                Controller.Locked = true;
                _statusTask       = ETaskStatus.Start;
                timerTask.Enabled = true;

                _nowPos = listGkodeCommand.SelectedIndex;

                if (listGkodeCommand.SelectedItems.Count == 1)
                {
                    _endPos = listGkodeCommand.Items.Count;
                }
                else
                {
                    _endPos = listGkodeCommand.SelectedIndex + listGkodeCommand.SelectedItems.Count;
                }
            }

            if (_statusTask == ETaskStatus.Pause)
            {
                Controller.Locked = true;
                _statusTask       = ETaskStatus.Work;
                timerTask.Enabled = true;
            }
        }
示例#11
0
        /// <summary>
        /// IPステータス文字列をセットする
        /// </summary>
        private void SetIPStatusMessage(ETaskStatus ts)
        {
            switch (ts)
            {
            case ETaskStatus.CREATE_AND_START:
                isSetIPStatusLabelTaskRunning = true;
                Task IPStatusMessageTask = Task.Factory.StartNew(() =>
                {
                    while (isSetIPStatusLabelTaskRunning)
                    {
                        IPStatusToolStripStatusLabel.Text = imageProc.status;
                    }
                });
                break;

            case ETaskStatus.STOP:
                isSetIPStatusLabelTaskRunning = false;
                break;
            }
        }
示例#12
0
    /// <summary>
    /// 触发事件
    /// </summary>
    /// <param name="param1"></param>
    /// <param name="param2"></param>
    /// <param name="param3"></param>
    public void OnTriggerEvent(FAbilityTagContainer inTriggerTag, object param1, object param2, object param3)
    {
        float add = (float)param1;

        Current += add;
        if (Current >= Conditions)
        {
            TaskStatus = ETaskStatus.TS_Finished;
            TaskManager.Instance.RemoveTask(this);

            foreach (FAbilityTagContainer registerTag in registerEventTags)
            {
                AbilityManager.Instance.RemoveEvent(registerTag, OnTriggerEvent);
            }
            foreach (FAbilityTagContainer triggerTag in finishTriggerTaskTags)
            {
                AbilityManager.Instance.TriggerEvent(triggerTag, 1);
            }
        }
    }
示例#13
0
        public List <Todo> GetAllTodos(string orderBy = "Id")
        {
            List <Todo> list      = new List <Todo>();
            SqlCommand  cmdSelect = new SqlCommand("SELECT * FROM Todos ORDER BY " + orderBy, conn);

            using (SqlDataReader reader = cmdSelect.ExecuteReader())
            {
                while (reader.Read())
                {
                    int         id      = (int)reader["Id"];
                    string      task    = (string)reader[1];
                    DateTime    dueDate = (DateTime)reader[2];
                    ETaskStatus isDone  = (ETaskStatus)Enum.Parse(typeof(ETaskStatus), (string)reader[3]); // ???
                    list.Add(new Todo()
                    {
                        Id = id, Task = task, DueDate = dueDate, IsDone = isDone
                    });
                }
            }
            return(list);
        }
        public async Task UpdateStatus(string caseId, ETaskStatus status, EFosteringHomeVisitForm form)
        {
            var formStatusFieldName = form.GetFormStatusFieldName();

            var formFields = new FormFieldBuilder()
                             .AddField(formStatusFieldName, status.GetTaskStatus());

            var updateModel = new IntegrationFormFieldsUpdateModel
            {
                IntegrationFormName   = _integrationFormName,
                CaseReference         = caseId,
                IntegrationFormFields = formFields.Build()
            };

            var response = await _verintServiceGateway
                           .UpdateCaseIntegrationFormField(updateModel);

            if (response.StatusCode != HttpStatusCode.OK)
            {
                throw new Exception("Passive update-status failure");
            }
        }
示例#15
0
 private void DoKill()
 {
     try
     {
         if (_process?.HasExited == false)
         {
             KillProcessAndChildrens(_process.Id);
             _process.OutputDataReceived -= Process_OutputDataReceived;
             _process.ErrorDataReceived  -= Process_ErrorDataReceived;
             _process.Exited             -= Process_Exited;
         }
     }
     catch
     {
         // nothing
     }
     _taskData.DebugData.TaskStatus = _taskData.DebugData.HasErrors() ? ETaskStatus.KilledWithErrors : ETaskStatus.Killed;
     _taskStatus = _taskData.DebugData.TaskStatus;
     StatusChanged?.Invoke(this, new TaskStatusChangedEventArgs(_taskStatus, _taskData.Id));
     _hasErrorMessage  = false;
     _hasOutputMessage = false;
 }
        public async Task GetCase_ShouldMapStatus(string status, ETaskStatus expectedStatus)
        {
            // Arrange
            var entity = new CaseBuilder()
                         .WithIntegrationFormField("surname", "Last Name")
                         .WithIntegrationFormField("firstname", "First Name")
                         .WithIntegrationFormField("tellusaboutyourselfstatus", status)
                         .Build();

            _verintServiceGatewayMock
            .Setup(_ => _.GetCase(It.IsAny <string>()))
            .ReturnsAsync(new HttpResponse <Case>
            {
                StatusCode      = HttpStatusCode.OK,
                ResponseContent = entity
            });

            // Act
            var result = await _caseService.GetCase("");

            // Assert
            Assert.Equal(expectedStatus, result.Statuses.TellUsAboutYourselfStatus);
        }
示例#17
0
 private void Process_ErrorDataReceived(object sender, System.Diagnostics.DataReceivedEventArgs e)
 {
     lock (_locker)
     {
         _taskData.DebugData.DateLastSignal = DateTime.Now;
         if (!string.IsNullOrEmpty(e.Data))
         {
             _hasErrorMessage = true;
         }
         if (_hasErrorMessage)
         {
             string message = ToErrorMessage(e.Data);
             _taskData.DebugData.Output += message;
             ErrorDataReceived?.Invoke(this, new TaskDataReceivedEventArgs(message, _taskData.Id));
             _taskData.DebugData.TaskStatus = ETaskStatus.RunningWithErrors;
             _taskStatus = _taskData.DebugData.TaskStatus;
             StatusChanged?.Invoke(this, new TaskStatusChangedEventArgs(_taskStatus, _taskData.Id));
             const string notificationMessageTemplate = "Task \"{0}\" sent error message:\r\n\t {1}.";
             string       notificationMessage         = string.Format(notificationMessageTemplate, _taskData.Name, e.Data);
             TaskNotification?.Invoke(this, new TaskNotificationEventArgs(notificationMessage, _taskData.Id, _taskData.Name, ENotificationType.TaskError));
         }
     }
 }
示例#18
0
 private void Process_Exited(object sender, EventArgs e)
 {
     lock (_locker)
     {
         _taskData.DebugData.DateLastSignal = DateTime.Now;
         Process process = sender as Process;
         int     result  = process.ExitCode; //this tell if there was an error or not
         string  message = ToExitMessage(result.ToString());
         _taskData.DebugData.Output += message;
         Exited?.Invoke(this, new TaskExitedEventArgs(result, message, _taskData.Id));
         _taskData.DebugData.TaskStatus = _taskData.DebugData.HasErrors()?ETaskStatus.CompletedWithErrors: ETaskStatus.Ready;
         _taskStatus = _taskData.DebugData.TaskStatus;
         StatusChanged?.Invoke(this, new TaskStatusChangedEventArgs(_taskStatus, _taskData.Id));
         _hasErrorMessage  = false;
         _hasOutputMessage = false;
         _process          = null;
         const string notificationMessageTemplate = "Task \"{0}\" exited with exit code {1}.";
         string       notificationMessage         = string.Format(notificationMessageTemplate, _taskData.Name, process.ExitCode);
         TaskNotification?.Invoke(this, new TaskNotificationEventArgs(notificationMessage, _taskData.Id, _taskData.Name, ENotificationType.TaskExit));
         string managementMessage = ToManagementMessage(notificationMessage);
         _taskData.DebugData.Output += managementMessage;
         ManagementDataReceived?.Invoke(this, new TaskDataReceivedEventArgs(managementMessage, _taskData.Id));
     }
 }
 private void buttonPauseTask_Click(object sender, EventArgs e)
 {
     if (_statusTask == ETaskStatus.Pause)
     {
         _statusTask = ETaskStatus.Start;
         Controller.Locked = true; //заблокируем
     }
     else
     {
         _statusTask = ETaskStatus.Pause;
         Controller.Locked = false; //разблокируем
     }
 }
示例#20
0
 public Task(string title, ETaskStatus status)
 {
     Id     = Guid.NewGuid();
     Title  = title;
     Status = status;
 }
 private void btStopTask_Click(object sender, EventArgs e)
 {
     timerTask.Enabled = false;
     _statusTask = ETaskStatus.Off;
     Controller.Locked = false; //разблокируем 
 }
示例#22
0
        /// <summary>
        /// Returns a list containing details for tasks that match the selection
        /// criteria.
        /// </summary>
        protected List <TaskInfo> GetTasks(ETaskType taskType, ETaskStatus taskStatus,
                                           string user, string server, bool currentSessionOnly)
        {
            int    userId = 0, totalTasks = 0;
            object oTaskIds = null, oTaskTypes = null, oTaskProgress = null, oTaskStatuses = null,
                   oUsers = null, oServers = null,
                   oScheduledStartTimes = null, oActualStartTimes = null, oLastUpdateTimes = null,
                   oDescriptions = null, oLogFiles = null;

            int[]         taskIds, progress;
            ETaskType[]   taskTypes;
            ETaskStatus[] taskStatuses;
            double[]      scheduledTimes, actualTimes, lastUpdateTimes;
            string[]      users, servers, descriptions, logFiles;

            if (user != null)
            {
                HFM.Try("Retrieving user activity id for {0}", user,
                        () => HsvSystemInfo.GetActivityUserID(user, out userId));
            }

            HFM.Try("Retrieving details of tasks",
                    () => HsvSystemInfo.EnumRunningTasks(taskType == ETaskType.All, (int)taskType,
                                                         user == null, userId, server == null, server,
                                                         !currentSessionOnly, taskStatus == ETaskStatus.All, (int)taskStatus,
                                                         0, 10000, // Retrieve the first 10,000 records
                                                         out oTaskIds, out oTaskTypes, out oTaskProgress, out oTaskStatuses,
                                                         out oUsers, out oServers, out oScheduledStartTimes, out oActualStartTimes,
                                                         out oLastUpdateTimes, out oDescriptions, out oLogFiles, out totalTasks));

            // Note: We can't use HFM.Object2Array for the primitive and ennum
            // types here, since the returned values are not object[]!?
            // May have something to do with the params being declared out, rather
            // than in/out?
            taskIds         = (int[])oTaskIds;
            taskTypes       = (ETaskType[])oTaskTypes;
            progress        = (int[])oTaskProgress;
            taskStatuses    = (ETaskStatus[])oTaskStatuses;
            users           = HFM.Object2Array <string>(oUsers);
            servers         = HFM.Object2Array <string>(oServers);
            scheduledTimes  = (double[])oScheduledStartTimes;
            actualTimes     = (double[])oActualStartTimes;
            lastUpdateTimes = (double[])oLastUpdateTimes;
            descriptions    = HFM.Object2Array <string>(oDescriptions);
            logFiles        = HFM.Object2Array <string>(oLogFiles);

            var tasks = new List <TaskInfo>(totalTasks);

            for (var i = 0; taskIds != null && i < taskIds.Length; ++i)
            {
                tasks.Add(new TaskInfo()
                {
                    TaskId             = taskIds[i],
                    User               = users[i],
                    Server             = servers[i],
                    TaskType           = taskTypes[i],
                    TaskStatus         = taskStatuses[i],
                    PercentageComplete = progress[i],
                    ScheduledStartTime = DateTime.FromOADate(scheduledTimes[i]),
                    ActualStartTime    = DateTime.FromOADate(actualTimes[i]),
                    LastUpdate         = DateTime.FromOADate(lastUpdateTimes[i]),
                    Description        = descriptions[i],
                    LogFile            = logFiles[i]
                });
            }

            return(tasks);
        }
        /// <summary>
        /// Предыдущее значение
        /// </summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (_statusTask == ETaskStatus.Start)
            {
                Controller.SendBinaryData(BinaryData.pack_9E(0x05));
                Controller.SendBinaryData(BinaryData.pack_BF(GlobalSetting.ControllerSetting.AxleX.MaxSpeed, GlobalSetting.ControllerSetting.AxleY.MaxSpeed, GlobalSetting.ControllerSetting.AxleZ.MaxSpeed, GlobalSetting.ControllerSetting.AxleA.MaxSpeed));
                Controller.SendBinaryData(BinaryData.pack_C0());
                _statusTask = ETaskStatus.Work;
            }

            if (_statusTask == ETaskStatus.Stop)
            {
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_9D());
                Controller.SendBinaryData(BinaryData.pack_9E(0x02));
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                _statusTask = ETaskStatus.Off;
                Controller.Locked = false; //разблокируем 
            }
            
            if (_statusTask == ETaskStatus.Work)
            {
                if (_nowPos >= _endPos)
                {
                    _statusTask = ETaskStatus.Stop;
                    return;
                }

                // сравним наличие изменений в данных, и проанализируем какие команды послать в контроллер
                DataRow dataRowNow = DataLoader.DataRows[_nowPos];
                DataRow dataRowOld = new DataRow(0,"");
                if (_nowPos != 0) dataRowOld = DataLoader.DataRows[_nowPos-1];


                //TODO: пока не работает
                if (dataRowNow.Extra.NeedPause)
                {
                    //MessageBox.Show(@"Выполняется пауза длительностью " + dataRowNow.Extra.timeoutMsec + @" мс.", "",
                    //    MessageBoxButtons.OK);
                    //System.Threading.Thread.Sleep(dataRowNow.Extra.timeoutMsec);
                }

                //Сравнить, и установить в случае необходимости
                //1) Шпиндель и скорость работы
                //2) Выполнить движение с необходимой скоростью

                //if (dataRowNow.Machine != dataRowOld.Machine)
                if (dataRowNow.Machine.SpindelON != dataRowOld.Machine.SpindelON || dataRowNow.Machine.SpeedSpindel != dataRowOld.Machine.SpeedSpindel)
                {
                    Controller.SendBinaryData(BinaryData.pack_B5(dataRowNow.Machine.SpindelON, 2, BinaryData.TypeSignal.Hz, dataRowNow.Machine.SpeedSpindel));

                    //зафиксируем
                    PlanetCNC_Controller.LastStatus = dataRowNow;
                }

                if (dataRowNow.POS.X != dataRowOld.POS.X || dataRowNow.POS.Y != dataRowOld.POS.Y || dataRowNow.POS.Z != dataRowOld.POS.Z || dataRowNow.POS.Z != dataRowOld.POS.Z)
                {
                    if (Controller.INFO.NuberCompleatedInstruction == 0)
                    {
                        //если нет номера инструкции, то отправляем пока буфер не сильно занят
                        if (GlobalSetting.AppSetting.Controller == ControllerModel.PlanetCNC_MK1 && Controller.INFO.FreebuffSize < 4) return;
                        if (GlobalSetting.AppSetting.Controller == ControllerModel.PlanetCNC_MK2 && Controller.INFO.FreebuffSize < 230) return;
                    }
                    else
                    {
                        //знаем номер инструкции, и будем отправлять пока не более 10 инструкций
                        if (_nowPos > (Controller.INFO.NuberCompleatedInstruction + GlobalSetting.ControllerSetting.MinBuffSize)) return;
                    }

                    int speedToSend = dataRowNow.Machine.SpeedMaсhine;

                    if (checkBoxManualSpeed.Checked)
                    {
                        if (dataRowNow.Machine.NumGkode == 0) speedToSend = (int)numericUpDown1.Value;

                        if (dataRowNow.Machine.NumGkode == 1) speedToSend = (int)numericUpDown2.Value;
                    }



                    //координаты следующей точки
                    float pointX = (float)dataRowNow.POS.X;
                    float pointY = (float)dataRowNow.POS.Y;
                    float pointZ = (float)dataRowNow.POS.Z;

                    //добавление смещения G-кода
                    if (Controller.CorrectionPos.useCorrection)
                    {
                        //// применение пропорций
                        //pointX *= Setting.koeffSizeX;
                        //pointY *= Setting.koeffSizeY;

                        //применение смещения
                        pointX += (float)Controller.CorrectionPos.deltaX;
                        pointY += (float)Controller.CorrectionPos.deltaY;

                        //применение матрицы поверхности детали
                        if (Controller.CorrectionPos.UseMatrix)
                        {
                            pointZ += ScanSurface.GetPosZ(pointX, pointY);
                        }

                        pointZ += (float)Controller.CorrectionPos.deltaZ;

                    }

                    Controller.SendBinaryData(BinaryData.pack_CA(Controller.INFO.CalcPosPulse("X", (decimal)pointX),
                                                                    Controller.INFO.CalcPosPulse("Y", (decimal)pointY),
                                                                    Controller.INFO.CalcPosPulse("Z", (decimal)pointZ),
                                                                    Controller.INFO.CalcPosPulse("A", dataRowNow.POS.A),
                                                                    speedToSend,
                                                                    dataRowNow.numberRow));

                    //зафиксируем
                    PlanetCNC_Controller.LastStatus = dataRowNow;
                }
                
                if (_nowPos < _endPos) _nowPos++;
            }
        }
示例#24
0
 private void SetColor(ETaskStatus status)
 {
     SetColor(GetColorStatus(status, m_Timer.BlinkStatus));
 }
 private void btStopTask_Click(object sender, EventArgs e)
 {
     timerTask.Enabled = false;
     _statusTask       = ETaskStatus.Off;
     Controller.Locked = false; //разблокируем
 }
示例#26
0
 public TarkRunner(TaskData taskData)
 {
     _taskData   = taskData;
     _taskStatus = _taskData.DebugData.TaskStatus;
 }
示例#27
0
        private void RunTaskAsProcess(TaskData taskData)
        {
            _hasErrorMessage  = false;
            _hasOutputMessage = false;
            var process = new Process
            {
                StartInfo = new ProcessStartInfo
                {
                    FileName               = taskData.ActioningData.Command,
                    Arguments              = taskData.ActioningData.Parameters,
                    UseShellExecute        = false,
                    RedirectStandardOutput = true,
                    RedirectStandardError  = true,
                    WorkingDirectory       = taskData.ActioningData.StartIn,
                    CreateNoWindow         = true
                }
            };

            if (taskData.ActioningData.RunAsOther)
            {
                System.Security.SecureString ssPwd = new System.Security.SecureString();
                process.StartInfo.Domain   = taskData.ActioningData.Domain;
                process.StartInfo.UserName = taskData.ActioningData.UserName;
                string password = taskData.ActioningData.Password;
                for (int x = 0; x < password.Length; x++)
                {
                    ssPwd.AppendChar(password[x]);
                }
                process.StartInfo.Password = ssPwd;
            }

            process.OutputDataReceived += Process_OutputDataReceived;
            process.ErrorDataReceived  += Process_ErrorDataReceived;
            process.EnableRaisingEvents = true;
            process.Exited                += Process_Exited;
            _taskData.DebugData.Output     = string.Empty;
            _taskData.DebugData.TaskStatus = ETaskStatus.Running;
            _taskStatus = _taskData.DebugData.TaskStatus;

            string notificationMessageTemplate = "Starting task \"{0}\"... ";
            string notificationMessage         = string.Format(notificationMessageTemplate, _taskData.Name);

            TaskNotification?.Invoke(this, new TaskNotificationEventArgs(notificationMessage, _taskData.Id, _taskData.Name, ENotificationType.TaskStart));
            string managementMessage = ToManagementMessage(notificationMessage);

            _taskData.DebugData.Output += managementMessage;
            ManagementDataReceived?.Invoke(this, new TaskDataReceivedEventArgs(managementMessage, _taskData.Id));

            StatusChanged?.Invoke(this, new TaskStatusChangedEventArgs(_taskStatus, _taskData.Id));
            _taskData.DebugData.DateStarted = DateTime.Now;
            try
            {
                process.Start();
            }
            catch (Exception ex)
            {
                notificationMessageTemplate = "Error while running \"{0}\": \r\b\t:{1}";
                notificationMessage         = string.Format(notificationMessageTemplate, _taskData.Name, ex.Message);
                TaskNotification?.Invoke(this, new TaskNotificationEventArgs(notificationMessage, _taskData.Id, _taskData.Name, ENotificationType.TaskCrash));
                managementMessage           = ToManagementMessage(notificationMessage);
                _taskData.DebugData.Output += managementMessage;
                ManagementDataReceived?.Invoke(this, new TaskDataReceivedEventArgs(managementMessage, _taskData.Id));
            }
            process.BeginOutputReadLine();
            process.BeginErrorReadLine();
            _process = process;
        }
 public void GetTaskStatus_ShouldReturnCorrectTaskStatus(string expected, ETaskStatus taskStatus)
 {
     Assert.Equal(expected, taskStatus.GetTaskStatus());
 }
        /// <summary>
        /// Предыдущее значение
        /// </summary>
        private void timer1_Tick(object sender, EventArgs e)
        {
            if (_statusTask == ETaskStatus.Start)
            {
                Controller.SendBinaryData(BinaryData.pack_9E(0x05));
                Controller.SendBinaryData(BinaryData.pack_BF(GlobalSetting.ControllerSetting.AxleX.MaxSpeed, GlobalSetting.ControllerSetting.AxleY.MaxSpeed, GlobalSetting.ControllerSetting.AxleZ.MaxSpeed, GlobalSetting.ControllerSetting.AxleA.MaxSpeed));
                Controller.SendBinaryData(BinaryData.pack_C0());
                _statusTask = ETaskStatus.Work;
            }

            if (_statusTask == ETaskStatus.Stop)
            {
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_9D());
                Controller.SendBinaryData(BinaryData.pack_9E(0x02));
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                Controller.SendBinaryData(BinaryData.pack_FF());
                _statusTask       = ETaskStatus.Off;
                Controller.Locked = false; //разблокируем
            }

            if (_statusTask == ETaskStatus.Work)
            {
                if (_nowPos >= _endPos)
                {
                    _statusTask = ETaskStatus.Stop;
                    return;
                }

                // сравним наличие изменений в данных, и проанализируем какие команды послать в контроллер
                DataRow dataRowNow = DataLoader.DataRows[_nowPos];
                DataRow dataRowOld = new DataRow(0, "");
                if (_nowPos != 0)
                {
                    dataRowOld = DataLoader.DataRows[_nowPos - 1];
                }


                //TODO: пока не работает
                if (dataRowNow.Extra.NeedPause)
                {
                    //MessageBox.Show(@"Выполняется пауза длительностью " + dataRowNow.Extra.timeoutMsec + @" мс.", "",
                    //    MessageBoxButtons.OK);
                    //System.Threading.Thread.Sleep(dataRowNow.Extra.timeoutMsec);
                }

                //Сравнить, и установить в случае необходимости
                //1) Шпиндель и скорость работы
                //2) Выполнить движение с необходимой скоростью

                //if (dataRowNow.Machine != dataRowOld.Machine)
                if (dataRowNow.Machine.SpindelON != dataRowOld.Machine.SpindelON || dataRowNow.Machine.SpeedSpindel != dataRowOld.Machine.SpeedSpindel)
                {
                    Controller.SendBinaryData(BinaryData.pack_B5(dataRowNow.Machine.SpindelON, 2, BinaryData.TypeSignal.Hz, dataRowNow.Machine.SpeedSpindel));

                    //зафиксируем
                    PlanetCNC_Controller.LastStatus = dataRowNow;
                }

                if (dataRowNow.POS.X != dataRowOld.POS.X || dataRowNow.POS.Y != dataRowOld.POS.Y || dataRowNow.POS.Z != dataRowOld.POS.Z || dataRowNow.POS.Z != dataRowOld.POS.Z)
                {
                    if (Controller.INFO.NuberCompleatedInstruction == 0)
                    {
                        //если нет номера инструкции, то отправляем пока буфер не сильно занят
                        if (GlobalSetting.AppSetting.Controller == ControllerModel.PlanetCNC_MK1 && Controller.INFO.FreebuffSize < 4)
                        {
                            return;
                        }
                        if (GlobalSetting.AppSetting.Controller == ControllerModel.PlanetCNC_MK2 && Controller.INFO.FreebuffSize < 230)
                        {
                            return;
                        }
                    }
                    else
                    {
                        //знаем номер инструкции, и будем отправлять пока не более 10 инструкций
                        if (_nowPos > (Controller.INFO.NuberCompleatedInstruction + GlobalSetting.ControllerSetting.MinBuffSize))
                        {
                            return;
                        }
                    }

                    int speedToSend = dataRowNow.Machine.SpeedMaсhine;

                    if (checkBoxManualSpeed.Checked)
                    {
                        if (dataRowNow.Machine.NumGkode == 0)
                        {
                            speedToSend = (int)numericUpDown1.Value;
                        }

                        if (dataRowNow.Machine.NumGkode == 1)
                        {
                            speedToSend = (int)numericUpDown2.Value;
                        }
                    }



                    //координаты следующей точки
                    float pointX = (float)dataRowNow.POS.X;
                    float pointY = (float)dataRowNow.POS.Y;
                    float pointZ = (float)dataRowNow.POS.Z;

                    //добавление смещения G-кода
                    if (Controller.CorrectionPos.useCorrection)
                    {
                        //// применение пропорций
                        //pointX *= Setting.koeffSizeX;
                        //pointY *= Setting.koeffSizeY;

                        //применение смещения
                        pointX += (float)Controller.CorrectionPos.deltaX;
                        pointY += (float)Controller.CorrectionPos.deltaY;

                        //применение матрицы поверхности детали
                        if (Controller.CorrectionPos.UseMatrix)
                        {
                            pointZ += ScanSurface.GetPosZ(pointX, pointY);
                        }

                        pointZ += (float)Controller.CorrectionPos.deltaZ;
                    }

                    Controller.SendBinaryData(BinaryData.pack_CA(Controller.INFO.CalcPosPulse("X", (decimal)pointX),
                                                                 Controller.INFO.CalcPosPulse("Y", (decimal)pointY),
                                                                 Controller.INFO.CalcPosPulse("Z", (decimal)pointZ),
                                                                 Controller.INFO.CalcPosPulse("A", dataRowNow.POS.A),
                                                                 speedToSend,
                                                                 dataRowNow.numberRow));

                    //зафиксируем
                    PlanetCNC_Controller.LastStatus = dataRowNow;
                }

                if (_nowPos < _endPos)
                {
                    _nowPos++;
                }
            }
        }
        private void buttonStartTask_Click(object sender, EventArgs e)
        {
            if (!Controller.Connected) return; 

            if (Controller.Locked) return;

            if (_statusTask == ETaskStatus.Off)
            {
                if (listGkodeCommand.SelectedIndex == -1) return;     
            
                Controller.Locked = true;
                _statusTask = ETaskStatus.Start;
                timerTask.Enabled = true;

                _nowPos = listGkodeCommand.SelectedIndex;

                if (listGkodeCommand.SelectedItems.Count == 1) _endPos = listGkodeCommand.Items.Count;
                else
                {
                    _endPos = listGkodeCommand.SelectedIndex + listGkodeCommand.SelectedItems.Count;
                }   
            }

            if (_statusTask == ETaskStatus.Pause)
            {
                Controller.Locked = true;
                _statusTask = ETaskStatus.Work;
                timerTask.Enabled = true;
            }
        }