示例#1
0
 private void buttonSaveData_Click(object sender, EventArgs e)
 {
     SaveMeasurementsToCSVClass.Save(selectedHeader, values, selectedHeader.channel);
 }
 private void buttonSaveData_Click(object sender, EventArgs e)
 {
     SaveMeasurementsToCSVClass.Save(selectedHeader, valuesCH0, 0);
     SaveMeasurementsToCSVClass.Save(selectedHeader, valuesCH1, 1);
 }
示例#3
0
        private void MultiSuccess35A(List <byte[]> list)
        {
            Invoke((MethodInvoker) delegate
            {
                labelMultiDownload.Text      = "Success!";
                labelMultiDownload.ForeColor = System.Drawing.Color.Green;
                const string delimiter       = "\r\n";
                Console.WriteLine("Success from MULTI");
                //string path = AppDomain.CurrentDomain.BaseDirectory;
                string filenameCH0;
                string filenameCH1;
                string midleFix = textBoxDataDownloadCapacitorDescription35A.Text;
                int[] valuesCH0, valuesCH1;
                MeasurementHeaderClass selectedHeader;
                string[] postFixes = { "_R", "_C" };
                int postFixIndex   = 0;


                FolderBrowserDialog dialog = new FolderBrowserDialog();
                dialog.SelectedPath        = defaultPath;
                if (dialog.ShowDialog() == DialogResult.OK)
                {
                    defaultPath = dialog.SelectedPath + "\\";
                }
                else
                {
                    // If no folder is selected just abort everything :(
                    labelMultiDownload.Text      = "Canceled!";
                    labelMultiDownload.ForeColor = System.Drawing.Color.Black;
                    return;
                }


                foreach (var item in list)
                {
                    ByteArrayDecoderClass dec = new ByteArrayDecoderClass(item);
                    // Extract data len without header (2 measurements are stored in raw thats why / 4)
                    int dataLen = (dec.Get2BytesAsInt() - ConfigClass.HEADER_LENGTH) / 4;

                    // Remove header from data packet
                    selectedHeader               = new MeasurementHeaderClass(0); // Dummy address
                    selectedHeader.timestamp     = dec.Get6BytesAsTimestamp();
                    selectedHeader.prescaler     = dec.Get4BytesAsInt();
                    selectedHeader.numOfPoints   = dec.Get2BytesAsInt();
                    selectedHeader.operatingMode = dec.Get1ByteAsInt();
                    selectedHeader.channel       = dec.Get1ByteAsInt();

                    valuesCH0 = new int[dataLen];
                    valuesCH1 = new int[dataLen];

                    for (int i = 0; i < dataLen; i++)
                    {
                        valuesCH0[i] = dec.Get2BytesAsInt16();
                        valuesCH1[i] = dec.Get2BytesAsInt16();
                    }
                    // Values are extracted so far, now form filename

                    // Form timestamp string
                    string time = (selectedHeader.timestamp[0] + 2000).ToString() + "_" + selectedHeader.timestamp[1].ToString() + "_" +
                                  selectedHeader.timestamp[2].ToString() + "__" + selectedHeader.timestamp[3].ToString() + "-" +
                                  selectedHeader.timestamp[4].ToString() + "-" + selectedHeader.timestamp[5].ToString();
                    //string channel = SupercapHelperClass.ConvertChannelToSymbolicString(selectedHeader.channel);

                    filenameCH0 = "dev" + ConfigClass.deviceAddr + "_" + midleFix + "_" + time + "_" + "CH0" + postFixes[postFixIndex];
                    filenameCH1 = "dev" + ConfigClass.deviceAddr + "_" + midleFix + "_" + time + "_" + "CH1" + postFixes[postFixIndex];
                    SaveMeasurementsToCSVClass.Save(valuesCH0, 0, defaultPath + filenameCH0 + ".csv", delimiter);
                    SaveMeasurementsToCSVClass.Save(valuesCH1, 1, defaultPath + filenameCH1 + ".csv", delimiter);
                    postFixIndex++;
                }
            }
                   );

            Console.WriteLine("All Done!!!!");
        }