Example #1
0
 //FILE SAVING
 static public void SaveDATA(LoggerState settings, ref string filepath, DATA concatdata)
 {
     try
     {
         using (System.IO.StreamWriter file = new System.IO.StreamWriter(filepath))
         {
             int    line_number = 0;
             string str;
             while (true)
             {
                 str = "";
                 if (IO.GetLine_Num(settings, concatdata, line_number++, ref str, ",") == 0)
                 {
                     break;
                 }
                 file.WriteLine(str);
             }
             ;
             //File automatically closes with using (don't manually close!)
         }
     }
     catch
     {
         throw;
     }
 }
Example #2
0
        public static int GetLineId_Num(LoggerState settings, List <int> data, int line_number, ref string visitor, string delimiter)
        {
            if (line_number < settings.n_samples)
            {
                int start = line_number * settings.n_channels;
                int end   = start + settings.n_channels;

                //Separate new data from existing data
                if (visitor.Length != 0)
                {
                    visitor += delimiter;
                }

                //Add to existing
                List <string> str = new List <string>();
                for (int i = start; i < end; i++)
                {
                    str.Add(data[i].ToString());
                }
                visitor += string.Join(delimiter, str.ToArray());
                return(1);
            }

            return(0);
        }
Example #3
0
        private void button3_Click(object sender, EventArgs e)
        {
            Dictionary <string, string> dict = LoggerState.MergeDictionary(settings);

            string text = String.Join("}\n{", dict.Keys.ToArray());

            MessageBox.Show("{" + text + "}");
        }
Example #4
0
        public static string GetFilePathTemp(LoggerState settings)
        {
            string timestamp = Environment.TickCount.ToString();
            string path      = settings.testpath + @"\temp" + timestamp;

            settings.temp_filename = path;
            return(path);
        }
Example #5
0
        public UserSettings(LoggerState settings)
        {
            this.settings = settings;

            InitializeComponent();

            cbTesting.Checked = settings.testingmode;
            tbFileFormat.Text = settings.datafileformat;
        }
Example #6
0
        public void SetupTimedSample(LoggerState settings)
        {
            /*
             * //resolution (works) (12/16bit)
             * aio.GetAiResolution(id, out AiResolution);
             * maxbytes = Math.Pow(2, AiResolution);
             *
             * //Doesn't work on 1664LAX
             * aio.SetAiRangeAll(1,CaioConst.P025)
             *
             * //Doesn't work (reads 1)
             * short nC1;
             * aio.GetAiChannels(id, out nC1);
             *
             * //is this a mapping?
             * string map = "";
             * AiChannelSeq = new short[nChannel];
             * for (short i = 0; i < nChannel; i++)
             * {
             *  aio.GetAiChannelSequence(id, i, out AiChannelSeq[i]);
             *  map += AiChannelSeq[i].ToString() + ",";
             * }
             */

            //Setting the
            foreach (DEVICEID id in devices)
            {
                HANDLE_RETURN_VALUES = aio.SetAiChannels(id, settings.n_channels);
                HANDLE_RETURN_VALUES = aio.SetAiSamplingClock(id, settings.timer_interval); //default usec (2000 for)
                HANDLE_RETURN_VALUES = aio.SetAiStopTimes(id, settings.n_samples);
                HANDLE_RETURN_VALUES = aio.SetAiEventSamplingTimes(id, DATA_RECEIVE_EVENT); //#samples until data retrieve event

                HANDLE_RETURN_VALUES = aio.SetAiTransferMode(id, 0);                        //Device buffered 1=sent to user memory
                HANDLE_RETURN_VALUES = aio.SetAiMemoryType(id, 0);                          //FIFO 1=Ring

                if (settings.external_control)
                {
                    HANDLE_RETURN_VALUES = aio.SetAiStartTrigger(id, 1);                //1 by External trigger rising edge
                }
                else
                {
                    HANDLE_RETURN_VALUES = aio.SetAiStartTrigger(id, 0);                //0 by Software
                }

                if (settings.external_control)
                {
                    HANDLE_RETURN_VALUES = aio.SetAiClockType(id, 1);                   //external
                }
                else
                {
                    HANDLE_RETURN_VALUES = aio.SetAiClockType(id, 0);                   //internal
                }

                HANDLE_RETURN_VALUES = aio.SetAiStopTrigger(id, 0);                     //0 means by time
            }
        }
Example #7
0
        public static int GetLine_Num(LoggerState settings, DATA concatdata, int line_number, ref string visitor, string delimiter = ",")
        {
            int num = 0;

            foreach (KeyValuePair <DEVICEID, List <int> > device_data in concatdata)
            {
                num += IO.GetLineId_Num(settings, device_data.Value, line_number, ref visitor, delimiter);
            }
            return(num);
        }
Example #8
0
 public static string GetFilePathTest(LoggerState settings, string datafileformat, string extension)
 {
     //TODO: chekc its a valid filename
     return(LoggerState.MergeObjectToString(settings, datafileformat) + "." + extension);
 }
Example #9
0
 public static string GetFilePathCal(LoggerState settings, int idx)
 {
     return(settings.testpath + @"\" + cal_enum[idx] + ".cal");
 }