public void GetMeasurement(ChDef ChDefine, ref ArrayList reading, ref ArrayList timestamp, ref ArrayList channelnum) // 从安捷伦获读取测量值的函数 { List <string[]> GlobalConfig = new List <string[]>(); //全局配置list定义 List <string[]> ChannelConfig = new List <string[]>(); //通道配置list定义 string AllChsNum = "";//ChDefine.VoltageDCChNum + "," +ChDefine.FRTDChNum + "," + ChDefine.CurrentDCChNum + "," + ChDefine.TCChNum;//全部通道的字符串,目前支持VDC,ADC,FRTD,TC //string SCANstr = "SCAN (@" + AllChsNum + ")";//扫描通道字符串 //string DELAYstr = "CHANnel:DELay "+ChDefine.ChDelay+", (@"+AllChsNum+")";//通道延时字符串 //GlobalConfig.Add(new string[] { "ROUTe:", SCANstr, DELAYstr, });//配置扫描路径和通道间隔 //GlobalConfig.Add(new string[] { "TRIGger:", "COUNt 1", "SOURce TIMer", "TIMer 0" });//配置触发 //GlobalConfig.Add(new string[] { "FORMat:", "READing:TIME ON", "READing:TIME:TYPE ABS", "READing:CHANnel ON" });//配置读取的相关数据 if (ChDefine.VoltageDCChNum != "") //如果有直流电压测量 { string UDCstr = "(@" + ChDefine.VoltageDCChNum + ")"; //拼出所在的通道 ChannelConfig.Add(new string[] { "CONFigure:", "VOLTage:DC AUTO", UDCstr }); //配置相关通道 AllChsNum = ChDefine.VoltageDCChNum; } if (ChDefine.TCChNum != "" && ChDefine.TCChsType != "") { string TCCstr = "(@" + ChDefine.TCChNum + ")"; //拼出所在的通道 ChannelConfig.Add(new string[] { "CONFigure:", "TEMPerature TC," + ChDefine.TCChsType, TCCstr }); ChannelConfig.Add(new string[] { "UNIT:", "TEMPerature C", TCCstr }); //配置单位 ChannelConfig.Add(new string[] { "TEMP:", "TRAN:TC:RJUN:TYPE INT", TCCstr }); //配置热电偶的参考端为板卡内部 if (AllChsNum != "") { AllChsNum += "," + ChDefine.TCChNum; } else { AllChsNum = ChDefine.TCChNum; } } if (ChDefine.FRTDChNum != "") //如果有四线制热电阻 { string RTDstr = "(@" + ChDefine.FRTDChNum + ")"; //拼出所在的通道 ChannelConfig.Add(new string[] { "CONFigure:", "TEMPerature FRTD, " + ChDefine.FRTDalpha, RTDstr }); //配置相关通道 ChannelConfig.Add(new string[] { "UNIT:", "TEMPerature C", RTDstr }); //配置单位 if (AllChsNum != "") { AllChsNum += "," + ChDefine.FRTDChNum; } else { AllChsNum = ChDefine.FRTDChNum; } } if (ChDefine.CurrentDCChNum != "") //如果有直流电流测量通道 { string IDCstr = "(@" + ChDefine.CurrentDCChNum + ")"; //拼出所在的通道 ChannelConfig.Add(new string[] { "CONFigure:", "CURRent:DC AUTO", IDCstr }); //配置相关通道 if (AllChsNum != "") { AllChsNum += "," + ChDefine.CurrentDCChNum; } else { AllChsNum = ChDefine.CurrentDCChNum; } } string SCANstr = "SCAN (@" + AllChsNum + ")"; //扫描通道字符串 string DELAYstr = "CHANnel:DELay " + ChDefine.ChDelay + ", (@" + AllChsNum + ")"; //通道延时字符串 GlobalConfig.Add(new string[] { "ROUTe:", SCANstr, DELAYstr, }); //配置扫描路径和通道间隔 GlobalConfig.Add(new string[] { "TRIGger:", "COUNt 1", "SOURce TIMer", "TIMer 0" }); //配置触发 GlobalConfig.Add(new string[] { "FORMat:", "READing:TIME ON", "READing:TIME:TYPE ABS", "READing:CHANnel ON" }); //配置读取的相关数据 GlobalConfig.TrimExcess(); ChannelConfig.TrimExcess();//去掉list多余的内存空间 DAQ TestDAQ = new DAQ(); //声明DAQ类实例 TestDAQ.OpenRS232Port(ChDefine.COMPortNum); //开端口 TestDAQ.Config34970A(GlobalConfig, ChannelConfig); //配置主机 //Thread.Sleep(1000); TestDAQ.Readings(ref reading, ref timestamp, ref channelnum); //获取读数 }
private async Task M0004_Books_TypeL() { string LRoot = "shared/transfers/LVolumes/"; if (!Shared.Storage.DirExist(LRoot)) { return; } string[] Ids = Shared.Storage.ListDirs(LRoot); int l = Ids.Length; List <Book> Entries = new List <Book>(); await Ids.ExecEach(async ( Id, i ) => { MesgR(stx.Text("MightTakeAWhile") + string.Format("{1}/{2} ( {0} )", Id, i + 1, l)); Book Entry = null; if (int.TryParse(Id, out int k) && X.Exists) { BookItem Item = X.Instance <BookItem>(XProto.BookItemEx, Id); Entry = Item.Entry; Entry.Type = Entry.Type | BookType.L; } else { BookItem Item = new LocalTextDocument(Id); Entry = Item.Entry; } await Shared.BooksDb.LoadCollectionAsync(Entry, x => x.Volumes, x => x.Index); Entry.Volumes.Clear(); string BRoot = LRoot + Id + "/"; string MetaLoc = BRoot + "METADATA.xml"; XRegistry XMeta = new XRegistry("<Meta />", MetaLoc); XParameter[] VolDefs = XMeta.Parameters("vid"); VolDefs.ExecEach((VolDef, vi) => { Volume Vol = new Volume() { Book = Entry, Title = VolDef.GetValue("name"), Chapters = new List <Chapter>(), Index = vi }; Vol.Meta[AppKeys.GLOBAL_VID] = VolDef.Id; XRegistry ChReg = new XRegistry("<ch />", BRoot + VolDef.Id + ".vol"); XParameter[] ChDefs = ChReg.Parameters("cid"); ChDefs.ExecEach((ChDef, ei) => { Chapter Ch = new Chapter() { Book = Entry, Volume = Vol, Title = ChDef.GetValue("name"), Index = ei }; Ch.Meta[AppKeys.GLOBAL_CID] = ChDef.Id; string ChLocation = BRoot + VolDef.Id + "/" + ChDef.Id + ".txt"; if (Shared.Storage.FileExists(ChLocation)) { ChapterContent ChCont = new ChapterContent() { Chapter = Ch, }; ChCont.Data.BytesValue = Shared.Storage.GetBytes(ChLocation); Shared.BooksDb.ChapterContents.Add(ChCont); } Vol.Chapters.Add(Ch); }); Entry.Volumes.Add(Vol); }); Entries.Add(Entry); }); MesgR(stx.Text("SavingRecords")); Shared.BooksDb.SaveBooks(Entries.ToArray()); Purge(LRoot); }