Exemplo n.º 1
0
 public DataExchanger(ref ArduinoReciver _arduinoReciver, ref ArduinoSender _arduinoSender, ref PhidgetReciver _phidgetReciver, ref MotionCalculator _motionCalculator)
 {
     arduinoReciver   = _arduinoReciver;
     arduinoSender    = _arduinoSender;
     phidgetReciver   = _phidgetReciver;
     motionCalculator = _motionCalculator;
 }
Exemplo n.º 2
0
        private void Form1_Load(object sender, EventArgs e)
        {

            for (int i = 0; i < MotorsCPort.Count; i++)
            {
                if (lastPort < MotorsCPort[i])
                {
                    lastPort = MotorsCPort[i];
                    SerialPort serialPort = new SerialPort();
                    serialPort.BaudRate = 115200;
                    serialPort.PortName = "COM" + MotorsCPort[i];
                    serialPort.WriteTimeout = 1000;
                    serialPort.DtrEnable = false;
                    serialPort.RtsEnable = false;
                    serialPort.Open();


                    serialPort.Write("{M0,F,0}{M1,F,0}{M2,F,0}{M3,F,0}{M4,F,0}{M5,F,0}");
                    serialPort.ReadExisting();
                    listofPorts.Add(serialPort);
                }
            }
            UdpClient udpClient = new UdpClient(8888);


            abort = false;
            arduinoSender = new ArduinoSender(ref listofPorts, ref PhToMtr);
            arduinoReciver = new ArduinoReciver(ref listofPorts,ref MtrToPh);
            udpReceiver = new UdpReceiver(ref udpClient);
            dataExchanger = new DataExchanger(ref arduinoReciver, ref arduinoSender, ref phidgetReciver, ref motionCalculator);
            PhidgetThread = new Thread(new ThreadStart(phidgetReciver.ThreadRun));
            ReciverThread = new Thread(new ThreadStart(arduinoReciver.ThreadRun));
            SenderThread = new Thread(new ThreadStart(arduinoSender.ThreadRun));
            CalculatorThread = new Thread(new ThreadStart(motionCalculator.ThreadRun));
            UDPReceiverThread = new Thread(new ThreadStart(udpReceiver.ThreadRun));
            DataExchangerThread = new Thread(new ThreadStart(dataExchanger.ThreadRun));
            System.Diagnostics.Trace.WriteLine("Before start thread");
            PhidgetThread.Name = "PhidgetThread";
            ReciverThread.Name = "ReciverThread";
            SenderThread.Name = "SenderThread";
            CalculatorThread.Name = "CalculatorThread";
            UDPReceiverThread.Name = "UDPReceiverThread";
            DataExchangerThread.Name = "DataExchangerThread";

            phidgetReciver.abort = false;
            arduinoReciver.abort = false;
            arduinoSender.abort = false;
            motionCalculator.abort = false;
            dataExchanger.abort = false;
            PhidgetThread.Start();
            ReciverThread.Start();
            CalculatorThread.Start();
            UDPReceiverThread.Start();
            {
                listOfLEdits.Add(currentLoad1);
                listOfLEdits.Add(currentLoad2);
                listOfLEdits.Add(currentLoad3);
                listOfLEdits.Add(currentLoad4);
                listOfLEdits.Add(currentLoad5);
                listOfLEdits.Add(currentLoad6);
                listOfLEdits.Add(currentLoad7);
                listOfLEdits.Add(currentLoad8);
                listOfLEdits.Add(currentLoad9);
                listOfLEdits.Add(currentLoad10);
                listOfLEdits.Add(currentLoad11);
                listOfLEdits.Add(currentLoad12);
            }
            {
                listOfPEdits.Add(currPos1);
                listOfPEdits.Add(currPos2);
                listOfPEdits.Add(currPos3);
                listOfPEdits.Add(currPos4);
                listOfPEdits.Add(currPos5);
                listOfPEdits.Add(currPos6);
                listOfPEdits.Add(currPos7);
                listOfPEdits.Add(currPos8);
                listOfPEdits.Add(currPos9);
                listOfPEdits.Add(currPos10);
                listOfPEdits.Add(currPos11);
                listOfPEdits.Add(currPos12);
            }
            {
                listOfTEdits.Add(currTorque1);
                listOfTEdits.Add(currTorque2);
                listOfTEdits.Add(currTorque3);
                listOfTEdits.Add(currTorque4);
                listOfTEdits.Add(currTorque5);
                listOfTEdits.Add(currTorque6);
                listOfTEdits.Add(currTorque7);
                listOfTEdits.Add(currTorque8);
                listOfTEdits.Add(currTorque9);
                listOfTEdits.Add(currTorque10);
                listOfTEdits.Add(currTorque11);
                listOfTEdits.Add(currTorque12);
            }
            {
                listOfSEdits.Add(totalDiff1);
                listOfSEdits.Add(totalDiff2);
                listOfSEdits.Add(totalDiff3);
                listOfSEdits.Add(totalDiff4);
                listOfSEdits.Add(totalDiff5);
                listOfSEdits.Add(totalDiff6);
                listOfSEdits.Add(totalDiff7);
                listOfSEdits.Add(totalDiff8);
                listOfSEdits.Add(totalDiff9);
                listOfSEdits.Add(totalDiff10);
                listOfSEdits.Add(totalDiff11);
                listOfSEdits.Add(totalDiff12);
            }
            {
                listOfKHEdits.Add(KoeffH1);
                listOfKHEdits.Add(KoeffH2);
                listOfKHEdits.Add(KoeffH3);
                listOfKHEdits.Add(KoeffH4);
                listOfKHEdits.Add(KoeffH5);
                listOfKHEdits.Add(KoeffH6);
                listOfKHEdits.Add(KoeffH7);
                listOfKHEdits.Add(KoeffH8);
                listOfKHEdits.Add(KoeffH9);
                listOfKHEdits.Add(KoeffH10);
                listOfKHEdits.Add(KoeffH11);
                listOfKHEdits.Add(KoeffH12);
            }
            {
                listOfKVEdits.Add(KoeffV1);
                listOfKVEdits.Add(KoeffV2);
                listOfKVEdits.Add(KoeffV3);
                listOfKVEdits.Add(KoeffV4);
                listOfKVEdits.Add(KoeffV5);
                listOfKVEdits.Add(KoeffV6);
                listOfKVEdits.Add(KoeffV7);
                listOfKVEdits.Add(KoeffV8);
                listOfKVEdits.Add(KoeffV9);
                listOfKVEdits.Add(KoeffV10);
                listOfKVEdits.Add(KoeffV11);
                listOfKVEdits.Add(KoeffV12);
            }

            this.Location = new Point(0, 0);

        }