Esempio n. 1
0
        private void OnButtonClick_OK(object sender, System.EventArgs e)
        {
            // create an instance of the data logger
            MccDaq.DataLogger logger = new MccDaq.DataLogger(m_SrcFilename);

            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval		:receives the sample interval (time between samples)
            //     sampleCount			:receives the sample count
            //	   startDate			:receives the start date
            //	   startTime			:receives the start time

            int sampleInterval = 0;
            int sampleCount    = 0;
            int startDate      = 0;
            int startTime      = 0;

            ULStat = logger.GetSampleInfo
                         (ref sampleInterval, ref sampleCount, ref startDate, ref startTime);
            if (ULStat.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                lblResult.Text = ULStat.Message;
                return;
            }
            // get the destination path from the source file name
            int    index          = m_SrcFilename.LastIndexOf(".");
            string m_DestFilename = m_SrcFilename.Substring(0, index + 1) + "csv" + "\0";

            //  convert the file
            //   Parameters:
            //     m_DestFilename		:destination file
            //     startSample			:first sample to convert
            //     sampleCount			:number of samples to convert
            //	   m_Delimiter			:field seperator

            int startSample = 0;

            ULStat = logger.ConvertFile(m_DestFilename, startSample, sampleCount, m_Delimiter);
            if (ULStat.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                lblResult.Text = ULStat.Message;
                return;
            }
            else
            {
                lblResult.Text = logger.FileName + " converted to " + m_DestFilename + ".";
            }
        }
Esempio n. 2
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop
            MccDaq.ErrorInfo errorInfo = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            //  Get the first file in the directory
            //   Parameters:
            //     MccDaq.GetFileOptions.GetFirst :first file
            //     m_Path						  :path to search
            //	   filename						  :receives name of file
            string	filename = new string('\0', MAX_PATH);
            errorInfo = MccDaq.DataLogger.GetFileName((int)MccDaq.GetFileOptions.GetFirst, ref m_Path, ref filename);
            string newpath = filename.TrimEnd('\0');
            string absolutePath = Path.GetFullPath(newpath);

            // create an instance of the data logger
            MccDaq.DataLogger logger = new MccDaq.DataLogger(filename);

            //  Get the file info for the first file in the directory
            //   Parameters:
            //     filename						  :file to retrieve information from
            //     version						  :receives the version of the file
            //	   size							  :receives the size of file
            int	version = 0;
            int	size = 0;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetFileInfo(ref version, ref size);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblFilename.Text = absolutePath;
                    lblFileVersion.Text = version.ToString();
                    lblFileSize.Text = size.ToString();
                }
            }

            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval					 :receives the sample interval (time between samples)
            //     sampleCount						 :receives the sample count
            //	   startDate						 :receives the start date
            //	   startTime						 :receives the start time
            int	sampleInterval = 0;
            int	sampleCount = 0;
            int	startDate = 0;
            int startTime = 0;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetSampleInfo(ref sampleInterval, ref sampleCount, ref startDate, ref startTime);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblSampleInterval.Text = sampleInterval.ToString();
                    lblSampleCount.Text = sampleCount.ToString();

                    int day = startDate & 0xff;
                    int month = (startDate>>8) & 0xff;
                    int year = (startDate>>16) & 0xffff;
                    string dateStr = month.ToString() + "/" + day.ToString() + "/" + year.ToString();
                    lblStartDate.Text = dateStr;

                    string postfix;
                    switch ((startTime >> 24) & 0xff)
                    {
                        case 0:
                            postfix = " AM";
                            break;
                        case 1:
                            postfix = " PM";
                            break;
                        case -1:
                            postfix = "";
                            break;
                        default:
                            postfix = "";
                            break;
                    }
                    int hours = (startTime>>16) & 0xff;
                    int minutes = (startTime>>8) & 0xff;
                    int seconds = (startTime) & 0xff;
                    string timeStr = hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString() + ":" + postfix;
                    lblStartTime.Text = timeStr;
                }
            }

            //  Get the ANALOG channel count for the first file in the directory
            //   Parameters:
            //     channelMask						:receives the channel mask to specify which channels were logged
            //     unitMask							:receives the unit mask to specify temp or raw data
            //	   aiChannelCount					:receives the number of AI chennels logged
            int	aiChannelCount = 0;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetAIChannelCount(ref aiChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblAIChannelCount.Text = aiChannelCount.ToString();
                }
            }

            //  Get the ANALOG info for the first file in the directory
            //   Parameters:
            //     channelMask						:receives the channel mask to specify which channels were logged
            //     unitMask							:receives the unit mask to specify temp or raw data
            int []	channelNumbers;
            int []	units;

            channelNumbers = new int[aiChannelCount];
            units = new int[aiChannelCount];
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetAIInfo(ref channelNumbers, ref units);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblChannelMask.Text = "";
                    lblUnitMask.Text = "";
                    for (int i=0; i<aiChannelCount; i++)
                    {
                        lblChannelMask.Text += channelNumbers[i].ToString();

                        if (units[i] == Convert.ToInt32(MccDaq.LoggerUnits.Raw))
                            lblUnitMask.Text += "Raw";
                        else
                            lblUnitMask.Text += "Temperature";

                        if (i < aiChannelCount - 1)
                        {
                            lblChannelMask.Text = lblChannelMask.Text + ", ";
                            lblUnitMask.Text = lblUnitMask.Text + ", ";
                        }
             					}
                }
            }

            //  Get the CJC info for the first file in the directory
            //   Parameters:
            //	   cjcChannelCount					:receives the number of CJC chennels logged
            int	cjcChannelCount = 0;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetCJCInfo( ref cjcChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblCJCChannelCount.Text = cjcChannelCount.ToString();
                }
            }

            //  Get the DIO info for the first file in the directory
            //   Parameters:
            //	   dioChannelCount					:receives the number of DIO chennels logged
            int	dioChannelCount = 0;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetDIOInfo(ref dioChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblDIOChannelCount.Text = dioChannelCount.ToString();
                }
            }

            if (errorInfo.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                MessageBox.Show(errorInfo.Message);
                return;
            }
        }
