Пример #1
0
        public Form1()
        {
            try
            {
                initTime = DateTime.Now;
                //Calls calculation method for filters
                highCoeff     = filterCoeff(double.Parse(ConfigurationManager.AppSettings.Get("angleHighPass")), sampFreq / bufferSize, "High");
                lowCoeff      = filterCoeff(double.Parse(ConfigurationManager.AppSettings.Get("angleLowPass")), sampFreq / bufferSize, "Low");
                bandHighCoeff = filterCoeff(double.Parse(ConfigurationManager.AppSettings.Get("velocityHighPass")), sampFreq / bufferSize, "High");
                bandLowCoeff  = filterCoeff(double.Parse(ConfigurationManager.AppSettings.Get("velocityLowPass")), sampFreq / bufferSize, "Low"); //2*10^-2

                InitializeComponent();                                                                                                            // Initializes the visual components
                SetSize();                                                                                                                        // Sets up the size of the window and the corresponding location of the components
                Frameco     = 0;
                dayFrameCo0 = DayNr.GetDayNr(DateTime.Now);

                //Initialization of TwinCAT connection. 851 is the port for PLC runtime 1

                if (twinCatBool)
                {
                    tcAds.Connect(851);
                }

                myStopwatch          = new Stopwatch();
                dataWritingSyncEvent = new SyncEvents();

                consumerd    = new DataConsumerDelegate[2];
                consumerd[0] = new DataConsumerDelegate(new DataConsumerDelegate.outputDelegate(showStatistics), true);
                consumerd[1] = new DataConsumerDelegate(new DataConsumerDelegate.outputDelegate(Pattern), true);
                consumerd[1].myThread.Priority = ThreadPriority.Highest;
                for (int i = 0; i < consumerd.Length; i++)
                {
                    consumerd[i].myThread.Start();
                }
                dataWritingQueue = new Queue <PeakQueueItem>();

                dataWritingThreadBool      = true;
                dataWritingThread          = new Thread(dataWrite);
                dataWritingThread.Priority = ThreadPriority.Highest;
                dataWritingThread.Start();
                Thread.Sleep(10);

                cameraThread          = new Thread(initCamera);
                cameraThread.Priority = ThreadPriority.Highest;
                cameraThread.Start();
                curDirec = System.IO.Path.GetDirectoryName(Application.ExecutablePath);
                System.Diagnostics.Process.Start(curDirec + "\\AffinitySet.bat");
            }
            catch (System.Threading.ThreadAbortException) { }
            catch (Exception ex)
            {
                EmailError.emailAlert(ex);
                throw (ex);
            }
        }
Пример #2
0
 private void buRecord_Click(object sender, EventArgs e)
 {
     if (recordBool == false)
     {
         Frameco       = 0;
         dayFrameCo0   = DayNr.GetDayNr(DateTime.Now);
         buRecord.Text = "Stop Recording";
         myDataWriter  = new DataWriting();
         recordBool    = true;
     }
     else
     {
         buRecord.Text = "Record to Disk";
         recordBool    = false;
         myDataWriter.stopit();
     }
 }