Ejemplo n.º 1
0
 private void WriteDisplayOne(ISerialPortService pObjDisplay, string pStrPrint)
 {
     if (pObjDisplay.IsOpen())
     {
         pObjDisplay.Write(pStrPrint);
     }
     else
     {
         pObjDisplay.Open();
     }
 }
Ejemplo n.º 2
0
        public SettingsViewModel(
            IConsoleService consoleService,
            ISettingsService settingsService,
            ISerialPortService serialPortService,
            IConsoleFormatService consoleFormatService)
        {
            ConsoleService       = consoleService;
            SettingsService      = settingsService;
            SerialPortService    = serialPortService;
            ConsoleFormatService = consoleFormatService;

            OkCommand     = new RelayCommand(OkCommandImpl);
            CancelCommand = new RelayCommand(CancelCommandImpl);
            ApplyCommand  = new RelayCommand(ApplyCommandImpl);
        }
Ejemplo n.º 3
0
 public SerialCommunicationService(
     IHostingEnvironment environment,
     IConfiguration configuration,
     ILogger <SerialCommunicationService> logger,
     ISerialPortFactory serialPortFactory,
     ISerialPortService serialPortService)
 {
     this.environment       = environment;
     this.configuration     = configuration;
     this.logger            = logger;
     this.serialPortFactory = serialPortFactory;
     this.serialPortService = serialPortService;
     InitializeCommunicationPort();
     SetupBatteryLifePolling();
 }
Ejemplo n.º 4
0
 private void DisconnectDisplay(ISerialPortService pObjSerialPort)
 {
     if (pObjSerialPort != null)
     {
         lock (pObjSerialPort)
         {
             if (Connections.Count == 0 && pObjSerialPort.IsOpen())
             {
                 LogService.WriteInfo(string.Format("Desconectando puerto serial {0}...", pObjSerialPort.GetName()));
                 pObjSerialPort.Close();
                 LogService.WriteInfo(string.Format("Puerto serial {0} desconectado.", pObjSerialPort.GetName()));
             }
         }
     }
 }
Ejemplo n.º 5
0
        public WeighingMachineServerObject()
        {
            LogService.WriteInfo("Initiando constructor...");
            mObjDataReceivedDelegate = new WeighingMachineEventHandler(OnDataReceived);

            if (mObjSerialPortService == null)
            {
                mObjSerialPortService = GetSerialPortService();
                mObjSerialPortService.DataReceived += new SerialPortEventHandler(OnInternalDataReceived);
            }

            if (mLstObjConnections == null)
            {
                mLstObjConnections = new List <Guid>();
            }
        }
Ejemplo n.º 6
0
 private void ConnectDisplay(ISerialPortService pObjSerialPort)
 {
     if (pObjSerialPort != null)
     {
         LogService.WriteInfo("Puerto serial valido.");
         lock (pObjSerialPort)
         {
             if (!pObjSerialPort.IsOpen())
             {
                 LogService.WriteInfo(string.Format("Conectando puerto serial {0}...", pObjSerialPort.GetName()));
                 pObjSerialPort.Open();
                 LogService.WriteInfo(string.Format("Puerto serial {0} conectado.", pObjSerialPort.GetName()));
             }
         }
     }
 }
Ejemplo n.º 7
0
 private void InitializeDisplays()
 {
     if (Location == LocationEnum.HERMOSILLO)
     {
         mObjDisplayOneService = new SerialPortService();
     }
     else if (Location == LocationEnum.SONORA_SUR)
     {
         mObjDisplayOneService = new SerialPortService("Display1");
         mObjDisplayTwoService = new SerialPortService("Display2");
     }
     else
     {
         throw new Exception("Favor de configurar la localización de las pantallas.");
     }
 }
        public SerialPortSelectorViewModel(ISerialPortService serialPort, IWorkSituation work)
        {
            m_serialPort = serialPort;

            //PortNames = new ObservableCollection<string>(SerialPortService.GetPortNames());
            PortNames = new ObservableCollection <string>(new[] { "COM1", "COM2", "COM3", "COM4" });

            SelectedPortName = new ReactiveProperty <string>().AddTo(Disposables);
            SelectedPortName.Subscribe(n => Connect(n)).AddTo(Disposables);

            SelectedPortNameIndex       = new ReactiveProperty <int>().AddTo(Disposables);
            SelectedPortNameIndex.Value = (PortNames.Count == 1) ? 0 : -1;

            IsConnected = m_serialPort.ObserveProperty(p => p.IsOpen).ToReactiveProperty().AddTo(Disposables);
            IsBusy      = work.ObserveProperty(w => w.IsBusy).ToReactiveProperty().AddTo(Disposables);
        }
