private void ExecuteOpenChronographLinkCommand() { _writer.WriteLine(_chronograph.GetName()); _writer.WriteLine(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")); IsSerialPortOpened = _serialPortManager.Open(Chronograph, ComPort); }
public ReturnData PrepareTransaction() { Trace.WriteLine(string.Format("{0} PrepareTransaction(): Call", DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff"))); ReturnData returnData = new ReturnData { ReturnCode = ReturnCode.Successful }; try { if (!_serialPort.IsOpen) { _serialPort.Open(_portName); Thread.Sleep(300); } if (!IsReaderOnIdle()) { Trace.WriteLine("0"); _serialPort.WriteAndReadMessage(PktType.STX, "T6C", "", out string t6Cresponse, false); Trace.WriteLine("1"); } // Setting Timeout for Transaction int timeout = _parameterHandler.GetTimeoutPeriod(); _serialPort.WriteAndReadMessage(PktType.STX, "V09", Convert.ToChar(0x1A).ToString() + timeout.ToString(), out string v09response); if (!v09response.ToUpper().Equals("V0A0")) { throw new Exception(v09response); } } catch (Exception ex) { Trace.WriteLine(string.Format("{0} Exception: {1}", DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff"), ex.Message)); returnData.ReturnCode = ReturnCode.Error; returnData.ReturnCodeSpecified = true; } Trace.WriteLine(string.Format("{0} PrepareTransaction(): Return", DateTime.Now.ToString("yyyyMMdd HH:mm:ss.fff"))); return(returnData); }
public WebService1() { _parameterHandler = new ParameterHandler(); _debugLogHandler = new DebugLogHandler(); _serialPort = SerialPortManager.Instance; _buadrate = Int32.Parse(ConfigurationManager.AppSettings["buadrate"]); _portName = ConfigurationManager.AppSettings["portName"]; if (!_serialPort.IsOpen) { _serialPort.Open(_portName); } stackTrace = new StackTrace(); }
private void cbbserialport_SelectedIndexChanged(object sender, EventArgs e) { try { serialPortManager.SetComPortManual(cbbserialport.SelectedItem.ToString()); serialPortManager.SetComSpeedManual(1000000); serialPortManager.Open(); btnFire.Enabled = true; } catch { btnFire.Enabled = false; MessageBox.Show("Can't open the COM port", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }