/// <summary> /// When change tab, refresh status, timer, counter related informations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { string strSelPageName = tabControl1.TabPages[tabControl1.SelectedIndex].Text; StatusBar_IO.Text = ""; m_adamSocket.Disconnect(); m_adamSocket.Connect(m_adamSocket.GetIP(), protoType, portNum); if (strSelPageName == "Module Information") { m_iFailCount = 0; m_iScanCount = 0; } else if (strSelPageName == "DO") { //Refresh safety information RefreshSafetySetting(); chbxEnableSafety.Checked = m_bIsEnableSafetyFcn; btnSetSafetyValue.Enabled = m_bIsEnableSafetyFcn; } if (tabControl1.SelectedIndex == 0) { this.timer1.Enabled = false; } else { this.timer1.Enabled = true; } }
/// <summary> /// When change tab, refresh status, timer, counter related informations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { uint uiWidth; bool bEnable = true; string strSelPageName = tabControl1.TabPages[tabControl1.SelectedIndex].Text; StatusBar_IO.Text = ""; m_adamSocket.Disconnect(); m_adamSocket.Connect(m_adamSocket.GetIP(), protoType, portNum); if (strSelPageName == "Module Information") { m_iFailCount = 0; m_iScanCount = 0; } else if (strSelPageName == "DI") { //Get DI Filter value if (m_adamSocket.DigitalInput().GetDigitalFilterMiniSignalWidth(m_idxID, out uiWidth, out bEnable)) { txtCntMin.Text = uiWidth.ToString(); chkBoxDiFilterEnable.Checked = bEnable; } } if (tabControl1.SelectedIndex == 0) { timer1.Enabled = false; } else { timer1.Enabled = true; } }
/// <summary> /// When change tab, refresh status, timer, counter related informations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { string strSelPageName = tabControl1.TabPages[tabControl1.SelectedIndex].Text; StatusBar_IO.Text = ""; m_adamSocket.Disconnect(); m_adamSocket.Connect(m_adamSocket.GetIP(), protoType, portNum); if (strSelPageName == "Module Information") { m_iFailCount = 0; m_iScanCount = 0; } else if (strSelPageName == "AI") { RefreshRanges(); RefreshAiSetting(); RefreshBurnoutSetting(true, true); //refresh burnout mask value and get burnout detect mode } if (listViewChInfo.SelectedIndices.Count == 0) { listViewChInfo.Items[0].Selected = true; } if (tabControl1.SelectedIndex == 0) { timer1.Enabled = false; } else { timer1.Enabled = true; } }
/// <summary> /// 将模块链路重新连接 /// </summary> /// <param name="Adam">链路Socket</param> /// <returns></returns> public static bool Reconnect(AdamSocket Adam) { bool state = false; if (Adam != null) { if (Adam.Connected == false) { string IP = Adam.GetIP(); state = Adam.Connect(AdamType.Adam6000, IP, ProtocolType.Tcp); } } return(state); }
/// <summary> /// When change tab, refresh status, timer, counter related informations /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { string strSelPageName = tabControl1.TabPages[tabControl1.SelectedIndex].Text; StatusBar_IO.Text = ""; m_adamSocket.Disconnect(); m_adamSocket.Connect(m_adamSocket.GetIP(), protoType, portNum); if (strSelPageName == "Module Information") { m_iFailCount = 0; m_iScanCount = 0; } else if (strSelPageName == "AI") { RefreshRanges(); RefreshAiSetting(); if (m_aConf.GetModuleName() == "5017H") RefreshBurnoutSetting(true, true); if (m_aConf.GetModuleName() == "5017") RefreshBurnoutSetting(false, true); if (m_aConf.GetModuleName() == "5017" || m_aConf.GetModuleName() == "5017H") RefreshAiSampleRate(); } if (tabControl1.SelectedIndex == 0) timer1.Enabled = false; else { if (listViewChInfo.SelectedIndices.Count == 0) listViewChInfo.Items[0].Selected = true; timer1.Enabled = true; } }
/// <summary> /// Refresh Modbus Address type and value /// </summary> private void RefreshModbusAddressSetting() { gvAddress.Items.Clear(); try { if (m_adamModbusSocket.Connect(m_adamModbusSocket.GetIP(), protoType, portNum)) { bool bFixed; m_adamModbusSocket.Configuration().GetModbusAddressMode(out bFixed); string[] szAddressType = new string[m_szSlotInfo.Length]; string[] szLength = new string[m_szSlotInfo.Length]; string[] szStartAddress = new string[m_szSlotInfo.Length]; //Update Modbus Address Setting tab ListViewItem[] listItemModule = new ListViewItem[m_szSlotInfo.Length]; for (int i = 0; i < m_szSlotInfo.Length; i++) { listItemModule[i] = new ListViewItem(i.ToString()); if (m_szSlotInfo[i] != null) { if (IsModuleSupportModbusSetting(m_szSlotInfo[i])) { listItemModule[i].SubItems.Add("APAX-" + m_szSlotInfo[i]); } else { listItemModule[i].SubItems.Add("APAX-" + m_szSlotInfo[i] + " : INVALID"); } } else { listItemModule[i].SubItems.Add("Empty"); } listItemModule[i].SubItems.Add(""); listItemModule[i].SubItems.Add(""); listItemModule[i].SubItems.Add(""); gvAddress.Items.Add(listItemModule[i]); } if (bFixed) { addressTypeValue.Text = "Fixed Mode"; for (int i = 0; i < m_szSlotInfo.Length; i++) { if ((m_szSlotInfo[i] != null) && (IsModuleSupportModbusSetting(m_szSlotInfo[i]))) { Apax5000Config apaxConfig = null; int iTemp; m_adamModbusSocket.Configuration().GetModuleConfig(i, out apaxConfig); if (apaxConfig.wDevType == 0x0001 || apaxConfig.wDevType == 0x0002) { szLength[i] = Convert.ToString(64); iTemp = 64 * i + 1; szAddressType[i] = "0X"; } else { szLength[i] = Convert.ToString(32); iTemp = 32 * i + 1; szAddressType[i] = "4X"; } szStartAddress[i] = iTemp.ToString(); } else { szAddressType[i] = "0X"; szStartAddress[i] = (0).ToString(); szLength[i] = (0).ToString(); } } } else { int[] o_iData; addressTypeValue.Text = "Flexible Mode"; m_adamModbusSocket.Modbus().ReadAdvantechRegs(60101, 64, out o_iData); for (int i = 0; i < m_szSlotInfo.Length; i++) { if (IsModuleSupportModbusSetting(m_szSlotInfo[i])) { int iStartAddress = o_iData[i * 2] % 10000; if (o_iData[i * 2] / 40000 == 1) { szAddressType[i] = "4X"; } else { szAddressType[i] = "0X"; } szStartAddress[i] = iStartAddress.ToString(); szLength[i] = o_iData[i * 2 + 1].ToString(); } else { szAddressType[i] = "0X"; szStartAddress[i] = (0).ToString(); szLength[i] = (0).ToString(); } } } UpdateInfoString(IDX_STARTADDRESS, szStartAddress); UpdateInfoString(IDX_ADDRESSTYPE, szAddressType); UpdateInfoString(IDX_LENGTH, szLength); } } catch { MessageBox.Show("Initialize UI Modbus address setting failed.", "Error"); } m_adamModbusSocket.Disconnect(); }
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) { string strSelPageName = tabControl1.TabPages[tabControl1.SelectedIndex].Text; int idx; float fHigh = 0, fLow = 0, fVal = 0; ushort usVal; StatusBar_IO.Text = ""; m_adamSocket.Disconnect(); m_adamSocket.Connect(m_adamSocket.GetIP(), protoType, portNum); if (strSelPageName == "Module Information") { m_iFailCount = 0; m_iScanCount = 0; } else if (strSelPageName == "AO") { RefreshRanges(); RefreshAoStartupValues(); RefreshSafetySetting(); chbxEnableSafety.Checked = m_bIsEnableSafetyFcn; //Set AO info idx = 0; //initial index if (m_adamSocket.AnalogOutput().GetCurrentValue(m_idxID, idx, out usVal)) { AnalogOutput.GetRangeHighLow(m_usRanges[idx], out fHigh, out fLow); fVal = AnalogOutput.GetScaledValue(m_usRanges[idx], usVal); RefreshOutputPanel(fHigh, fLow, fVal); } else { this.StatusBar_IO.Text += "GetValues() filed!"; } //synchronize channel status for (int i = 0; i < listViewChInfo.Items.Count; i++) { if (i == idx) { listViewChInfo.Items[i].Selected = true; } else { listViewChInfo.Items[i].Selected = false; } } string szTemp = AnalogOutput.GetRangeName(m_usRanges[idx]); for (int i = 0; i < cbxRange.Items.Count; i++) { if (szTemp == cbxRange.Items[i].ToString()) { cbxRange.SelectedIndex = i; break; } } } if (tabControl1.SelectedIndex == 0) { this.timer1.Enabled = false; } else { this.timer1.Enabled = true; } }