Ejemplo n.º 9
0
        public ControllerPanelViewModel(ISwitchController controller, ISerialPortService serialPort, IWorkSituation work)
        {
            m_switchController = controller;

            IsConnected = serialPort.ObserveProperty(p => p.IsOpen).ToReactiveProperty().AddTo(Disposables);
            IsBusy      = work.ObserveProperty(w => w.IsBusy).ToReactiveProperty().AddTo(Disposables);

            PushButtonCommand = new[] { IsConnected, IsBusy }.CombineLatest(x => x[0] && !x[1]).ToReactiveCommand <ButtonType?>().AddTo(Disposables);
            PushButtonCommand.Subscribe(PushButton).AddTo(Disposables);

            PushDPadCommand = new[] { IsConnected, IsBusy }.CombineLatest(x => x[0] && !x[1]).ToReactiveCommand <DPadCommand?>().AddTo(Disposables);
            PushDPadCommand.Subscribe(PushDPad).AddTo(Disposables);

            MoveStickCommand = new[] { IsConnected, IsBusy }.CombineLatest(x => x[0] && !x[1]).ToReactiveCommand <StickParameter>().AddTo(Disposables);
            MoveStickCommand.Subscribe(MoveStick).AddTo(Disposables);
        }
Ejemplo n.º 10
0
        public Session(
            IConsoleService consoleService,
            ISerialPortService serialPortService,
            ISettingsService settingsService,
            IDialogService dialogService)
        {
            // Services

            ConsoleService    = consoleService;
            SerialPortService = serialPortService;
            SettingsService   = settingsService;
            DialogService     = dialogService;


            // Commands

            StartSessionCommand = new RelayCommand(StartSessionCommandImpl);
            EndSessionCommand   = new RelayCommand(EndSessionCommandImpl);
        }
Ejemplo n.º 11
0
        public ConsoleViewModel(
            IConsoleService consoleService,
            ISerialPortService serialPortService,
            ISettingsService settingsService,
            IClipboardService clipboardService,
            IDialogService dialogService,
            IApplicationServices applicationServices,
            IWindowService windowService,
            IPrinterService printerService,
            ITaskHelpers taskHelpers)
        {
            // Services

            ConsoleService      = consoleService;
            SerialPortService   = serialPortService;
            SettingsService     = settingsService;
            ClipboardService    = clipboardService;
            DialogService       = dialogService;
            ApplicationServices = applicationServices;
            WindowService       = windowService;
            PrinterService      = printerService;
            TaskHelpers         = taskHelpers;


            // Commands

            NewSessionCommand        = new AsyncRelayCommand(NewSessionCommandImpl);
            EndSessionCommand        = new RelayCommand(EndSessionCommandImpl);
            SaveCommand              = new AsyncRelayCommand(SaveCommandImpl);
            PrintCommand             = new RelayCommand(PrintCommandImpl);
            ClearCommand             = new RelayCommand(ClearCommandImpl);
            CopyCommand              = new RelayCommand(CopyCommandImpl);
            PasteCommand             = new AsyncRelayCommand(PasteCommandImpl);
            PasteAndSendCommand      = new AsyncRelayCommand(PasteAndSendCommandImpl);
            PasteAndSendLinesCommand = new AsyncRelayCommand(PasteAndSendLinesCommandImpl);
            CutCommand       = new AsyncRelayCommand(CutCommandImpl);
            SelectAllCommand = new RelayCommand(SelectAllCommandImpl);
            QuitCommand      = new RelayCommand(QuitCommandImpl);
            SettingsCommand  = new RelayCommand(SettingsCommandImpl);

            Title = "Serial Port Utility";
        }
Ejemplo n.º 12
0
        public SessionSetupViewModel(
            IConsoleService consoleService,
            ISettingsService settingsService,
            ISerialPortService serialPortService,
            IConsoleFormatService consoleFormatService,
            IDialogService dialogService)
        {
            // Services

            ConsoleService       = consoleService;
            SettingsService      = settingsService;
            SerialPortService    = serialPortService;
            ConsoleFormatService = consoleFormatService;
            DialogService        = dialogService;

            // Commands

            StartCommand       = new RelayCommand(StartCommandImpl);
            CancelCommand      = new RelayCommand(CancelCommandImpl);
            MakeDefaultCommand = new RelayCommand(MakeDefaultCommandImpl);
        }
