public async Task <ManualControlViewModel> GetManualControlViewModel()
        {
            ManualControlViewModel manualControlViewModel = new ManualControlViewModel();

            IEnumerable <HardwareFunction> activatedValves =
                await unitOfWork.GetAll <HardwareFunction>().Where(x => x.FunctionType == HardwareFunctionType.Valve && x.IsActivated).ToListAsync();

            manualControlViewModel.IsValvesActivated = activatedValves != null && activatedValves.Any();

            IEnumerable <HardwareFunction> allSyringePumpFunctions = await unitOfWork.GetAll <HardwareFunction>()
                                                                     .Where(x => x.FunctionType == HardwareFunctionType.SyringePumpInit ||
                                                                            x.FunctionType == HardwareFunctionType.SyringePumpFin || x.FunctionType == HardwareFunctionType.SyringePumpDraw)
                                                                     .ToListAsync();

            manualControlViewModel.AllSyringePumpHardwareFunctions =
                allSyringePumpFunctions.Select(x => new ListItem()
            {
                Value = (int)x.FunctionType, Text = x.Name
            });
            manualControlViewModel.SelectedSyringePumpFunction = HardwareFunctionType.SyringePumpInit;

            IEnumerable <HardwareFunction> allGSValves = await unitOfWork.GetAll <HardwareFunction>()
                                                         .Where(x => x.FunctionType == HardwareFunctionType.GSValve)
                                                         .ToListAsync();

            manualControlViewModel.AllGSValvesHardwareFunctions =
                allGSValves.Select(x => new ListItem()
            {
                Id = x.ApiUrl, Text = x.Name
            });
            manualControlViewModel.SelectedGSValveFunction = allGSValves.First().ApiUrl;

            return(manualControlViewModel);
        }
        public ManualControl()
        {
            InitializeComponent();
            var vm = new ManualControlViewModel(
                FlightSimulatorModel.Instance.SetTelnetClient(new TelnetClient()));

            DataContext     = vm;
            Joystick.Moved += vm.Update;
        }
    private void OnConnect(object obj)
    {
        _client = new TcpClient(IP_ADDRESS, PORT);
        _client.Client.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.KeepAlive, true);
        _master   = ModbusIpMaster.CreateIp(_client);
        Connected = _client.Connected;

        ManualControlViewModel = new ManualControlViewModel(_master);
        SetupViewModel         = new SetupViewModel(_master);

        StartReadingInfo();
    }
Example #4
0
        public MainViewModel()
        {
            //Error Handling.
            _errorListViewModel = new ErrorListViewModel();

            //Printer Model.
            _printerModel = new PrinterModel();

            //Print Model.
            _printModel = new PrintModel(_printerModel);

            //Serial Communication Incoming and Outgoing Message Interpreter.
            _realTimeStatusDataModel = new RealTimeStatusDataModel(_printerModel);

            //Serial Communication.
            _serialCommunicationOutgoingMessagesModel = new SerialCommunicationOutgoingMessagesModel();
            _serialCommunicationMainModel             = new SerialCommunicationMainModel(_serialCommunicationOutgoingMessagesModel, _printerModel, _printModel, _realTimeStatusDataModel, _errorListViewModel);
            _serialMessageDisplayViewModel            = new SerialMessageDisplayViewModel();
            _serialCommunicationViewModel             = new SerialCommunicationViewModel(_serialCommunicationMainModel, _serialCommunicationOutgoingMessagesModel, _serialMessageDisplayViewModel);

            //Printer View Model.
            _printerViewModel = new PrinterViewModel(_printerModel, _serialCommunicationMainModel.SerialCommunicationCommandSetsModel);

            //Print View Model.
            _printViewModel = new PrintViewModel(_printModel, _serialMessageDisplayViewModel);

            //Real Time Status.
            _realTimeStatusSerialInterpreterModel = new RealTimeStatusSerialInterpreterModel(_serialCommunicationMainModel, _printerModel, _printerViewModel, _realTimeStatusDataModel, _errorListViewModel);
            _realTimeStatusDataViewModel          = new RealTimeStatusDataViewModel(_realTimeStatusDataModel, _printerViewModel, _serialCommunicationMainModel.SerialCommunicationCommandSetsModel, _errorListViewModel);

            //Manual Commmands and Calibration.
            _manualControlModel     = new ManualControlModel(_printerModel, _serialCommunicationOutgoingMessagesModel, _realTimeStatusDataModel, _errorListViewModel);
            _calibrationModel       = new CalibrationModel(_realTimeStatusDataModel, _printerModel, _serialCommunicationOutgoingMessagesModel, _errorListViewModel);
            _manualControlViewModel = new ManualControlViewModel(_manualControlModel, _realTimeStatusDataViewModel, _printerViewModel);
            _calibrationViewModel   = new CalibrationViewModel(_calibrationModel, _manualControlViewModel, _realTimeStatusDataViewModel, _printerViewModel);

            //GCode.
            _uploadedGCodeModel    = new GCodeModel();
            _gCodeFileManagerModel = new GCodeFileManagerModel(_uploadedGCodeModel, _errorListViewModel);
            _gCodeConverterModel   = new GCodeConverterModel(_printerModel, _printModel, _realTimeStatusDataModel, _errorListViewModel);
            _gcodeManagerViewModel = new GCodeManagerViewModel(_gCodeFileManagerModel, _gCodeConverterModel, _printViewModel);

            //Printing.
            _printExecuteViewModel = new PrintExecuteViewModel(_gcodeManagerViewModel, _realTimeStatusDataModel, _calibrationViewModel, _serialCommunicationViewModel, _serialCommunicationOutgoingMessagesModel, _serialMessageDisplayViewModel, _printViewModel);

            //Settings.
            _saveLoadViewModel = new SaveLoadViewModel(_gcodeManagerViewModel, _printerViewModel, _printViewModel, _errorListViewModel);

            //Unset Main Window.
            _unsetMainViewModel = new UnsetMainViewModel();
        }
