private void OnMenuFile_Open(object sender, EventArgs e) { OpenFileDialog sFD = new OpenFileDialog(); sFD.Title = "保存文件"; sFD.ShowHelp = true; sFD.Filter = "工程文件(*.cfg)|*.cfg"; //过滤格式 sFD.FilterIndex = 1; //格式索引 sFD.RestoreDirectory = false; sFD.InitialDirectory = "c:\\"; //默认路径 if (sFD.ShowDialog() == DialogResult.OK) { string filePath = sFD.FileName; List <DeviceForXml> list = ReadXml(filePath); foreach (DeviceForXml item in list) { DeviceMessage devMsg = item.devMsg; Device429 device = new Device429(); device.BoardNo = devMsg.BoardNo; device.BoardType = devMsg.BoardType; device.ChannelCount = devMsg.ChannelCount; device.ChannelType = devMsg.ChannelType; device.DevID = devMsg.DevID; device.filterStr = devMsg.filter; TopMenuVM topMenuVM = new TopMenuVM(device); topMenuVM.OpenSetting();//将xml初始化设备及软件 } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //设置对应的设备 string[] pathParts = this.Name.Split('_'); _device429 = App.Instance.FlightBusManager.Bus429.GetSpecificItem(pathParts[pathParts.Length - 1]); _chVm = new ChannelReceiveControlVm(_device429); //初始化数据 InitializeData(); //提示信息 _chVm.MsgShow.Initialize( () => this.StatusStrip.ClearMsg(), info => this.StatusStrip.ShowErrorInfo(info), info => this.StatusStrip.ShowWarningInfo(info), info => this.StatusStrip.ShowInfo(info)); _thread.ThreadEvent += OnProcess;//创建一个新的线程来处理count if (this.radioButton2.Checked == true) { _chVm.IsFileSaveAllow = true; } else { _chVm.IsFileSaveAllow = false; } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //设置对应的设备 string[] pathParts = this.Name.Split('_'); _device429 = App.Instance.FlightBusManager.Bus429.GetSpecificItem(pathParts[pathParts.Length - 1]); }
private void OnLogin(object sender, EventArgs e) { //检测授权 var activator = new KeyAuthorization(App.Instance.ConfigDirectory); if (!activator.Check()) { MessageBox.Show(@"软件过期,请重新授权!", @"提示"); return; } _newDeviceUi.Login(); #if Test Device429 device = ((Bus429)App.Instance.FlightBusManager.GetBus(BoardType.A429.ToString())).GetSpecificItem(0); if (device != null) { Channe429Receive ch = (Channe429Receive)device.GetSpecificItem(0); Channel429DriverRx driver = (Channel429DriverRx)ch.ChannelDriver; MibDataA429 mibDataA429; driver.ChannelMibGetRx(out mibDataA429); Console.WriteLine("mibDataA429:{0},{1}", mibDataA429.cnt, mibDataA429.err_cnt); } #endif this.Close(); }
public void Initialize(Device429 device429) { for (int i = 0; i < 16; i++) { Channe429Send ch = (Channe429Send)device429.GetSpecificItem(i + 16); var channel = new ChannelInfoUiSend(); channel.Name = ch.Name; channel.ChannelID = ch.ChannelID; if (ch.Parity == 1) { channel.Parity = BaudRate.偶校验.ToString(); } else if (ch.Parity == 0) { channel.Parity = BaudRate.奇校验.ToString(); } else { channel.Parity = BaudRate.校验.ToString(); } channel.Enabled = ch.Enabled; channel.BaudRate = ch.BaudRate; channel.LoopEnable = ch.LoopEnable; _channels.Add(channel); } }
public void Initialize(Device429 device429)//初始化通道 { for (int i = 0; i < 16; i++) { Channe429Receive ch = (Channe429Receive)device429.GetSpecificItem(i);//遍历dic,获取信息 var channel = new ChannelInfoUiReceive(); channel.Name = ch.Name; channel.ChannelID = ch.ChannelID; if (ch.Parity == 1) { channel.Parity = BaudRate.偶校验.ToString(); } else if (ch.Parity == 0) { channel.Parity = BaudRate.奇校验.ToString(); } else { channel.Parity = BaudRate.校验.ToString(); } channel.Enabled = ch.Enabled; channel.BaudRate = ch.BaudRate; channel.IsFilter = ch.isFilter; channel.ReceiveType = ch.receiveType; channel.DeepCount = ch.deepCount; channel.TimeCount = ch.timeCount; _channels.Add(channel); SetGatherParam(ch); } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); string[] pathParts = this.Name.Split('_'); _device429 = App.Instance.FlightBusManager.Bus429.GetSpecificItem(pathParts[pathParts.Length - 1]); updateTree(); _treeView.AfterCheck += treeView2AfterCheck; }
public A429ChannelTreeViewContainer(DevicePage devicePage) { InitializeComponent(); _devicePage = devicePage; string path = _devicePage.Name; string[] pathParts = path.Split('_'); Bus429 bus429 = (Bus429)App.Instance.FlightBusManager.GetBus(pathParts[1]); Device429 device429 = bus429.GetSpecificItem(pathParts[2]); }
private void SaveObject(object sender, EventArgs e) { if (treeViewContainer.flag == false) { MessageBox.Show("当前没有设备,无需保存工程!"); return; } SaveFileDialog sFD = new SaveFileDialog(); sFD.Title = "保存文件"; sFD.ShowHelp = true; sFD.Filter = "工程文件(*.cfg)|*.cfg"; //过滤格式 sFD.FilterIndex = 1; //格式索引 sFD.RestoreDirectory = false; sFD.InitialDirectory = "c:\\"; //默认路径 if (sFD.ShowDialog() == DialogResult.OK) { //获得保存文件的路径 string filePath = sFD.FileName; string xmlResult = string.Empty; DeviceForXml deviceForXml = new DeviceForXml(); List <DeviceForXml> list = new List <DeviceForXml>(); //遍历整个tree获取device foreach (var item in treeViewContainer.treeView.Nodes) { TreeNode treeNode = (TreeNode)item; foreach (var A429Dev in treeNode.Nodes) { TreeNode treeNodeA429Dev = (TreeNode)A429Dev; foreach (var treeNodes in treeNodeA429Dev.Nodes) { TreeNode treeNodes429 = (TreeNode)treeNodes; //string[] pathParts = treeNodes429.Name.Split('_'); Device429 _device429 = App.Instance.FlightBusManager.Bus429.GetSpecificItem(treeNodes429.Name); TopMenuVM topMenuVM = new TopMenuVM(_device429); topMenuVM.SaveSetting(); deviceForXml = topMenuVM._deviceInfo; list.Add(deviceForXml); } } } xmlResult = SimpleSerializer.Serialize <List <DeviceForXml> >(list); //保存 using (FileStream fsWrite = new FileStream(filePath, FileMode.OpenOrCreate, FileAccess.Write)) { byte[] buffer = Encoding.Default.GetBytes(xmlResult); fsWrite.Write(buffer, 0, buffer.Length); } } }
protected override void OnLoad(EventArgs e) { base.OnLoad(e); //设置对应的设备 string[] pathParts = this.Name.Split('_'); _device429 = App.Instance.FlightBusManager.Bus429.GetSpecificItem(pathParts[pathParts.Length - 1]); ChVm = new ChannelSendControlVm(_device429); //初始化数据 InitializeData(); //提示信息 ChVm.MsgShow.Initialize( () => this.StatusStrip.ClearMsg(), info => this.StatusStrip.ShowErrorInfo(info), info => this.StatusStrip.ShowWarningInfo(info), info => this.StatusStrip.ShowInfo(info)); _thread.ThreadEvent += OnProcess;//创建一个新的线程来处理count }
public TopMenuVM(Device429 device429) { this._device429 = device429; _deviceInfo = new DeviceForXml(); }
public ChannelSendControlVm(Device429 device429) { this._device429 = device429; }
} //是否允许文件保存 public ChannelReceiveControlVm(Device429 device429) { this._device429 = device429; }
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); } } }
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); } }