Ejemplo n.º 13
0
        private void WriteDisplayOne(ISerialPortService pObjDisplay, int pIntHeadsNumber, float pFlTotalWeight, float pFlAverageWeight)
        {
            string lStrHeads         = Location == LocationEnum.HERMOSILLO ? pIntHeadsNumber.ToString() : pIntHeadsNumber.ToString("00");
            string lStrTotalWeight   = Location == LocationEnum.HERMOSILLO ? pFlTotalWeight.ToString("###0") : pFlTotalWeight.ToString("00000");
            string lStrAverageWeight = Location == LocationEnum.HERMOSILLO ? pFlAverageWeight.ToString("###0.0") : pFlAverageWeight.ToString("000.0");

            LogService.WriteInfo(lStrHeads + ' ' + lStrTotalWeight + ' ' + lStrAverageWeight);
            LogService.WriteInfo(GetFormattedMessage(lStrHeads, GetPositionCode(PositionEnum.HEADS_NUMBER)));
            LogService.WriteInfo(GetFormattedMessage(lStrTotalWeight, GetPositionCode(PositionEnum.TOTAL_WEIGHT)));
            LogService.WriteInfo(GetFormattedMessage(lStrAverageWeight, GetPositionCode(PositionEnum.AVERAGE_WEIGHT)));

            pObjDisplay.Write(GetFormattedMessage(lStrHeads, GetPositionCode(PositionEnum.HEADS_NUMBER)));
            if (Location == LocationEnum.SONORA_SUR)
            {
                Thread.Sleep(800);
            }
            pObjDisplay.Write(GetFormattedMessage(lStrTotalWeight, GetPositionCode(PositionEnum.TOTAL_WEIGHT)));
            if (Location == LocationEnum.SONORA_SUR)
            {
                Thread.Sleep(800);
            }
            pObjDisplay.Write(GetFormattedMessage(lStrAverageWeight, GetPositionCode(PositionEnum.AVERAGE_WEIGHT)));
        }
Ejemplo n.º 14
0
        private void WriteDisplayTwo(ISerialPortService pObjDisplay, string pStrBatchNumber, int pIntHeadsNumber, float pFlTotalWeight, float pFlAverageWeight, string pStrBuyerNumber, decimal pDbecPrice)
        {
            string lStrBatch         = Location == LocationEnum.HERMOSILLO ? pStrBatchNumber : Convert.ToInt32(pStrBatchNumber).ToString("000");
            string lStrHeads         = Location == LocationEnum.HERMOSILLO ? pIntHeadsNumber.ToString() : pIntHeadsNumber.ToString("00");
            string lStrTotalWeight   = Location == LocationEnum.HERMOSILLO ? pFlTotalWeight.ToString("###0") : pFlTotalWeight.ToString("00000");
            string lStrAverageWeight = Location == LocationEnum.HERMOSILLO ? pFlAverageWeight.ToString("###0.0") : pFlAverageWeight.ToString("000.0");
            string lStrPrice         = Location == LocationEnum.HERMOSILLO ? (pDbecPrice > 999 ? pDbecPrice / 10 : pDbecPrice).ToString("N") : pDbecPrice.ToString("00000.00");

            LogService.WriteInfo("buyer: " + pStrBuyerNumber);

            string lStrBuyer = Location == LocationEnum.HERMOSILLO ? pStrBuyerNumber : !string.IsNullOrEmpty(pStrBuyerNumber) ? pStrBuyerNumber.Substring(0, 3) : "000";

            LogService.WriteInfo(lStrBuyer);

            if (Location == LocationEnum.HERMOSILLO)
            {
                pObjDisplay.Write(GetFormattedMessage(lStrBatch, GetPositionCode(PositionEnum.BATCH_NUMBER)));
                pObjDisplay.Write(GetFormattedMessage(lStrHeads, GetPositionCode(PositionEnum.SALE_HEADS_NUMBER)));
                pObjDisplay.Write(GetFormattedMessage(lStrTotalWeight, GetPositionCode(PositionEnum.SALE_TOTAL_WEIGHT)));
                pObjDisplay.Write(GetFormattedMessage(lStrAverageWeight, GetPositionCode(PositionEnum.SALE_AVERAGE_WEIGHT)));
                pObjDisplay.Write(GetFormattedMessage(lStrBuyer, GetPositionCode(PositionEnum.BUYER_NUMBER)));
                pObjDisplay.Write(GetFormattedMessage(lStrPrice, GetPositionCode(PositionEnum.PRICE)));
            }
            else
            {
                string lStrMessage = "Z" + GetFormattedMessage(lStrBatch, GetPositionCode(PositionEnum.BATCH_NUMBER)) +
                                     GetFormattedMessage(lStrHeads, GetPositionCode(PositionEnum.SALE_HEADS_NUMBER)) +
                                     GetFormattedMessage(lStrTotalWeight, GetPositionCode(PositionEnum.SALE_TOTAL_WEIGHT)) +
                                     GetFormattedMessage(lStrAverageWeight, GetPositionCode(PositionEnum.SALE_AVERAGE_WEIGHT)) +
                                     GetFormattedMessage(lStrBuyer, GetPositionCode(PositionEnum.BUYER_NUMBER)) +
                                     GetFormattedMessage(lStrPrice, GetPositionCode(PositionEnum.PRICE));

                LogService.WriteInfo(lStrMessage);

                pObjDisplay.Write(lStrMessage);
            }
        }