Example #5
0
        public MainWindow()
        {
            InitializeComponent();

            ArduinoSerialPort            = new ArduinoSerialPort();
            ArduinoSerialPort.MainWindow = this;

            COMPortInfoListView.PortComboBox.SelectionChanged += PortComboBox_SelectionChanged;

            SerialCommunicationViewModel serialCommunicationViewModel = ArduinoSerialPortView.DataContext as SerialCommunicationViewModel;

            serialCommunicationViewModel.ArduinoSerialPort = ArduinoSerialPort;

            ManualControlViewModel manualControlViewModel = ManualControlView.DataContext as ManualControlViewModel;

            manualControlViewModel.ArduinoSerialPort = ArduinoSerialPort;
        }
        public async Task <JsonResult> ExecGSValveFunction(ManualControlViewModel manualControlViewModel)
        {
            try
            {
                User currentUser = manualControlService.GetCurrentUser();

                await signalHubContext.Clients.Group(currentUser.Id).addMessage(
                    new SignalMessage
                {
                    Message    = manualControlViewModel.SelectedGSValveFunction,
                    SignalType = SignalType.GSValve
                });

                return(JsonSuccess(string.Empty));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
        public async Task <JsonResult> SetSyringePump(ManualControlViewModel manualControlViewModel)
        {
            try
            {
                User currentUser = manualControlService.GetCurrentUser();

                HardwareFunction syringePumpHardwareFunction =
                    await unitOfWork.GetAll <HardwareFunction>()
                    .SingleAsync(x => x.FunctionType == manualControlViewModel.SelectedSyringePumpFunction);

                string apiUrl;
                if (manualControlViewModel.SelectedSyringePumpFunction == HardwareFunctionType.SyringePumpDraw)
                {
                    apiUrl = string.Format(syringePumpHardwareFunction.ApiUrl,
                                           manualControlViewModel.SyringePumpStepMode ? 1 : 0, manualControlViewModel.SyringePumpFlow, manualControlViewModel.SyringePumpVolume);
                }
                else
                {
                    apiUrl = string.Format(syringePumpHardwareFunction.ApiUrl,
                                           manualControlViewModel.SyringePumpStepMode ? 1 : 0, manualControlViewModel.SyringePumpFlow);
                }

                await signalHubContext.Clients.Group(currentUser.Id).addMessage(
                    new SignalMessage
                {
                    Message    = apiUrl,
                    SignalType = SignalType.SyringePump
                });

                return(JsonSuccess(string.Empty));
            }
            catch (Exception ex)
            {
                return(JsonError(ex.Message));
            }
        }
Example #8
0
 public ManualControlView()
 {
     InitializeComponent();
     viewModel   = new ManualControlViewModel();
     DataContext = viewModel;
 }
 public ManualControl()
 {
     InitializeComponent();
     vm          = new ManualControlViewModel(MyModel.Instance);
     DataContext = vm;
 }
        public async Task <ActionResult> Index()
        {
            ManualControlViewModel manualControlViewModel = await manualControlService.GetManualControlViewModel();

            return(View(manualControlViewModel));
        }
 public ManualControl()
 {
     InitializeComponent();
     DataContext = new ManualControlViewModel(new ManualControlModel(CommandsServer.Instance));
 }