public InstrumentDataReportCTD(InstrumentDataManager _manager, byte _deviceId, OutPutFormat _outFormat ) : base(_manager, _deviceId) { sipperFile = _manager.SipperFile(); SipperConfigRec configRec = _manager.ConmfigRec(); if (sipperFile != null) { ext0Code = sipperFile.CtdExt0; ext1Code = sipperFile.CtdExt1; ext2Code = sipperFile.CtdExt2; ext3Code = sipperFile.CtdExt3; } else if (configRec != null) { ext0Code = configRec.HeaderRec().CtdExt0Code(); ext1Code = configRec.HeaderRec().CtdExt1Code(); ext2Code = configRec.HeaderRec().CtdExt2Code(); ext3Code = configRec.HeaderRec().CtdExt3Code(); } String siperFileName = ""; if (sipperFile != null) { siperFileName = OSservices.GetRootName(sipperFile.SipperFileName); } //if (!String.IsNullOrEmpty (siperFileName)) // ctdStream = new StreamWriter ("C:\\Temp\\" + siperFileName + ".txt"); }
private void AddSipperFiles(String[] sipperFileNames) { if (sipperFileNames == null) { return; } String errorMsgs = ""; foreach (String sfn in sipperFileNames) { String rootName = OSservices.GetRootName(sfn); PicesSipperFile sf = DbConn().SipperFileRecLoad(rootName); if (sf != null) { if (errorMsgs.Length > 0) { errorMsgs += "\n"; } errorMsgs += "File[" + rootName + "] already in DataBase; Cruise[" + sf.CruiseName + "] Station[" + sf.StationName + "] Deployment[" + sf.DeploymentNum + "]"; } } if (errorMsgs.Length > 0) { MessageBox.Show("The following errors occurred" + "\n" + "\n" + errorMsgs + "\n", "Add Sipper Files Failed."); } else { foreach (String sfn in sipperFileNames) { String rootName = OSservices.GetRootName(sfn); PicesSipperFile newSipperFile = new PicesSipperFile(rootName); newSipperFile.CruiseName = deployment.CruiseName; newSipperFile.StationName = deployment.StationName; newSipperFile.DeploymentNum = deployment.DeploymentNum; SipperConfigRec config = new SipperConfigRec(); newSipperFile.Sp0 = config.HeaderRec().SerialPortShortName(0); newSipperFile.Sp1 = config.HeaderRec().SerialPortShortName(1); newSipperFile.Sp2 = config.HeaderRec().SerialPortShortName(2); newSipperFile.Sp3 = config.HeaderRec().SerialPortShortName(3); if (String.IsNullOrEmpty(newSipperFile.Sp0)) { newSipperFile.Sp0 = "CTD"; newSipperFile.Sp1 = "P-R"; newSipperFile.Sp2 = "BAT"; newSipperFile.Sp3 = ""; } newSipperFile.CtdExt0 = config.HeaderRec().CtdExt0Code(); newSipperFile.CtdExt1 = config.HeaderRec().CtdExt1Code(); newSipperFile.CtdExt2 = config.HeaderRec().CtdExt2Code(); newSipperFile.CtdExt3 = config.HeaderRec().CtdExt3Code(); if (String.IsNullOrEmpty(newSipperFile.CtdExt0)) { newSipperFile.CtdExt1 = "TRN"; newSipperFile.CtdExt1 = "OXG"; newSipperFile.CtdExt2 = "FLO"; newSipperFile.CtdExt3 = "TUR"; } DbConn().SipperFileInsert(newSipperFile); if (!DbConn().Valid()) { MessageBox.Show("Error occurred adding SipperFile[" + rootName + "]" + "\n\n" + DbConn().LastErrorDesc()); break; } } PopulateScreen(); } } /* AddSipperFiles */
/// <summary> /// Initializes a new instance of the <see cref="InstrumentDataManager"/> class. /// </summary> /// <param name="_dataLogger">The _data logger.</param> /// <param name="_sipperFile">The _sipper file.</param> /// <param name="_configRec">The _config rec.</param> /// <param name="_currentDataRow">The _current data row.</param> public InstrumentDataManager(InstrumentDataLogger _dataLogger, // Will take ownership of '_dataLogger' PicesSipperFile _sipperFile, SipperConfigRec _configRec, InstrumentData _currentDataRow ) { dataLogger = _dataLogger; configRec = _configRec; sipperFile = _sipperFile; portAssignments = null; if (sipperFile != null) { portAssignments = new PortAssignment[4]; if (String.IsNullOrEmpty(sipperFile.Sp0)) { portAssignments[0] = null; } else { portAssignments[0] = new PortAssignment(sipperFile.Sp0, ""); } if (String.IsNullOrEmpty(sipperFile.Sp1)) { portAssignments[1] = null; } else { portAssignments[1] = new PortAssignment(sipperFile.Sp1, ""); } if (String.IsNullOrEmpty(sipperFile.Sp2)) { portAssignments[2] = null; } else { portAssignments[2] = new PortAssignment(sipperFile.Sp2, ""); } if (String.IsNullOrEmpty(sipperFile.Sp3)) { portAssignments[3] = null; } else { portAssignments[3] = new PortAssignment(sipperFile.Sp3, ""); } } else { portAssignments = configRec.HeaderRec().PortAssignments(); } reporters = new InstrumentDataReport[MaxNumOfDevices]; currentDataRow = _currentDataRow; byte deviceId = 0; for (deviceId = 0; deviceId < MaxNumOfDevices; deviceId++) { reporters[deviceId] = null; if (deviceId >= SerialPort0DeviceID) { byte serialPort = (byte)(deviceId - SerialPort0DeviceID); if (serialPort < portAssignments.Length) { if (portAssignments[serialPort] != null) { reporters[deviceId] = portAssignments[serialPort].Instrument().CreateInstrumentDataReport(this, deviceId); } } } } InitializeLatitude(); }