Ejemplo n.º 15
0
 public PresetClickCommand(ISerialPortService serialPort)
 {
     _serialPort = serialPort;
 }
Ejemplo n.º 16
0
 public DebugController(ISerialCommunicationService serialCommunicationService, ILogger <DebugController> logger, ISerialPortService serialPortService)
 {
     this.serialCommunicationService = serialCommunicationService;
     this.logger            = logger;
     this.serialPortService = serialPortService;
 }
        public MacroPanelViewModel(IMacroService macro, IMacroPool pool, ICanceler canceler, IWorkSituation work, ISwitchClock clock, ISerialPortService serialPort, ICancellationRequest cancelRequest, IGameCapture gameCapture)
        {
            m_macro         = macro;
            m_macroCanceler = canceler;
            m_macroPool     = pool;

            IsConnected = serialPort.ObserveProperty(p => p.IsOpen).ToReactiveProperty().AddTo(Disposables);
            IsBusy      = work.ObserveProperty(w => w.IsBusy).ToReactiveProperty().AddTo(Disposables);

            Clock       = clock.ToReactivePropertyAsSynchronized(m => m.DateTime).AddTo(Disposables);
            Clock.Value = DateTime.Now;

            DrawLotoIdCommand    = CreateExecuteMacroCommand <DrawLotoIdMacro>();
            GainWattsCommand     = CreateExecuteMacroCommand <GainWattsMacro>();
            BattleMaxRaidCommand = CreateExecuteMacroCommand <BattleMaxRaidMacro>();
            //SeekPokemonCommand = CreateExecuteMacroCommand<SeekPokemonMacro>();
            RapidTimeTravelCommand     = CreateExecuteMacroCommand <RapidTimeTravelMacro>();
            RapidTimeTravelDays        = clock.ToReactivePropertyAsSynchronized(m => m.DaysCount).AddTo(Disposables);
            RapidTimeTravelDays.Value  = 0;
            ThreeDaysTravelCommand     = CreateExecuteMacroCommand <ThreeDaysTravelMacro>();
            CanGoNextThreeDays         = (m_macroPool.Get <ThreeDaysTravelMacro>() as ThreeDaysTravelMacro).ObserveProperty(m => m.CanGoNext).ToReactiveProperty().AddTo(Disposables);
            ThreeDaysTravelNextCommand = CanGoNextThreeDays.ToReactiveCommand().AddTo(Disposables);
            ThreeDaysTravelNextCommand.Subscribe(() =>
            {
                using (var wait = new EventWaitHandle(false, EventResetMode.ManualReset, "WAIT_NEXT_3_DAYS"))
                {
                    wait.Set();
                }
            });
            MashAButtonCommand = CreateExecuteMacroCommand <MashAButtonMacro>();

            IsCanceling   = cancelRequest.ObserveProperty(c => c.IsCancellationRequested).ToReactiveProperty().AddTo(Disposables);
            CancelCommand = new[] { IsBusy, IsCanceling }.CombineLatest(x => x[0] && !x[1]).ToReactiveCommand().AddTo(Disposables);
            CancelCommand.Subscribe(m_macroCanceler.Cancel);

            SaveImageCommand = new ReactiveCommand().AddTo(Disposables);
            SaveImageCommand.Subscribe(() => gameCapture.SaveFrame(null));
        }
Ejemplo n.º 18
0
 public SerialPortConsumer(ISerialPortService serialPort)
 {
     _serialPort = serialPort;
 }
Ejemplo n.º 19
0
 private void WriteDisplayOne(ISerialPortService pObjDisplay, string pStrPrint)
 {
     pObjDisplay.Write(pStrPrint);
 }
Ejemplo n.º 20
0
 public SettingsViewModel(ISerialPortService serialPortService)
 {
     _serialPortService = serialPortService;
 }