Esempio n. 3
0
        private void cmdSampInfo_Click(object sender, EventArgs e)
        {
            int    Hour, Minute, Second;
            int    Month, Day, Year;
            int    SampleInterval, SampleCount;
            int    StartDate, StartTime;
            int    Postfix;
            string PostfixStr, StartDateStr;
            string StartTimeStr;

            PostfixStr     = "";
            SampleInterval = 0;
            SampleCount    = 0;
            StartDate      = 0;
            StartTime      = 0;

            // Get the sample information
            //  Parameters:
            //    Filename            :name of file to get information from
            //    SampleInterval      :time between samples
            //    SampleCount         :number of samples in the file
            //    StartDate           :date of first sample
            //    StartTime           :time of first sample

            ULStat = logger.GetSampleInfo(ref SampleInterval, ref SampleCount, ref StartDate, ref StartTime);
            if (ULStat.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                lblComment.Text = ULStat.Message + ".";
            }
            else
            {
                //Parse the date from the StartDate parameter
                Month        = (StartDate >> 8) & 0xff;
                Day          = StartDate & 0xff;
                Year         = (StartDate >> 16) & 0xffff;
                StartDateStr = Month.ToString("00") + "/" +
                               Day.ToString("00") + "/" + Year.ToString("0000");

                //Parse the time from the StartTime parameter
                Hour    = (StartTime >> 16) & 0xffff;
                Minute  = (StartTime >> 8) & 0xff;
                Second  = StartTime & 0xff;
                Postfix = (StartTime >> 24) & 0xff;
                if (Postfix == 0)
                {
                    PostfixStr = " AM";
                }
                if (Postfix == 1)
                {
                    PostfixStr = " PM";
                }
                StartTimeStr = Hour.ToString("00") + ":" +
                               Minute.ToString("00") + ":" + Second.ToString("00")
                               + PostfixStr;

                txtResults.Text =
                    "The sample properties of '" + logger.FileName + "' are:" +
                    "\r\n" + "\r\n" + "\t" + "SampleInterval: " + "\t" +
                    SampleInterval.ToString("0") + "\r\n" + "\t" + "SampleCount: " +
                    "\t" + SampleCount.ToString("0") + "\r\n" + "\t" +
                    "Start Date: " + "\t" + StartDateStr + "\r\n" + "\t" +
                    "Start Time: " + "\t" + StartTimeStr;
            }
        }
