public void SetDataBlock(DataBlock db) { m_db = new DataBlock(); m_db.Copy(db); int time = 0; bool oldBit = false; for (int i = 0; i < m_db.GetChannelLength(); i++) { bool bit = m_db.GetVoltage(0,i)>10; if ( oldBit == false && bit == true ) { Process(false, time); time=0; } else if (oldBit == true && bit == false) { Process(true, time); time = 0; } else { time++; } oldBit = bit; } textBox1.Text += "histo\r\n"; List<int> keys = new List<int>(); foreach (int i in m_histo.Keys) { keys.Add(i); } keys.Sort(); foreach (int i in keys) { int v = m_histo[i]; textBox1.Text += string.Format("{0:000} {1:000} ", i, v) + "\r\n"; } }
public void SetDataBlock(DataBlock db) { m_db = new DataBlock(); m_db.Copy(db); //List<int> PeakOffsets = GetMinMax(m_db); List<int> PeakOffsets = new List<int>(); List<int> deltas = new List<int>(); PeakFinder.InitLoopThoughWave(db); int t = 0; for (; ; ) { int v = PeakFinder.LoopThoughWave(); if (v == 255) break; t = t + v; PeakOffsets.Add(t); deltas.Add(v); } db.m_Annotations = PeakOffsets.ToArray(); int offset = 0; for (; offset < deltas.Count; offset++) { if (deltas[offset] != 0) break; } if (offset >= 0) { //output.Text += string.Format("Clocked signal found: {0}\r\n", offset); string bitstream = ExtractBits(deltas); output.Text += bitstream + "\r\n"; //output.Text += string.Format("Errors as FSK: {0}\r\n", DetectFSK(bitstream)); output.Text += "\r\nText:\r\n"; output.Text += Decode4BitsToString(bitstream, false) + "\r\n"; //output.Text += string.Format("Alternating: \r\n"); //output.Text += GetBitStreamFromAlternating(bitstream) + "\r\n"; } else { output.Text += string.Format("Clocked signal not found, dumping timing values\r\n"); int last = 0; foreach (int i in PeakOffsets) { output.Text += string.Format("{0:0000}: {1}", i, i-last) + "\r\n"; last = i; } } }