Esempio n. 1
0
        public PortController()
        {
            if (isLive)
            {
                SerialPort port = connectLaserCamera();

                //No lasercamera found, init emulator
                if (port == null || !port.IsOpen)
                {
                    isLive = false;
                    InitEmulator();
                    return;
                }

                Thread readThread   = new Thread(() => { readPort  = new ReadPort(this, port); });
                Thread writeThread  = new Thread(() => { writePort = new WritePort(port); });
                readThread.Start();
                writeThread.Start();

                readThread.Join();
                writeThread.Join();

                writePort.stopMeasurement();

                while (!readPort.lastCommandReceived.Equals("me"))
                {
                    // wait for settings
                    Thread.Sleep(100);
                    getSettings();
                }

                //Turn pilotlaser off at start if it is on.
                /*if(PilotLaser != 0)
                {
                    PilotLaser = 0;
                }*/
                PilotLaser = 0;
                measurementIndex = laserCameraSettingsModule.getMeasurementIndex();
                initializeMeasurement();
            }
            else
            {
                InitEmulator();
            }
        }
Esempio n. 2
0
 public PortEmulator(ReadPort readPort, PortController portController)
 {
     this.readPort = readPort;
     this.portController = portController;
 }
Esempio n. 3
0
        private void InitEmulator()
        {
            Thread readThread = new Thread(() => { readPort = new ReadPort(this); });
            Thread writeThread = new Thread(() => { writePort = new WritePort(); });
            readThread.Start();
            writeThread.Start();

            readThread.Join();
            writeThread.Join();
            portEmulator = new PortEmulator(readPort, this);

            getSettings();
            initializeMeasurement();
        }