Esempio n. 4
0
        private void frmLoggerData_Load(object sender, EventArgs e)
        {
            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.DontPrint :all warnings and errors encountered will be handled locally
            //     MccDaq.ErrorHandling.DontStop   :if an error is encountered, the program will not stop,
            //      errors will be handled locally.

            MccDaq.ErrorInfo ULStat = MccDaq.MccService.ErrHandling
                                          (MccDaq.ErrorReporting.DontPrint, MccDaq.ErrorHandling.DontStop);

            //  Get the first file in the directory
            //   Parameters:
            //     MccDaq.GetFileOptions.GetFirst :first file
            //     m_Path						  :path to search
            //	   filename						  :receives name of file
            string filename = new string(' ', MAX_PATH);

            ULStat = MccDaq.DataLogger.GetFileName
                         ((int)MccDaq.GetFileOptions.GetFirst, ref m_Path, ref filename);
            filename = filename.Trim();
            filename = filename.Trim('\0');

            // create an instance of the data logger
            logger = new MccDaq.DataLogger(filename);


            //  Set the preferences
            //    Parameters
            //      timeFormat					  :specifies times are 12 or 24 hour format
            //      timeZone					  :specifies local time of GMT
            //      units						  :specifies Fahrenheit, Celsius, or Kelvin
            MccDaq.TimeFormat timeFormat = MccDaq.TimeFormat.TwelveHour;
            MccDaq.TimeZone   timeZone   = MccDaq.TimeZone.Local;
            MccDaq.TempScale  units      = MccDaq.TempScale.Fahrenheit;
            logger.SetPreferences(timeFormat, timeZone, units);


            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval					 :receives the sample interval (time between samples)
            //     sampleCount						 :receives the sample count
            //	   startDate						 :receives the start date
            //	   startTime						 :receives the start time
            int sampleInterval = 0;
            int startDate      = 0;
            int startTime      = 0;

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                ULStat = logger.GetSampleInfo(ref sampleInterval, ref SampleCount, ref startDate, ref startTime);
            }

            //  Get the ANALOG channel count for the first file in the directory
            //   Parameters:
            //	   aiChannelCount					:receives the number of AI chennels logged
            int aiChannelCount = 0;

            if (ULStat.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                ULStat = logger.GetAIChannelCount(ref aiChannelCount);
            }
        }
Esempio n. 5
0
        private void OnButtonClick_OK(object sender, System.EventArgs e)
        {
            // create an instance of the data logger
            MccDaq.DataLogger logger = new MccDaq.DataLogger(m_SrcFilename);

            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval					 :receives the sample interval (time between samples)
            //     sampleCount						 :receives the sample count
            //	   startDate						 :receives the start date
            //	   startTime						 :receives the start time
            int	sampleInterval = 0;
            int	sampleCount = 0;
            int	startDate = 0;
            int startTime = 0;
            m_ErrorInfo = logger.GetSampleInfo(ref sampleInterval, ref sampleCount, ref startDate, ref startTime);

            // get the destination path from the source file name
            int index = m_SrcFilename.LastIndexOf(".");
            string m_DestFilename = m_SrcFilename.Substring(0, index+1) + "csv";

            //  convert the file
            //   Parameters:
            //     m_DestFilename					 :destination file
            //     startSample						 :first sample to convert
            //     sampleCount						 :number of samples to convert
            //	   m_Delimiter						 :field seperator
            int startSample = 0;
            if (m_ErrorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                m_ErrorInfo = logger.ConvertFile(m_DestFilename, startSample, sampleCount, m_Delimiter);
            }

            if (m_ErrorInfo.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                MessageBox.Show(m_ErrorInfo.Message);
                return;
            }
        }
