Ejemplo n.º 1
0
        public void ConnectToDevice()
        {
            if (SelectedAvailablePort == null)
            {
                MessageBox.Show("No selected COM Port!");
            }
            else if (SelectedBaudRate == 0)
            {
                MessageBox.Show("No selected Baud Rate!");
            }
            else
            {
                SerialPortManager.Instance.BaudRate = SelectedBaudRate;
                SerialPortManager.Instance.PortName = SelectedAvailablePort;
                try
                {
                    SerialPortManager.Instance.Open();
                    SerialPortManager.Instance.DiscardInBuffer();
                    if (CTRL_udpClient == null)
                    {
                        CTRL_udpClient = new UdpClient(23400);
                        CTRL_udpClient.BeginReceive(OnCTRL_UDPReceive, null);
                    }
                    if (Ch1_udpClient == null)
                    {
                        Ch1_udpClient = new UdpClient(23410);
                        Ch1_udpClient.BeginReceive(Ch1_UDPReceive, null);
                    }
                    if (Ch2_udpClient == null)
                    {
                        Ch2_udpClient = new UdpClient(23420);
                        Ch2_udpClient.BeginReceive(Ch2_UDPReceive, null);
                    }

                    UIElementCollectionHelper.UIElementVisibilityUpdater(UIElementStateVariations.ConnectAfterClick);
                    _runningTask = true;
                    ConfigureDevice();
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.ToString());
                }
            }
        }
Ejemplo n.º 2
0
        public MeasureModeViewModel()
        {
            Thread.CurrentThread.CurrentUICulture = new CultureInfo("en-us");
            ConnectCommand    = new ConnectCommand(this);
            DisConnectCommand = new DisConnectCommand(this);
            MeasureOffCommand = new MeasureOffCommand(this);
            MeasureOnCommand  = new MeasureOnCommand(this);
            RunCommand        = new RunCommand(this);

            AvailablePorts = SerialCommunicationSettings.ListOfSerialPorts();
            BaudRates      = SerialCommunicationSettings.ListOfSerialBaudRates();
            CardTypes      = XmlFilter.Instance.GetCardTypeNames();

            UpdateTimeUI();
            UIElementCollectionHelper = new UIElementCollectionHelper(this);
            UIElementCollectionHelper.UIElementVisibilityUpdater(UIElementStateVariations.ConnectBeforeClick);

            ReadingSerialState();

            ReportDataCollector.InitializeLists();
            IsRunningNow      = GeneralMessageCollection.IsRunningStateChecker(false);
            _stopWatchTimeOut = new Stopwatch();
            this._udp         = new Udp();
        }