/// <summary> /// Waits the until network card is up. /// </summary> /// <returns></returns> public bool WaitUntilNetworkCardIsUp(int maxWaitTimeValue = MAX_WAIT) { NetworkCardUp = false; maxWaitTime = maxWaitTimeValue; pingCounter = 0; try { StatisticalData data = ClimbSmallHill; IAsyncResult ar = data.BeginInvoke(null, null); while (!ar.IsCompleted) { Console.WriteLine("Waiting....."); Thread.Sleep(20 * IDLE_TIME); } Console.WriteLine("Wait is finished..."); Console.WriteLine("Time Taken for Network card is up ....{0}", data.EndInvoke(ar).ToString() + "..Seconds"); } finally { } return(NetworkCardUp); }
private void StatisticWriteTXT(string FileName) { using (StreamWriter sw = new StreamWriter(FileName)) { // StatisticalData [] stat = new StatisticalData[FileLenght]; StatisticalData stat1 = new StatisticalData(); string str = ""; for (int i = 0; i < FileLenght; i++) { // stat[i].K = (double) 100; str = "Frm " + i.ToString() + ";"; str = str + stat[i].mean.ToString() + ";"; str = str + stat[i].sigma.ToString() + ";"; str = str + stat[i].K.ToString() + ";"; str = str + stat[i].P.ToString() + ";"; str = str + stat[i].Z.ToString(); sw.WriteLine(str); str = ""; } // Add some text to the file. sw.WriteLine("-------------------"); sw.WriteLine("mean;sigma;K;P;Z"); // Arbitrary objects can also be written to the file. sw.Write("File Created: "); sw.WriteLine(DateTime.Now); } }
private static StatisticalDataHistogram[] CalculatePointsFrequencyFromStatistics( StatisticalData[] values, StatisticalDataHistogram[] histograms) { for (int index1 = 0; index1 < values.Length; ++index1) { StatisticalData statisticalData = values[index1]; for (int index2 = 0; index2 < histograms.Length; ++index2) { if (histograms[index2].get_TimeFrame().IsInTimeFrame((DateTime)statisticalData.Date)) { HistogramCalculator.IncrementPointFrequency(histograms[index2], (double)statisticalData.Value); } } } return(histograms); }
public void Test04() { finito = false; NetworkChange.NetworkAvailabilityChanged += new NetworkAvailabilityChangedEventHandler(NetworkChange_NetworkAvailabilityChanged); StatisticalData data = ClimbSmallHill; IAsyncResult ar = data.BeginInvoke(null, null); while (!ar.IsCompleted) { Console.WriteLine("Waiting....."); Thread.Sleep(20 * IDLE_TIME); } Console.WriteLine("Wait is finished..."); Console.WriteLine("Time Taken for climbing ....{0}", data.EndInvoke(ar).ToString() + "..Seconds"); Console.ReadLine(); Console.WriteLine("Esecuzione terminata"); NetworkChange.NetworkAvailabilityChanged -= NetworkChange_NetworkAvailabilityChanged; }
public void StatisticWrite(string FileName, string AViFileName, string TXtFileName) { // Create the new, empty data file. FileStream fs = new FileStream(FileName, FileMode.CreateNew); // Create the writer for data. BinaryWriter w = new BinaryWriter(fs); // Write data to Test.data. //Open AVI file to read all frames avi_reader.Open(AViFileName); avi_writer.Open("DSP.avi", avi_reader.width, avi_reader.height); //Recalculate stat structure to holld all frames statistis // StatisticalData [] stat = new StatisticalData[avi_reader.length]; FileLenght = avi_reader.length; stat = new StatisticalData[FileLenght]; string str = ""; StatisticalData stat1 = new StatisticalData(); //Open window to show opened frames // FormLoaded = new frmLoaded(); // FormLoaded.Show(); int count = 0; Cursor.Current = Cursors.WaitCursor; for (int i = 0; i < FileLenght; i++) { if (bmpTmp != null) { bmpTmp.Dispose(); } bmpTmp = avi_reader.GetNextFrame(); avi_writer.AddFrame(bmpTmp); imagestatistic.ImageStreamStatistic(bmpTmp); //Here we can add DSP features //Visualize frames // if (count > 10) // { // count = 0; // FormLoaded.LoadBitmap(bmpTmp); // } // count++; stat[i] = imagestatistic.StatisticDataa; stat1 = stat[i]; // str = str + ";" + i.ToString(); w.Write(stat1.mean); w.Write(stat1.sigma); w.Write(stat1.K); w.Write(stat1.P); w.Write(stat1.Z); } avi_reader.Close(); avi_writer.Close(); // FormLoaded.LoadBitmap(bmpTmp); //Close preview window // FormLoaded.Close(); // MessageBox.Show("Writed data is: " + str); str.Remove(0, str.Length); w.Close(); fs.Close(); StatisticWriteTXT(TXtFileName); }