Esempio n. 6
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop
            MccDaq.ErrorInfo errorInfo = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);

            //  Get the first file in the directory
            //   Parameters:
            //     MccDaq.GetFileOptions.GetFirst :first file
            //     m_Path						  :path to search
            //	   filename						  :receives name of file
            string	filename = new string('\0', MAX_PATH);
            errorInfo = MccDaq.DataLogger.GetFileName((int)MccDaq.GetFileOptions.GetFirst, ref m_Path, ref filename);

            // create an instance of the data logger
            MccDaq.DataLogger logger = new MccDaq.DataLogger(filename);

            //  Set the preferences
            //    Parameters
            //      timeFormat					  :specifies times are 12 or 24 hour format
            //      timeZone					  :specifies local time of GMT
            //      units						  :specifies Fahrenheit, Celsius, or Kelvin
            MccDaq.TimeFormat	timeFormat = MccDaq.TimeFormat.TwelveHour;
            MccDaq.TimeZone		timeZone = MccDaq.TimeZone.Local;
            MccDaq.TempScale	units = MccDaq.TempScale.Fahrenheit;
            logger.SetPreferences(timeFormat, timeZone, units);

            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval					 :receives the sample interval (time between samples)
            //     sampleCount						 :receives the sample count
            //	   startDate						 :receives the start date
            //	   startTime						 :receives the start time
            int	sampleInterval = 0;
            int	sampleCount = 0;
            int	startDate = 0;
            int startTime = 0;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetSampleInfo(ref sampleInterval, ref sampleCount, ref startDate, ref startTime);
            }

            //  Get the ANALOG channel count for the first file in the directory
            //   Parameters:
            //	   aiChannelCount					:receives the number of AI chennels logged
            int	aiChannelCount = 0;
            float [] aiChannelData = null;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetAIChannelCount(ref aiChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    aiChannelData = new float [sampleCount * aiChannelCount];
                }
            }

            //  Get the CJC info for the first file in the directory
            //   Parameters:
            //	   cjcChannelCount					:receives the number of CJC chennels logged
            int	cjcChannelCount = 0;
            float [] cjcChannelData = null;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetCJCInfo( ref cjcChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    cjcChannelData = new float [sampleCount * cjcChannelCount];
                }
            }

            //  Get the DIO info for the first file in the directory
            //   Parameters:
            //	   dioChannelCount					:receives the number of DIO chennels logged
            int	dioChannelCount = 0;
            int [] dioChannelData = null;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetDIOInfo(ref dioChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    dioChannelData = new int [sampleCount * dioChannelCount];
                }
            }

            //  Read the time tag information
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     dateTags							:receives the date tag information
            //     timeTags							:receives the time tag information
            int startSample = 0;
            int [] dateTags = new int [sampleCount];
            int [] timeTags = new int [sampleCount];
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadTimeTags(startSample, sampleCount, ref dateTags, ref timeTags);
            }

            //  Read the Analog data
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     aiChannelData					:receives the analog data
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadAIChannels(startSample, sampleCount, ref aiChannelData);
            }

            //  Read the CJC data
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     cjcChannelData					:receives the cjc data
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadCJCChannels(startSample, sampleCount, ref cjcChannelData);
            }

            //  Read the DIO data
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     dioChannelData					:receives the dio data
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadDIOChannels(startSample, sampleCount, ref dioChannelData);
            }

            // display the data in teh list box
            string	displayStr;
            string	dateStr;
            string	timeStr;
            string	postfix;
            int		index;

            for (int i=0; i<sampleCount; i++)
            {
                int		date = dateTags[i];
                int		time = timeTags[i];

                int day = date & 0xff;
                int month = (date>>8) & 0xff;
                int year = (date>>16) & 0xffff;
                dateStr = month.ToString() + "/" + day.ToString() + "/" + year.ToString();

                switch ((time >> 24) & 0xff)
                {
                    case 0:
                        postfix = " AM";
                        break;
                    case 1:
                        postfix = " PM";
                        break;
                    case -1:
                        postfix = "";
                        break;
                    default:
                        postfix = "";
                        break;
                }
                int hours = (time>>16) & 0xff;
                int minutes = (time>>8) & 0xff;
                int seconds = (time) & 0xff;
                timeStr = hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString() + ":" + postfix;

                displayStr = dateStr + "  " + timeStr;

                if (aiChannelCount > 0)
                {
                    index = i * aiChannelCount;
                    for (int j=0; j<aiChannelCount; j++)
                    {
                        displayStr += "\t\t" + aiChannelData[index++].ToString();
                    }
                }

                if (cjcChannelCount > 0)
                {
                    index = i * cjcChannelCount;
                    for (int j=0; j<cjcChannelCount; j++)
                    {
                        displayStr += "\t\t" + cjcChannelData[index++].ToString();
                    }
                }

                if (dioChannelCount > 0)
                {
                    index = i * dioChannelCount;
                    for (int j=0; j<dioChannelCount; j++)
                    {
                        displayStr += "\t" + dioChannelData[index++].ToString();
                    }
                }

                lbData.Items.Add(displayStr);
            }

            if (errorInfo.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                MessageBox.Show(errorInfo.Message);
                return;
            }
        }
