Esempio n. 1
0
        private void StartButton_Click(object sender, EventArgs e)
        {
            SenderThread.Start();
            phidgetReciver.Start();
            arduinoReciver.Start();
            arduinoSender.Start();
            motionCalculator.Start();
            dataExchanger.Start();
            DataExchangerThread.Start();
            StartButton.Enabled = false;
            //var sw = System.IO.File.AppendText("c:\\tmp\\runlog.csv");
            for (int i = 0; i < listOfKHEdits.Count; i++)
            {
                listOfKHEdits[i].Text = motionCalculator.getSetupAt(i).KoeffH.ToString();
                listOfKVEdits[i].Text = motionCalculator.getSetupAt(i).KoeffV.ToString();
            }
            while (!abort)
            {
                for (int i = 0; i < phidgetReciver.Count(); i++)
                {
                    listOfLEdits[i].Text = (motionCalculator.getSetupAt(i).Load- motionCalculator.getSetupAt(i).ZeroLoad).ToString("#.##");
                    listOfPEdits[i].Text = arduinoReciver.getValueOf(i).ToString("000");
                    listOfTEdits[i].Text = motionCalculator.getSetupAt(i).Direction + motionCalculator.getSetupAt(i).Torque.ToString("#.##");
                    listOfSEdits[i].Text = (motionCalculator.getSetupAt(i).KoeffHSign * motionCalculator.getSetupAt(i).CurKoeffH).ToString("#.##");
                }
                //sw.WriteLine(motionCalculator.getSetupAt(4).LastDiff + "," + phidgetReciver.getValueOf(4).ToString() + "," + motionCalculator.getSetupAt(4).Torque.ToString("#.##")+","+ motionCalculator.getSetupAt(5).LastDiff + "," + phidgetReciver.getValueOf(5).ToString() + "," + motionCalculator.getSetupAt(5).Torque.ToString("#.##"));
                //Thread.Sleep(10);
                Application.DoEvents();
            }
            //sw.Close();

        }
Esempio n. 2
0
        public void ThreadRun()
        {
            initializeExchanger();
            System.Diagnostics.Trace.WriteLine("DataExchanger started");

            while (!abort)
            {
                while (!abort)
                {
                    for (int i = 0; i < phidgetReciver.Count(); i++)
                    {
                        motionCalculator.getSetupAt(i).Load     = phidgetReciver.getValueOf(i);
                        motionCalculator.getSetupAt(i).Position = arduinoReciver.getValueOf(i);
                        arduinoSender.setValueOf(i, motionCalculator.getSetupAt(i).Torque, motionCalculator.getSetupAt(i).Direction);
                    }
                }
            }

            System.Diagnostics.Trace.WriteLine("DataExchanger stopped");
        }