public mainApp() { InitializeComponent(); InitializeColorsSyringe(); decoder = new ProgressDecoder(syringe); communication = Communication.createCommunicationManager(serialPort, decoder); decoder.NewPositionArrived += new EventHandler <DecoderArgs>(newPosEvent); decoder.StartPosArrived += new EventHandler <DecoderArgs>(startPosEvent); decoder.SyringeStoppedArrived += new EventHandler <DecoderArgs>(stoppedEvent); decoder.HomingDoneArrived += new EventHandler <DecoderArgs>(homingDoneEvent); decoder.BolusDoneArrived += new EventHandler <DecoderArgs>(bolusDoneEvent); t = new System.Timers.Timer(); t.Interval = 25; t.AutoReset = true; t.Elapsed += new ElapsedEventHandler(getData); arduino = new ArduinoConnectionManager(); arduino.ConnectionChanged += new EventHandler <ConnectionArgs>(connectionChanged); baseConnector = SyringesBaseConnector.getInstance(); }
/// <summary> /// Create New Syringe Form. /// </summary> /// <param ID="id"> /// Id of new syringe to create /// </param> /// <param Decoder="d"></param> public NewSyringe(int id, ProgressDecoder d) { InitializeComponent(); initColors(); decoder = d; connector = SyringesBaseConnector.getInstance(); newSyringe = new Syringe() { ID = id }; this.ok_btn.DialogResult = DialogResult.OK; t = new System.Timers.Timer(); t.Interval = 25; t.Elapsed += new ElapsedEventHandler(getData); t.AutoReset = true; communication = Communication.getCommunicationManager(); speed_cmb.SelectedIndex = 0; decoder.NewPositionArrived += new EventHandler <DecoderArgs>(newPositionEvent); decoder.HomingDoneArrived += new EventHandler <DecoderArgs>(homeDoneEvent); }
/// <summary> /// Create and return Communication instance. /// </summary> /// <param SerialPort="serialPort"> /// SerialPort object used in main thread. /// </param> /// <returns> /// <see cref="Communication"/> instance. /// </returns> public static Communication createCommunicationManager(SerialPort serialPort, ProgressDecoder d) { if (instance == null) { instance = new Communication(); serial = serialPort; serial.DataReceived += new SerialDataReceivedEventHandler(dataReceived); decoder = d; } return(instance); }