Esempio n. 7
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop
            MccDaq.ErrorInfo errorInfo = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);


            //  Get the first file in the directory
            //   Parameters:
            //     MccDaq.GetFileOptions.GetFirst :first file
            //     m_Path						  :path to search
            //	   filename						  :receives name of file
            string filename = new string('\0', MAX_PATH);

            errorInfo = MccDaq.DataLogger.GetFileName((int)MccDaq.GetFileOptions.GetFirst, ref m_Path, ref filename);


            // create an instance of the data logger
            MccDaq.DataLogger logger = new MccDaq.DataLogger(filename);


            //  Set the preferences
            //    Parameters
            //      timeFormat					  :specifies times are 12 or 24 hour format
            //      timeZone					  :specifies local time of GMT
            //      units						  :specifies Fahrenheit, Celsius, or Kelvin
            MccDaq.TimeFormat timeFormat = MccDaq.TimeFormat.TwelveHour;
            MccDaq.TimeZone   timeZone   = MccDaq.TimeZone.Local;
            MccDaq.TempScale  units      = MccDaq.TempScale.Fahrenheit;
            logger.SetPreferences(timeFormat, timeZone, units);


            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval					 :receives the sample interval (time between samples)
            //     sampleCount						 :receives the sample count
            //	   startDate						 :receives the start date
            //	   startTime						 :receives the start time
            int sampleInterval = 0;
            int sampleCount    = 0;
            int startDate      = 0;
            int startTime      = 0;

            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetSampleInfo(ref sampleInterval, ref sampleCount, ref startDate, ref startTime);
            }


            //  Get the ANALOG channel count for the first file in the directory
            //   Parameters:
            //	   aiChannelCount					:receives the number of AI chennels logged
            int aiChannelCount = 0;

            float [] aiChannelData = null;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetAIChannelCount(ref aiChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    aiChannelData = new float [sampleCount * aiChannelCount];
                }
            }


            //  Get the CJC info for the first file in the directory
            //   Parameters:
            //	   cjcChannelCount					:receives the number of CJC chennels logged
            int cjcChannelCount = 0;

            float [] cjcChannelData = null;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetCJCInfo(ref cjcChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    cjcChannelData = new float [sampleCount * cjcChannelCount];
                }
            }


            //  Get the DIO info for the first file in the directory
            //   Parameters:
            //	   dioChannelCount					:receives the number of DIO chennels logged
            int dioChannelCount = 0;

            int [] dioChannelData = null;
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetDIOInfo(ref dioChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    dioChannelData = new int [sampleCount * dioChannelCount];
                }
            }


            //  Read the time tag information
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     dateTags							:receives the date tag information
            //     timeTags							:receives the time tag information
            int startSample = 0;

            int [] dateTags = new int [sampleCount];
            int [] timeTags = new int [sampleCount];
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadTimeTags(startSample, sampleCount, ref dateTags, ref timeTags);
            }


            //  Read the Analog data
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     aiChannelData					:receives the analog data
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadAIChannels(startSample, sampleCount, ref aiChannelData);
            }


            //  Read the CJC data
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     cjcChannelData					:receives the cjc data
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadCJCChannels(startSample, sampleCount, ref cjcChannelData);
            }


            //  Read the DIO data
            //   Parameters:
            //	   startSample						:first sample to read
            //	   sampleCount						:number of samples to read
            //     dioChannelData					:receives the dio data
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.ReadDIOChannels(startSample, sampleCount, ref dioChannelData);
            }


            // display the data in teh list box
            string displayStr;
            string dateStr;
            string timeStr;
            string postfix;
            int    index;

            for (int i = 0; i < sampleCount; i++)
            {
                int date = dateTags[i];
                int time = timeTags[i];

                int day   = date & 0xff;
                int month = (date >> 8) & 0xff;
                int year  = (date >> 16) & 0xffff;
                dateStr = month.ToString() + "/" + day.ToString() + "/" + year.ToString();

                switch ((time >> 24) & 0xff)
                {
                case 0:
                    postfix = " AM";
                    break;

                case 1:
                    postfix = " PM";
                    break;

                case -1:
                    postfix = "";
                    break;

                default:
                    postfix = "";
                    break;
                }
                int hours   = (time >> 16) & 0xff;
                int minutes = (time >> 8) & 0xff;
                int seconds = (time) & 0xff;
                timeStr = hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString() + ":" + postfix;

                displayStr = dateStr + "  " + timeStr;

                if (aiChannelCount > 0)
                {
                    index = i * aiChannelCount;
                    for (int j = 0; j < aiChannelCount; j++)
                    {
                        displayStr += "\t\t" + aiChannelData[index++].ToString();
                    }
                }

                if (cjcChannelCount > 0)
                {
                    index = i * cjcChannelCount;
                    for (int j = 0; j < cjcChannelCount; j++)
                    {
                        displayStr += "\t\t" + cjcChannelData[index++].ToString();
                    }
                }

                if (dioChannelCount > 0)
                {
                    index = i * dioChannelCount;
                    for (int j = 0; j < dioChannelCount; j++)
                    {
                        displayStr += "\t" + dioChannelData[index++].ToString();
                    }
                }

                lbData.Items.Add(displayStr);
            }


            if (errorInfo.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                MessageBox.Show(errorInfo.Message);
                return;
            }
        }
