private void button1_Click(object sender, EventArgs e) { foreach (var item in _treeView2.Nodes) { TreeNode node = (TreeNode)item; uint chanelId = Convert.ToUInt32(node.Text.Split('_')[1]); uint ret; Channe429Receive channe429ReNow = null; //Channe429Receive channe429Re foreach (var itemOfRev in _device429.ReceiveComponents) { Channe429Receive channe429Re = (Channe429Receive)itemOfRev; if (channe429Re.ChannelID == chanelId) { channe429ReNow = channe429Re; } } if (node.Checked == true) { Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, chanelId); ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_ENABLE); channe429ReNow.isLoop = false; } else { Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, chanelId); ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_DISABLE); channe429ReNow.isLoop = true; } if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelLoopTx", ret)); } } }
//获取当前选中的label public void Select(string path) { _curSelectedChannel = null; CurSelectedLabel = null; string[] pathParts = path.Split('_'); if (pathParts.Length > 3) { string chName = pathParts[3]; _curSelectedChannel = (Channe429Send)_device429.GetSpecificItem(chName);//这个方法是获取子组件 if (pathParts.Length > 4) { string lableName = pathParts[4]; CurSelectedLabel = (SendLabel429)_curSelectedChannel.GetSpecificItem(lableName); //这里将数据初始化到周期发送里面 Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, _curSelectedChannel.ChannelID); uint ret = driverTx.ChannelSendTx((uint)CurSelectedLabel.ActualValue, SendOptA429.BHT_L1_A429_OPT_PERIOD_SEND_UPDATE); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelSendTx Set Data", ret)); } ret = driverTx.ChannelPeriodParamTx(CurSelectedLabel.Interval, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelPeriodParamTx", ret)); } } } }
//清除数据 private void ClearData(object sender, EventArgs e) { foreach (var item in _device429.ReceiveComponents) { Channe429Receive sendChanel = (Channe429Receive)item; sendChanel.count = 0; sendChanel.errCount = 0; sendChanel.DeviceCount = 0; sendChanel.errDeviceCount = 0; for (int i = 0; i <= 377; i++) { ReceiveLabel429 label = (ReceiveLabel429)sendChanel.GetSpecificItem(i); if (label != null) { sendChanel.Delete(label); } } Channel429DriverRx channel429DriverRx = new Channel429DriverRx(_device429.DevID, sendChanel.ChannelID); uint ret = channel429DriverRx.ChannelMibClearRx(); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when clear receive data", ret)); } } }
public override void Login(IDeviceInfo info) { if (BoardType == info.BoardType) { foreach (var component in ChildComponents) { IDeviceInfo device = (IDeviceInfo)component; if (device.BoardNo == info.BoardNo && device.BoardType == info.BoardType && device.ChannelCount == info.ChannelCount && device.ChannelType == info.ChannelType) { return; } } //建立设备前初始化 uint ret = ((Device429Operator)DriverOperate).DefaultInit(info.DevID); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelSendTx", ret)); } //建立设备 Device429 dev = new Device429(); dev.InitializeParameter(info); Add(dev); dev.BuildModule(); dev.ReceiveModule.Start(); dev.SendModule.Start(); } }
//检测板卡信息 public List <IDeviceInfo> CheckDevice() { List <IDeviceInfo> list = new List <IDeviceInfo>(); DeviceIDManager deviceIDManager = new DeviceIDManager(); List <uint> deviceIDList = deviceIDManager.GetProperAllDeviceID(); //遍历所有可能的devID,看哪些是在线的 for (int i = 0; i < deviceIDList.Count; i++) { uint devID = deviceIDList[i]; //使用429也可以检测处1553的设备,所以此处就用429的就可以了。 uint ret = Bus429.DriverOperate.DeviceProbe(devID); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke DeviceProbe", ret)); } if (ret == 0) { DeviceInfo deviceInfo = new DeviceInfo(); uint backplaneType; uint boardNumber; BoardType boardType; DeviceIDManager.AnalysisDevID(devID, out backplaneType, out boardType, out boardNumber); deviceInfo.BoardNo = boardNumber; deviceInfo.BoardType = boardType; deviceInfo.DevID = devID; list.Add(deviceInfo); } } return(list); }
private void GetGatherParam() { ChannelGatherParamA429Rx gatherParamA429 = new ChannelGatherParamA429Rx(); uint ret = ((Channel429DriverRx)(ChannelDriver)).ChannelGatherParam(ref gatherParamA429, ParamOptionA429.BHT_L1_PARAM_OPT_GET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelGatherParam", ret)); } if (gatherParamA429.gather_enable == 0)//过滤 { isFilter = true; } else { isFilter = false; } if (gatherParamA429.recv_mode == RecvModeA429.BHT_L1_A429_RECV_MODE_LIST) { receiveType = "队列"; } else { receiveType = "采样"; } if (!string.IsNullOrEmpty(gatherParamA429.threshold_count.ToString())) { deepCount = gatherParamA429.threshold_count.ToString(); } if (!string.IsNullOrEmpty(gatherParamA429.threshold_time.ToString())) { timeCount = gatherParamA429.threshold_time.ToString(); } }
private static void Main() { //检测.net版本。 if (!VersionCheck.Check4FromRegistry()) { MessageBox.Show(".net版本过低。本程序需要运行在.net4.0或.net4.0以后的版本!", "提示"); return; } App.Instance.ApplicationDirectory = Environment.CurrentDirectory + "\\"; //同时只能运行一个实例。 if (SingletonApp.IsMutexExsited) { SingletonApp.ShowRunningInstance(); return; } //指定运行日志要保存的目录 RunningLog.Start(App.Instance.ApplicationDirectory + "\\history\\"); //判断当前登录用户是否为管理员 if (WindowsAuthority.IsAdministrator) { //设置应用程序退出和异常的事件 Application.ApplicationExit += App.Instance.RaiseApplicationExist; Application.ThreadExit += App.Instance.RaiseMainThreadExist; Application.ThreadException += (o, e) => MessageBox.Show(e.Exception.ToString()); try { //运行应用程序内核 App.Instance.BuildModule(); App.Instance.Initialize(); App.Instance.RaiseStarting(); //启动Ui界面 IInvoke invoker = ObjectGenerator.Create("FlightViewerUI.dll", "BinHong.FlightViewerUI.UiInvoker") as IInvoke; invoker.Invoke(); } catch (Exception e) { string msg = e.Message; #if DEBUG msg = e.Message + e.StackTrace; #endif RunningLog.Record(LogType.System, LogLevel.Error, msg); Thread.Sleep(200); MessageBox.Show(msg); } finally { SingletonApp.ReleaseMutex(); } } else { WindowsAuthority.RunAsAdministrator(Application.ExecutablePath); } }
private void SendPerid(object sender, EventArgs e) { Channel429DriverTx driverTx = new Channel429DriverTx(_device429.DevID, ChVm._curSelectedChannel.ChannelID); uint ret = driverTx.ChannelSendTx(0, SendOptA429.BHT_L1_A429_OPT_PERIOD_SEND_START); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelSendTx Set Data", ret)); } }
private void OnMenuHelp_HelpDoc(object sender, EventArgs e) { string filePath = App.Instance.ApplicationDirectory + "FlightViewer帮助文档.chm"; if (!File.Exists(filePath)) { RunningLog.Record(LogLevel.Error, "FlightViewer帮助文档缺失!"); } else { System.Diagnostics.Process.Start(filePath); } }
//向设备写入信息 public void WriteDev(ushort addr, byte byteOut) { uint ret = device429Operator.FpgaEepromWrite(DevID, addr, byteOut); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke WriteDev", ret)); } else { RunningLog.Record(string.Format("WriteDev Success!")); } }
public void Send() { if (Enabled == false || isSend == false) { return; } foreach (var item in ChildComponents) { SendLabel429 label429 = item as SendLabel429; if (!label429.IsSelected) { return; } if (label429 != null) { currentLabel = label429; Channel429DriverTx driverTx = (Channel429DriverTx)ChannelDriver; uint ret = 0; if (!label429.isAutoIncrement) { ret = driverTx.ChannelSendTx((uint)label429.ActualValue, SendOptA429.BHT_L1_A429_OPT_RANDOM_SEND); } else { label429.ActualValue += 1; ret = driverTx.ChannelSendTx((uint)label429.ActualValue, SendOptA429.BHT_L1_A429_OPT_RANDOM_SEND); } if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelSendTx", ret)); errCount++; } else { labelCount++; FileHelper.WriteLogForSend(Convert.ToString(label429.ActualValue, 2)); } MibDataA429 mibDataA429; ret = driverTx.ChannelMibGetTx(out mibDataA429); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelMibGetTx", ret)); errCount++; } DeviceCount = mibDataA429.cnt; errDeviceCount = mibDataA429.err_cnt; } } }
//读取设备信息 public void ReadDev(ushort addr, ref byte byteOut) { int size = Marshal.SizeOf(typeof(byte)); byte[] bytes = new byte[size]; IntPtr data = Marshal.AllocHGlobal(size); uint ret = device429Operator.FpgaEepromRead(DevID, addr, ref data); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ReadDev", ret)); } else { byteOut = (byte)Marshal.PtrToStructure(data, typeof(int)); } }
private void ClearData(object sender, EventArgs e) { foreach (var ch in _device429.SendComponents) { Channe429Send chennel = (Channe429Send)ch; chennel.labelCount = 0; chennel.errCount = 0; chennel.DeviceCount = 0; chennel.errDeviceCount = 0; this.textBox_sendValue.Text = ""; Channel429DriverTx channel429DriverRx = new Channel429DriverTx(_device429.DevID, chennel.ChannelID); uint ret = channel429DriverRx.ChannelMibClearTx(); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when clear send data", ret)); } } }
private void treeView1_AfterSelect(object sender, TreeViewEventArgs e) { if (!_treeView.SelectedNode.FullPath.ToLower().Contains("ssm")) { return; } ChannelFilterParamA429Rx channelFilterParamA429Rx = new ChannelFilterParamA429Rx(); if (_treeView.SelectedNode.Checked == true) { //_treeView.SelectedNode.Checked = false; channelFilterParamA429Rx.filterMode = 0; } else if (_treeView.SelectedNode.Checked == false) { //_treeView.SelectedNode.Checked = true; channelFilterParamA429Rx.filterMode = 1; } TreeNode treeNode = (TreeNode)_treeView.SelectedNode; //SSM TreeNode SDINodes = treeNode.Parent; //sdi TreeNode LabelNodes = SDINodes.Parent; //label TreeNode ChannelNodes = LabelNodes.Parent; //channel int channelId = Convert.ToInt32(ChannelNodes.Text.Split('_')[1]); Channel429DriverRx channel429DriverRx = new Channel429DriverRx(_device429.DevID, (uint)channelId); string sdi = SDINodes.Text.Split('_')[1]; channelFilterParamA429Rx.sdi = Convert.ToUInt16(sdi, 2); int label = Convert.ToInt32(LabelNodes.Text.Split('_')[1]); string labelStr = Convert.ToString(label, 2);//问题出在这 ushort bytelabel = Convert.ToUInt16(labelStr, 2); channelFilterParamA429Rx.label = bytelabel; string ssm = treeNode.Text.Split('_')[1]; channelFilterParamA429Rx.ssm = Convert.ToUInt16(ssm, 2); uint ret = channel429DriverRx.ChannelFilterCfgRxm(channelFilterParamA429Rx); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when Aplly Strainer", ret)); } }
/// <summary> /// 线程响应 /// </summary> /// <param name="stateInfo"></param> private void OnThread(object stateInfo) { while (true) { Thread.Sleep(100); Action act = ThreadEvent; if (act != null) { try { act(); } catch (Exception ex) { RunningLog.Record(ex.Message + "\n" + ex.StackTrace); } } } }
public void Receive() { if (Enabled == false || isSend == false) { return; } rxpA429Result.data = 0; Channel429DriverRx driverRx = (Channel429DriverRx)ChannelDriver; RxpA429 rxpA429 = new RxpA429(); uint maxRxp = 1; int rxpNum; WaitStatusA429 opt = WaitStatusA429.BHT_L1_OPT_NOWAIT; uint ret = driverRx.ChannelRecvRx(out rxpA429, maxRxp, out rxpNum, opt);//这里设置为存储一个数据,那么可以操作的data只有一个 if (ret != 0) { errCount++; RunningLog.Record(string.Format("return value is {0} when receive data", ret)); } else if (rxpNum > 0 && ret == 0) { count++; rxpA429Result = rxpA429;//这里将out的数据保存到类中 FileHelper.WriteLogForReceive(Convert.ToString(rxpA429.data, 2)); } MibDataA429 mibDataA429; ret = driverRx.ChannelMibGetRx(out mibDataA429); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when ChannelMibGetRx data", ret)); } DeviceCount = mibDataA429.cnt; errDeviceCount = mibDataA429.err_cnt; if (IsFileSaveAllow)//如果允许保存文件,那么就执行这一步操作 { DataProcessModule.Save(rxpA429, rxpNum); } }
public override void BuildModule() { uint devID = ((IDeviceInfo)Owner).DevID; Channel429DriverTx driverTx = new Channel429DriverTx(devID, ChannelID); ChannelDriver = driverTx; object baudRateValue = App.Instance.ConfigManager.GetParameter(this.Path + "_BaudRate"); if (baudRateValue != null) { BaudRate = (int)baudRateValue; } uint ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_ENABLE); LoopEnable = true; if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelLoopTx", ret)); } }
private void SetGatherParam(Channe429Receive channelInfoUi) { ChannelGatherParamA429Rx gatherParamA429 = new ChannelGatherParamA429Rx(); if (channelInfoUi.isFilter == true) //过滤 { gatherParamA429.gather_enable = 0; } else //不过滤 { gatherParamA429.gather_enable = 1; } if (channelInfoUi.receiveType == "队列") { gatherParamA429.recv_mode = RecvModeA429.BHT_L1_A429_RECV_MODE_LIST; } else { gatherParamA429.recv_mode = RecvModeA429.BHT_L1_A429_RECV_MODE_SAMPLE; } if (!string.IsNullOrEmpty(channelInfoUi.deepCount)) { gatherParamA429.threshold_count = (ushort)Convert.ToInt32(channelInfoUi.deepCount); } if (!string.IsNullOrEmpty(channelInfoUi.timeCount)) { gatherParamA429.threshold_time = (ushort)Convert.ToInt32(channelInfoUi.timeCount); } uint ret = ((Channel429DriverRx)(channelInfoUi.ChannelDriver)).ChannelGatherParam(ref gatherParamA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelGatherParam", ret)); } }
public void UpdataDevice(Device429 device429) { for (int i = 0; i < 16; i++) { Channe429Receive channel = (Channe429Receive)device429.GetSpecificItem(i); ChannelInfoUiReceive channelInfoUi = _channels[i]; channel.AliasName = channelInfoUi.Name; if (channelInfoUi.Parity == BaudRate.偶校验.ToString()) { channel.Parity = 1; } else if (channelInfoUi.Parity == BaudRate.奇校验.ToString()) { channel.Parity = 0; } else { channel.Parity = 2; } channel.Enabled = channelInfoUi.Enabled; channel.BaudRate = channelInfoUi.BaudRate; channel.isFilter = channelInfoUi.IsFilter; channel.receiveType = channelInfoUi.ReceiveType; channel.deepCount = channelInfoUi.DeepCount; channel.timeCount = channelInfoUi.TimeCount; ChannelParamA429 paramA429 = new ChannelParamA429() { work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE }; if (channel.Parity == 0) { paramA429.par = ParityA429.BHT_L1_A429_PARITY_ODD; } else if (channel.Parity == 1) { paramA429.par = ParityA429.BHT_L1_A429_PARITY_EVEN; } else { paramA429.par = ParityA429.BHT_L1_A429_PARITY_NONE; } if (channelInfoUi.BaudRate == 12500) { paramA429.baud = BaudA429.BHT_L1_A429_BAUD_12_5K; } else if (channelInfoUi.BaudRate == 50000) { paramA429.baud = BaudA429.BHT_L1_A429_BAUD_50K; } else if (channelInfoUi.BaudRate == 100000) { paramA429.baud = BaudA429.BHT_L1_A429_BAUD_100K; } uint ret = ((Channel429DriverRx)(channel.ChannelDriver)).ChannelParamRx(ref paramA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret)); } SetGatherParam(channel); } }
public override void BuildModule() { object baudRateValue = App.Instance.ConfigManager.GetParameter(this.Path + "_BaudRate"); object enableValue = App.Instance.ConfigManager.GetParameter(this.Path + "_Enable"); object parityValue = App.Instance.ConfigManager.GetParameter(this.Path + "_Parity"); for (uint i = 0; i < 16; i++) { Channe429Receive channel = new Channe429Receive(i); channel.Enabled = false; if (baudRateValue != null) { channel.BaudRate = (int)baudRateValue; } if (enableValue != null) { channel.Enabled = (bool)enableValue; } if (parityValue != null) { channel.Parity = (int)parityValue; } channel.Initialize(); Add(channel); ReceiveComponents.Add(channel); channel.BuildModule(); //初始化Channel ChannelParamA429 paramA429 = new ChannelParamA429() { work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE, baud = BaudA429.BHT_L1_A429_BAUD_100K, par = ParityA429.BHT_L1_A429_PARITY_ODD }; uint ret = ((Channel429DriverRx)(channel.ChannelDriver)).ChannelParamRx(ref paramA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret)); } ChannelGatherParamA429Rx gatherParamA429 = new ChannelGatherParamA429Rx() { gather_enable = 1, recv_mode = RecvModeA429.BHT_L1_A429_RECV_MODE_SAMPLE, threshold_count = 0, threshold_time = 0 }; ret = ((Channel429DriverRx)(channel.ChannelDriver)).ChannelGatherParam(ref gatherParamA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelGatherParam", ret)); } } for (uint i = 0; i < 16; i++) { Channe429Send channel = new Channe429Send(i); channel.Enabled = false; if (baudRateValue != null) { channel.BaudRate = (int)baudRateValue; } if (enableValue != null) { channel.Enabled = (bool)enableValue; } if (parityValue != null) { channel.Parity = (int)parityValue; } channel.Initialize(); Add(channel); SendComponents.Add(channel); channel.BuildModule(); //初始化Channel ChannelParamA429 paramA429 = new ChannelParamA429() { work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE, baud = BaudA429.BHT_L1_A429_BAUD_100K, par = ParityA429.BHT_L1_A429_PARITY_ODD }; uint ret = ((Channel429DriverTx)(channel.ChannelDriver)).ChannelParamTx(ref paramA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret)); } } }
public void UpdataDevice(Device429 device429) { for (int i = 0; i < 16; i++) { Channe429Send channel = (Channe429Send)device429.GetSpecificItem(i + 16);//注意这里 ChannelInfoUiSend channelInfoUi = _channels[i]; channel.AliasName = channelInfoUi.Name; if (channelInfoUi.Parity == BaudRate.偶校验.ToString()) { channel.Parity = 1; } else if (channelInfoUi.Parity == BaudRate.奇校验.ToString()) { channel.Parity = 0; } else { channel.Parity = 2; } channel.BaudRate = channelInfoUi.BaudRate; channel.LoopEnable = channelInfoUi.LoopEnable; channel.Enabled = channelInfoUi.Enabled; ChannelParamA429 paramA429 = new ChannelParamA429() { work_mode = ChannelWorkModeA429.A429ChannelWorkModeNABLE }; if (channel.Parity == 0) { paramA429.par = ParityA429.BHT_L1_A429_PARITY_ODD; } else if (channel.Parity == 1) { paramA429.par = ParityA429.BHT_L1_A429_PARITY_EVEN; } else { paramA429.par = ParityA429.BHT_L1_A429_PARITY_NONE; } if (channelInfoUi.BaudRate == 12500) { paramA429.baud = BaudA429.BHT_L1_A429_BAUD_12_5K; } else if (channelInfoUi.BaudRate == 50000) { paramA429.baud = BaudA429.BHT_L1_A429_BAUD_50K; } else if (channelInfoUi.BaudRate == 100000) { paramA429.baud = BaudA429.BHT_L1_A429_BAUD_100K; } uint ret = ((Channel429DriverTx)(channel.ChannelDriver)).ChannelParamTx(ref paramA429, ParamOptionA429.BHT_L1_PARAM_OPT_SET); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when invoke ChannelParamRx", ret)); } if (channel.LoopEnable) { Channel429DriverTx driverTx = new Channel429DriverTx(device429.DevID, channel.ChannelID); ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_ENABLE); } else { Channel429DriverTx driverTx = new Channel429DriverTx(device429.DevID, channel.ChannelID); ret = driverTx.ChannelLoopTx(AbleStatusA429.BHT_L1_OPT_DISABLE); } } }
/// <summary> /// 点击PreviousBtn时 /// </summary> /// <param name="o"></param> /// <param name="e"></param> private void OnPreviousBtnClick(object o, EventArgs e) { _previousCheckBox.Checked = !_previousCheckBox.Checked; try { _logDataTable.Rows.Clear(); if (_previousCheckBox.Checked) { string dir = Directory.GetParent(RunningLog.LogFile.FilePath).FullName; string[] filePaths = Directory.GetFiles(dir, "*.his"); foreach (var filePath in filePaths) { string[] lines = File.ReadAllLines(filePath); for (int index = lines.Length - 1; index > -1; index--) { var line = lines[index]; LogItem item = LogItem.Parse(line); if (item != null) { DataRow dataRow = _logDataTable.NewRow(); dataRow["时间"] = item.Time; dataRow["类型"] = item.Type; dataRow["级别"] = item.Level; dataRow["内容"] = item.Text; _logDataTable.Rows.Add(dataRow); } else if (line != "" && item == null) { _logDataTable.Rows[_logDataTable.Rows.Count - 1]["内容"] += "\n" + line; } } } //装载完内容后设置一下行的高度 _flgView.AutoSizeRows(); } else { if (!File.Exists(RunningLog.LogFile.FilePath)) { return; } string[] lines = File.ReadAllLines(RunningLog.LogFile.FilePath); foreach (var line in lines) { LogItem item = LogItem.Parse(line); if (item != null) { DataRow dataRow = _logDataTable.NewRow(); dataRow["时间"] = item.Time; dataRow["类型"] = item.Type; dataRow["级别"] = item.Level; dataRow["内容"] = item.Text; _logDataTable.Rows.Add(dataRow); } else if (line != "" && item == null) { _logDataTable.Rows[_logDataTable.Rows.Count - 1]["内容"] += "\n" + line; } } //装载完内容后设置一下行的高度 _flgView.AutoSizeRows(); } } catch (Exception exception) { RunningLog.Record(LogLevel.Error, "读取日志错误," + exception.Message); } }
private void Apply(object sender, EventArgs e) { int sdiOrSsh = 0; string sdiOrSshStr = string.Empty; ChannelFilterParamA429Rx channelFilterParamA429Rx = new ChannelFilterParamA429Rx(); for (int i = 0; i < _treeView.Nodes.Count; i++) { TreeNode treeNode = (TreeNode)_treeView.Nodes[i]; Channel429DriverRx channel429DriverRx = new Channel429DriverRx(_device429.DevID, (uint)i); foreach (var item in treeNode.Nodes) { int label; string labelStr; ushort bytelabel; TreeNode treeLabelNode = (TreeNode)item; bool isContainLabel = treeLabelNode.Text.Contains("label"); if (isContainLabel) { label = Convert.ToInt32(treeLabelNode.Text.Split('_')[1]); labelStr = Convert.ToString(label, 2);//问题出在这 bytelabel = Convert.ToUInt16(labelStr, 2); channelFilterParamA429Rx.label = bytelabel; } foreach (var item2 in treeLabelNode.Nodes) { TreeNode treessNode = (TreeNode)item2; bool isContainSdi = treessNode.Text.Contains("SDI"); if (isContainSdi) { sdiOrSsh = Convert.ToInt32(treessNode.Text.Split('_')[1]); sdiOrSshStr = Convert.ToString(sdiOrSsh); channelFilterParamA429Rx.sdi = Convert.ToUInt16(sdiOrSshStr, 2); } foreach (var item3 in treessNode.Nodes) { TreeNode ssmNode = (TreeNode)item3; bool isContainSsm = ssmNode.Text.Contains("SSM"); if (isContainSsm) { sdiOrSsh = Convert.ToInt32(ssmNode.Text.Split('_')[1]); sdiOrSshStr = Convert.ToString(sdiOrSsh); channelFilterParamA429Rx.ssm = Convert.ToUInt16(sdiOrSshStr, 2); if (ssmNode.Checked == true) { channelFilterParamA429Rx.filterMode = 1; } else { channelFilterParamA429Rx.filterMode = 0; } } uint ret = channel429DriverRx.ChannelFilterCfgRxm(channelFilterParamA429Rx); if (ret != 0) { RunningLog.Record(string.Format("return value is {0} when Aplly Strainer", ret)); } } } } } }