private void cmdFileInfo_Click(object sender, EventArgs e) { int version = 0; int size = 0; // 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 ULStat = logger.GetFileInfo(ref version, ref size); if (ULStat.Value != MccDaq.ErrorInfo.ErrorCode.NoErrors) { lblComment.Text = ULStat.Message; } else { txtResults.Text = "The file properties of '" + logger.FileName + "' are:" + "\r\n" + "\r\n" + "\t" + "Version: " + "\t" + version.ToString("0") + "\r\n" + "\t" + "Size: " + "\t" + size.ToString("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; } }
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; } }