Esempio n. 8
0
        public Form1()
        {
            //
            // Required for Windows Form Designer support
            //
            InitializeComponent();

            //  Initiate error handling
            //   activating error handling will trap errors like
            //   bad channel numbers and non-configured conditions.
            //   Parameters:
            //     MccDaq.ErrorReporting.PrintAll :all warnings and errors encountered will be printed
            //     MccDaq.ErrorHandling.StopAll   :if an error is encountered, the program will stop
            MccDaq.ErrorInfo errorInfo = MccDaq.MccService.ErrHandling(MccDaq.ErrorReporting.PrintAll, MccDaq.ErrorHandling.StopAll);


            //  Get the first file in the directory
            //   Parameters:
            //     MccDaq.GetFileOptions.GetFirst :first file
            //     m_Path						  :path to search
            //	   filename						  :receives name of file
            string filename = new string('\0', MAX_PATH);

            errorInfo = MccDaq.DataLogger.GetFileName((int)MccDaq.GetFileOptions.GetFirst, ref m_Path, ref filename);
            string newpath      = filename.TrimEnd('\0');
            string absolutePath = Path.GetFullPath(newpath);

            // create an instance of the data logger
            MccDaq.DataLogger logger = new MccDaq.DataLogger(filename);


            //  Get the file info for the first file in the directory
            //   Parameters:
            //     filename						  :file to retrieve information from
            //     version						  :receives the version of the file
            //	   size							  :receives the size of file
            int version = 0;
            int size    = 0;

            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetFileInfo(ref version, ref size);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblFilename.Text    = absolutePath;
                    lblFileVersion.Text = version.ToString();
                    lblFileSize.Text    = size.ToString();
                }
            }

            //  Get the sample info for the first file in the directory
            //   Parameters:
            //     sampleInterval					 :receives the sample interval (time between samples)
            //     sampleCount						 :receives the sample count
            //	   startDate						 :receives the start date
            //	   startTime						 :receives the start time
            int sampleInterval = 0;
            int sampleCount    = 0;
            int startDate      = 0;
            int startTime      = 0;

            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetSampleInfo(ref sampleInterval, ref sampleCount, ref startDate, ref startTime);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblSampleInterval.Text = sampleInterval.ToString();
                    lblSampleCount.Text    = sampleCount.ToString();

                    int    day     = startDate & 0xff;
                    int    month   = (startDate >> 8) & 0xff;
                    int    year    = (startDate >> 16) & 0xffff;
                    string dateStr = month.ToString() + "/" + day.ToString() + "/" + year.ToString();
                    lblStartDate.Text = dateStr;

                    string postfix;
                    switch ((startTime >> 24) & 0xff)
                    {
                    case 0:
                        postfix = " AM";
                        break;

                    case 1:
                        postfix = " PM";
                        break;

                    case -1:
                        postfix = "";
                        break;

                    default:
                        postfix = "";
                        break;
                    }
                    int    hours   = (startTime >> 16) & 0xff;
                    int    minutes = (startTime >> 8) & 0xff;
                    int    seconds = (startTime) & 0xff;
                    string timeStr = hours.ToString() + ":" + minutes.ToString() + ":" + seconds.ToString() + ":" + postfix;
                    lblStartTime.Text = timeStr;
                }
            }


            //  Get the ANALOG channel count for the first file in the directory
            //   Parameters:
            //     channelMask						:receives the channel mask to specify which channels were logged
            //     unitMask							:receives the unit mask to specify temp or raw data
            //	   aiChannelCount					:receives the number of AI chennels logged
            int aiChannelCount = 0;

            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetAIChannelCount(ref aiChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblAIChannelCount.Text = aiChannelCount.ToString();
                }
            }


            //  Get the ANALOG info for the first file in the directory
            //   Parameters:
            //     channelMask						:receives the channel mask to specify which channels were logged
            //     unitMask							:receives the unit mask to specify temp or raw data
            int [] channelNumbers;
            int [] units;

            channelNumbers = new int[aiChannelCount];
            units          = new int[aiChannelCount];
            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetAIInfo(ref channelNumbers, ref units);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblChannelMask.Text = "";
                    lblUnitMask.Text    = "";
                    for (int i = 0; i < aiChannelCount; i++)
                    {
                        lblChannelMask.Text += channelNumbers[i].ToString();

                        if (units[i] == Convert.ToInt32(MccDaq.LoggerUnits.Raw))
                        {
                            lblUnitMask.Text += "Raw";
                        }
                        else
                        {
                            lblUnitMask.Text += "Temperature";
                        }

                        if (i < aiChannelCount - 1)
                        {
                            lblChannelMask.Text = lblChannelMask.Text + ", ";
                            lblUnitMask.Text    = lblUnitMask.Text + ", ";
                        }
                    }
                }
            }


            //  Get the CJC info for the first file in the directory
            //   Parameters:
            //	   cjcChannelCount					:receives the number of CJC chennels logged
            int cjcChannelCount = 0;

            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetCJCInfo(ref cjcChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblCJCChannelCount.Text = cjcChannelCount.ToString();
                }
            }


            //  Get the DIO info for the first file in the directory
            //   Parameters:
            //	   dioChannelCount					:receives the number of DIO chennels logged
            int dioChannelCount = 0;

            if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                errorInfo = logger.GetDIOInfo(ref dioChannelCount);
                if (errorInfo.Value == MccDaq.ErrorInfo.ErrorCode.NoErrors)
                {
                    lblDIOChannelCount.Text = dioChannelCount.ToString();
                }
            }

            if (errorInfo.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors)
            {
                MessageBox.Show(errorInfo.Message);
                return;
            }
        }