Beispiel #1
0
        /// <inheritdoc />
        public void TerminateWorkout(string serialNumber)
        {
            ICommandList commandList = _commandListFactory.Create();

            commandList.Add(new SetScreenStateCommand(ScreenType.Workout, ScreenValueWorkout.TerminateWorkout));
            commandList.Prepare();
            _pmCommunicator.Send(serialNumber, commandList);
        }
Beispiel #2
0
 public override void CorrectionSequence(ICommandList command)
 {
     Old.IsChange = true;
     if (Next != null && Next.IsChange == false)
     {
         if (Old.Type == eTypeObjectStream.Continue && Next.Type == eTypeObjectStream.Continue && Type != eTypeObjectStream.Acquisition)
         {
             Next.IsChange = true;
             command.Add(new ClearObjectCommand(((Command)command).Document, Parent, TypeCollection, Next.IndexEvent));
         }
         else if (Old.Type == eTypeObjectStream.Acquisition && Next.Type == eTypeObjectStream.Continue)
         {
             Next.IsChange = true;
             command.Add(new SetObjectCommand(((Command)command).Document, Parent, TypeCollection, Next.IndexEvent, eTypeObjectStream.Acquisition, ((ObjectSequence)Old).Acquisition));
         }
     }
 }
Beispiel #3
0
 /// <summary>
 /// Корректирует объекты схемы в зависимости от текущего объекта команды
 /// </summary>
 /// <param name="command">Объект комманды</param>
 public virtual void CorrectionSequence(ICommandList command)
 {
     Old.IsChange = true;
     if (Next != null && Next.IsChange == false)
     {
         if (Old.Type == eTypeObjectStream.Continue && Next.Type == eTypeObjectStream.Continue && Type != eTypeObjectStream.TableShape)
         {
             Next.IsChange = true;
             command.Add(new ClearObjectCommand(((Command)command).Document, Parent, TypeCollection, Next.IndexEvent));
         }
         else if (Old.Type == eTypeObjectStream.TableShape && Next.Type == eTypeObjectStream.Continue)
         {
             Next.IsChange = true;
             command.Add(new SetObjectCommand(((Command)command).Document, Parent, TypeCollection, Next.IndexEvent, eTypeObjectStream.TableShape,
                                              ((ObjectStream)Parent[TypeCollection][IndexEvent]).Table));
         }
     }
 }
Beispiel #4
0
        /// <inheritdoc />
        public bool IsReadyToProgramWorkout(string serialNumber)
        {
            if (string.IsNullOrWhiteSpace(serialNumber))
            {
                _logger.LogError("Serial number must be defined when determining state.");
                return(false);
            }

            GetOperationalStateCommand operationalStateCommand = new();
            GetWorkoutStateCommand     workoutStateCommand     = new();

            ICommandList commandList = _commandListFactory.Create();

            commandList.Add(operationalStateCommand);
            commandList.Add(workoutStateCommand);
            commandList.Prepare();

            _pmCommunicator.Send(serialNumber, commandList);

            OperationalState?operationalState = operationalStateCommand.Value;

            if (!operationalState.HasValue)
            {
                _logger.LogWarning("Operational state is unknown.");
                return(false);
            }

            if (operationalState.Value != OperationalState.Ready &&
                operationalState.Value != OperationalState.Workout)
            {
                return(false);
            }

            WorkoutState?workoutState = workoutStateCommand.Value;

            if (!workoutState.HasValue)
            {
                _logger.LogWarning("Workout state is unknown.");
                return(false);
            }

            return(workoutState.Value == WorkoutState.WaitingToBegin);
        }
 public override void CorrectionSequence(ICommandList command)
 {
     base.CorrectionSequence(command);
     if (Type == eTypeObjectStream.AsynchronousStop)
     {
         for (int i = IndexEvent - 1; i > 0 && Parent[TypeCollection][i].Type != eTypeObjectStream.AsynchronousStart &&
              Parent[TypeCollection][i].Type != eTypeObjectStream.Asynchronous; i--)
         {
             Parent[TypeCollection][i].IsChange = true;
             command.Add(new SetObjectCommand(((Command)command).Document, Parent, TypeCollection, i, eTypeObjectStream.Asynchronous));
         }
     }
     if (Next != null && Next.IsChange == false)
     {
         if (Old.Type == eTypeObjectStream.Asynchronous && Type != eTypeObjectStream.AsynchronousStart)
         {
             Next.IsChange = true;
             command.Add(new ClearObjectCommand(((Command)command).Document, Parent, TypeCollection, Next.IndexEvent));
         }
         else if (Old.Type == eTypeObjectStream.AsynchronousStart && Type != eTypeObjectStream.AsynchronousStart &&
                  (Next.Type == eTypeObjectStream.Asynchronous || Next.Type == eTypeObjectStream.AsynchronousStop))
         {
             Next.IsChange = true;
             command.Add(new ClearObjectCommand(((Command)command).Document, Parent, TypeCollection, Next.IndexEvent));
         }
     }
     if (Prev != null && Prev.IsChange == false)
     {
         if ((Old.Type == eTypeObjectStream.AsynchronousStop || Old.Type == eTypeObjectStream.Asynchronous) &&
             Prev.Type == eTypeObjectStream.Asynchronous && Type != eTypeObjectStream.Asynchronous && Type != eTypeObjectStream.AsynchronousStop)
         {
             Prev.IsChange = true;
             command.Add(new SetObjectCommand(((Command)command).Document, Parent, TypeCollection, Prev.IndexEvent, eTypeObjectStream.AsynchronousStop));
         }
     }
 }
        /// <summary>
        /// Метод CommandProcessing() обрабатывает комманды пользователя.
        /// </summary>
        /// <param name="command">Наименование комманды передается в качестве параметра command.</param>
        /// <param name="myList">Пользовательский список передается в качестве параметра myList.</param>
        public static void CommandProcessing(string command, ICommandList <string> myList)
        {
            var commandArgs = command.Split();

            switch (commandArgs[0])
            {
            case "1":
                myList.Add(commandArgs[1]);
                break;

            case "2":
                myList.Remove(int.Parse(commandArgs[1]));
                break;

            case "3":
                Console.WriteLine(myList.Contains(commandArgs[1]));
                break;

            case "4":
                myList.Swap(int.Parse(commandArgs[1]), int.Parse(commandArgs[2]));
                break;

            case "5":
                Console.WriteLine(myList.CountGreaterThan(commandArgs[1]));
                break;

            case "6":
                Console.Write("Maximum element in the list: ");
                Console.WriteLine(myList.Max());
                break;

            case "7":
                Console.Write("Minimum element in the list: ");
                Console.WriteLine(myList.Min());
                break;

            case "8":
                myList.Print();
                break;

            default:
                break;
            }
        }
        /// <summary>
        /// Gets the current workout state for a specified location
        /// </summary>
        /// <param name="serialNumber">The serial number</param>
        /// <returns>The current workout state</returns>
        private WorkoutState?GetWorkoutState(string serialNumber)
        {
            ICommandList commands = _commandListFactory.Create();

            commands.Add(new GetWorkoutStateCommand());
            commands.Prepare();

            try
            {
                _pmCommunicator.Send(serialNumber, commands);
            }
            catch (Exception e)
            {
                _logger.LogWarning(e, "Error occurred while checking workout state prior to polling");
                return(WorkoutState.WaitingToBegin);
            }

            return(commands.FirstOrDefault()?.Value);
        }