Beispiel #1
0
 private void OnDataArrived(ComService sender, DataArrivedArgs args)
 {
     if (DataArrived != null)
     {
         DataArrived(sender, args);
     }
 }
Beispiel #2
0
 private void OnStatusChanged(ComService sender, StatusChangedArgs args)
 {
     if (StatusChanged != null)
     {
         StatusChanged(sender, args);
     }
 }
Beispiel #3
0
        public ComPanel(Window parent, ComService comService)
            : base(parent)
        {
            _comService = comService;
            _comService.DataArrived += ComDataArrived;
            _comService.StatusChanged += ComStatusChanged;

            var sizer = new BoxSizer(Orientation.Vertical);
            _dataFont = new Font(10, FontFamily.Teletype, FontStyle.Normal, FontWeight.Normal);

            Panel controlPanel = CreateControlPanel();
            sizer.Add(controlPanel, 0, SizerFlag.Expand | SizerFlag.All, 0);

            _history = new TextCtrl(this, "", WxDefaultPosition, WxDefaultSize,
                WindowStyles.TextCtrlMultiline | WindowStyles.TextCtrlReadonly)
                {
                    Font = _dataFont
                };
            sizer.Add(_history, 1, SizerFlag.Expand | SizerFlag.All, 0);

            Panel sendPanel = CreateSendPanel();
            sizer.Add(sendPanel, 0, SizerFlag.Expand | SizerFlag.All, 5);

            SetSizer(sizer);
            sizer.SetSizeHints(this);

            EvtSize((e, s) => Sizer.SetDimension(0, 0, Width, Height));
            EvtClose((e, s) => OnClose());

            DisableInput();
        }
Beispiel #4
0
        public FrontPanelPanel(MainFrame parent, ComService comService)
            : base(parent)
        {
            _comService = comService;
            _comService.DataArrived += ComDataArrived;
            FlexGridSizer sizer = new FlexGridSizer(4, 0, 0);

            sizer.Add(new StaticText(this, "External\nVoltage", WxDefaultPosition, WxDefaultSize, WindowStyles.AlignRight), 0, SizerFlag.AlignCenterVertical | SizerFlag.All, 5);
            _externalVoltage = new ValueDisplay(this) { Value = "0.0", Unit = "mV" };
            sizer.Add(_externalVoltage, 0, SizerFlag.All, 5);

            sizer.Add(new StaticText(this, "Load\nVoltage", WxDefaultPosition, WxDefaultSize, WindowStyles.AlignRight), 0, SizerFlag.AlignCenterVertical | SizerFlag.All, 5);
            _loadVoltage = new ValueDisplay(this) { Value = "0.0", Unit = "mV" };
            sizer.Add(_loadVoltage, 0, SizerFlag.All, 5);

            sizer.Add(new StaticText(this, "External\nCurrent", WxDefaultPosition, WxDefaultSize, WindowStyles.AlignRight), 0, SizerFlag.AlignCenterVertical | SizerFlag.All, 5);
            _externalCurrent = new ValueDisplay(this) { Value = "0.0", Unit = "mA" };
            sizer.Add(_externalCurrent, 0, SizerFlag.All, 5);

            sizer.Add(new StaticText(this, "Load\nCurrent", WxDefaultPosition, WxDefaultSize, WindowStyles.AlignRight), 0, SizerFlag.AlignCenterVertical | SizerFlag.All, 5);
            _loadCurrent = new ValueDisplay(this) { Value = "0.0", Unit = "mV" };
            sizer.Add(_loadCurrent, 0, SizerFlag.All, 5);

            sizer.Add(0, 0);
            sizer.Add(0, 0);

            sizer.Add(new StaticText(this, "Target\nCurrent", WxDefaultPosition, WxDefaultSize, WindowStyles.AlignRight), 0, SizerFlag.AlignCenterVertical | SizerFlag.All, 5);
            Panel targetCurrentPanel = new Panel(this);
            var targetCurrentSizer = new FlexGridSizer(2, 5, 5);
            _targetCurrentSet = new Button(targetCurrentPanel, ID_TargetCurrentSet, "Set");
            EvtButton(ID_TargetCurrentSet, (s, e) => SetTargetCurrent());
            _targetCurrent = new TextCtrl(targetCurrentPanel, "0.0mA", WxDefaultPosition, new Size(70, _targetCurrentSet.Size.Height));
            targetCurrentSizer.Add(_targetCurrent);
            targetCurrentSizer.Add(_targetCurrentSet);
            targetCurrentPanel.SetSizer(targetCurrentSizer);
            targetCurrentSizer.SetSizeHints(targetCurrentPanel);
            sizer.Add(targetCurrentPanel, 0, SizerFlag.All, 5);

            SetSizer(sizer);
            sizer.SetSizeHints(this);

            EvtDestroy((s, e) => { OnDestory(); e.Skip(true); });
            _targetCurrent.EvtSetFocus((s, e) => _targetCurrentHasFocus = true);
            _targetCurrent.EvtKillFocus((s, e) => _targetCurrentHasFocus = false);
        }
Beispiel #5
0
 private void OnStatusChanged(ComService sender, StatusChangedArgs args)
 {
     if (StatusChanged != null)
     {
         StatusChanged(sender, args);
     }
 }
Beispiel #6
0
 private void OnDataArrived(ComService sender, DataArrivedArgs args)
 {
     if (DataArrived != null)
     {
         DataArrived(sender, args);
     }
 }
Beispiel #7
0
 private void ComStatusChanged(object sender, ComService.StatusChangedArgs args)
 {
     if (args.Status == ComService.Status.Connecting || args.Status == ComService.Status.Connected)
     {
         _connect.Enabled = false;
         _port.Enabled = false;
         _baudRate.Enabled = false;
         _disconnect.Enabled = true;
         _textInput.Enabled = true;
         _send.Enabled = true;
     }
     else if (args.Status == ComService.Status.Disconnected)
     {
         DisableInput();
     }
     else
     {
         throw new Exception("Unhandled status change");
     }
 }
Beispiel #8
0
 private void ComDataArrived(object sender, ComService.DataArrivedArgs args)
 {
     if (args.PacketType != ComService.PacketType.Controller)
     {
         AppendHistory(BytesToString(args.Data));
     }
 }
Beispiel #9
0
        private void ComDataArrived(object sender, ComService.DataArrivedArgs e)
        {
            if (e.PacketType != ComService.PacketType.Controller)
            {
                return;
            }

            ComService.ControllerData controllerData = _comService.ParseControllerData(e.Data);
            SetValue(_loadCurrent, controllerData.LoadCurrentSense, "A");
            SetValue(_loadVoltage, controllerData.LoadVoltage, "V");
            SetValue(_externalCurrent, controllerData.ExternalCurrent, "A");
            SetValue(_externalVoltage, controllerData.ExternalVoltage, "V");
            if (!_targetCurrentHasFocus)
            {
                _targetCurrent.Value = _valueConverterService.ToValueWithUnits(controllerData.LoadCurrentTarget, "A");
            }
        }