Ejemplo n.º 1
0
        /// <summary>
        /// Connect and disconnect command execute.
        /// </summary>
        /// <param name="obj">The obj.</param>
        private void ConnectDisconnectCommandExecute(object obj)
        {
            if (!IsConnected)
            {
                try
                {
                    _hartCommunication.Initialize(_settingsViewModel.SettingsDataModel.ComPort);
                    OpenResult result = _hartCommunication.Open();

                    switch (result)
                    {
                    case OpenResult.UnknownComPortError:
                        _messageBoxService.ShowError("Unknown COM port error while connecting to device.", "Error");
                        return;

                    case OpenResult.ComPortNotExisting:
                        _messageBoxService.ShowError("Selected COM port does not exists.", "Error");
                        return;

                    case OpenResult.ComPortIsOpenAlreadyOpen:
                        _messageBoxService.ShowError("COM port is already opened.", "Error");
                        return;
                    }

                    _hartCommunication.PreambleLength  = Convert.ToInt32(_settingsViewModel.SettingsDataModel.Preamble);
                    _hartCommunication.Receive        += ReceiveValueHandle;
                    _hartCommunication.SendingCommand += SendingValueHandle;

                    IsConnected = true;
                }
                catch (Exception e)
                {
                    _messageBoxService.ShowError("Error on connecting to device.\n\n" + e, "Error");
                }
            }
            else
            {
                try
                {
                    CloseResult result = _hartCommunication.Close();

                    switch (result)
                    {
                    case CloseResult.PortIsNotOpen:

                        _messageBoxService.ShowError("The port is not open.", "Error");
                        return;
                    }

                    IsConnected = false;

                    _hartCommunication.Receive        -= ReceiveValueHandle;
                    _hartCommunication.SendingCommand -= SendingValueHandle;
                }
                catch (Exception e)
                {
                    _messageBoxService.ShowError("Error on disconnecting from device.\n\n" + e, "Error");
                }
            }
        }
        public UWPContentDialog(string _description)
        {
            this.InitializeComponent();

            txtDescription.Text = _description;
            newName             = "";

            dialogResult = CloseResult.CANCEL;
        }
Ejemplo n.º 3
0
        public void Close(CloseResult result)
        {
            _window.Close();

            if (_onClosed != null)
            {
                _onClosed.Invoke(result);
            }
        }
        public async Task <IActionResult> Close(Guid accountId)
        {
            var command = new CloseCommand(accountId);

            CloseResult closeResult = await closeService.Process(command);

            if (closeResult == null)
            {
                return(new NoContentResult());
            }

            return(Ok());
        }
Ejemplo n.º 5
0
        public void Usage()
        {
            const string PORT_NAME = "COM1";

            HartCommunicationLite communication = new HartCommunicationLite(PORT_NAME);

            OpenResult openResult = communication.Open();

            Assert.That(openResult, Is.EqualTo(OpenResult.Opened));

            CloseResult closeResult = communication.Close();

            Assert.That(closeResult, Is.EqualTo(CloseResult.Closed));
        }
Ejemplo n.º 6
0
        public CloseResult CloseCard()
        {
            var res = new CloseResult();

            try
            {
                res.Result      = CloseCardExternal();
                res.ErrorString = GetErrorString(res.Result);
            }
            catch (Exception ex)
            {
                res.ErrorString = ex.Message;
            }

            return(res);
        }
        private void ContentDialog_PrimaryButtonClick(ContentDialog sender, ContentDialogButtonClickEventArgs args)
        {
            newName = txtEntry.Text.Trim();

            dialogResult = CloseResult.OK;
        }