示例#1
0
        public async Task <IActionResult> OnPostSave([FromBody] SavePositionCommand command)
        {
            try
            {
                List <SearchedPosition> dbResult = new List <SearchedPosition>();
                dbResult = await Mediator.Send(command);

                return(new JsonResult(new UIResult()
                {
                    Data = new { list = dbResult },
                    Status = UIStatus.Success,
                    Text = "بست موفقانه ثبت سیستم شد",
                    Description = string.Empty
                }));
            }
            catch (Exception ex)
            {
                return(new JsonResult(CustomMessages.FabricateException(ex)));
            }
        }
示例#2
0
        public MainWindowViewModel()
        {
            controllerSequencer = new ControllerSequencer(Properties.Settings.Default.RoboAddress, new ControllerConfiguration(), new ApplicationConfiguration()
            {
                ApplicationName = "RoboterApp"
            });
            this.PositionNames = new ObservableCollection <string>(this.controllerSequencer.GetPositionNames());

            BackwardForwardPositionController = controllerSequencer.ConfigureMotorPositionController(new MotorConfiguration
            {
                Motor = Motor.Two,
                ReferencingDirection            = Direction.Left,
                ReferencingSpeed                = Speed.Maximal,
                ReferencingFinePositioningSpeed = Speed.Slow,
                ReferencingInput                = DigitalInput.Two,
                ReferencingInputState           = false,
                Limit = 700
            });
            MoveBackwardCommand = new ContinuousMoveAxisCommand(this.BackwardForwardPositionController, Direction.Left);
            MoveForwardCommand  = new ContinuousMoveAxisCommand(this.BackwardForwardPositionController, Direction.Right);

            UpDownPositionController = controllerSequencer.ConfigureMotorPositionController(new MotorConfiguration
            {
                Motor = Motor.Three,
                ReferencingDirection            = Direction.Left,
                ReferencingSpeed                = Speed.Fast,
                ReferencingFinePositioningSpeed = Speed.Slow,
                ReferencingInput                = DigitalInput.Three,
                ReferencingInputState           = false,
                Limit = 2000
            });
            MoveUpCommand   = new ContinuousMoveAxisCommand(this.UpDownPositionController, Direction.Left);
            MoveDownCommand = new ContinuousMoveAxisCommand(this.UpDownPositionController, Direction.Right);

            TurnLeftRightPositionController = controllerSequencer.ConfigureMotorPositionController(new MotorConfiguration
            {
                Motor = Motor.One,
                ReferencingDirection            = Direction.Right,
                ReferencingSpeed                = Speed.Average,
                ReferencingFinePositioningSpeed = Speed.Slow,
                ReferencingInput                = DigitalInput.One,
                ReferencingInputState           = false,
                Limit = 2200
            });
            TurnLeftCommand  = new ContinuousMoveAxisCommand(this.TurnLeftRightPositionController, Direction.Left);
            TurnRightCommand = new ContinuousMoveAxisCommand(this.TurnLeftRightPositionController, Direction.Right);

            OpenCloseClampPositionController = controllerSequencer.ConfigureMotorPositionController(new MotorConfiguration
            {
                Motor = Motor.Four,
                ReferencingDirection            = Direction.Left,
                ReferencingSpeed                = Speed.Quick,
                ReferencingFinePositioningSpeed = Speed.Slow,
                ReferencingInput                = DigitalInput.Four,
                ReferencingInputState           = false,
                Limit      = 15,
                IsSaveable = false
            });
            OpenClampCommand  = new ContinuousMoveAxisCommand(this.OpenCloseClampPositionController, Direction.Left);
            CloseClampCommand = new ContinuousMoveAxisCommand(this.OpenCloseClampPositionController, Direction.Right);

            ReferenceAxisCommand  = new ReferenceAxisCommand(TurnLeftRightPositionController, UpDownPositionController, BackwardForwardPositionController, OpenCloseClampPositionController);
            SavePositionCommand   = new SavePositionCommand(this.controllerSequencer, this.PositionNames);
            MoveToPositionCommand = new MoveToPositionCommand(this.controllerSequencer, this);

            this.sequenceCommandLogic = new SequenceCommandLogic(this.controllerSequencer, this.BackwardForwardPositionController, this.UpDownPositionController, this.TurnLeftRightPositionController, this.OpenCloseClampPositionController);
            StartSequenceCommand      = new StartSequenceCommand(this.sequenceCommandLogic);

            AlarmSoundCommand = new AlarmSoundCommand(controllerSequencer);

            controllerSequencer.CommunicationLoopCyleTimeChanges.Subscribe(OnCommunicationLoopCycleTimeUpdate);
            controllerSequencer.CommunicationExceptions.Subscribe(OnCommunicationLoopExcpetion);
            controllerSequencer.ControllerConnectionStateChanges.Subscribe(OnControllerConnectionStateChanged);
            controllerSequencer.CommunicationLoopBlockingEvents.Subscribe(OnCommunicationLoopBlocked);
            CurrentControllerConnectionState = controllerSequencer.CurrentlyConnectedToController;
        }