private void btnSearch_Click(object sender, EventArgs e) { int iIndex; int iCount = 0; AdamInformation adamObject; string[] szLocalIPs; adamList = new ArrayList(); Cursor.Current = Cursors.WaitCursor; ClearNodes(); if (AdamSocket.GetLocalNetwork(out szLocalIPs)) { foreach (string szLocalIP in szLocalIPs) { ArrayList adamCarryList; AdamSocket.GetAdamDeviceList(m_iTimeout, szLocalIP, out adamCarryList); if (adamCarryList.Count > 0) { for (iIndex = 0; iIndex < adamCarryList.Count; iIndex++) { adamObject = new AdamInformation(); adamObject = (AdamInformation)adamCarryList[iIndex]; if (adamList.Contains(adamObject) == false) { adamList.Add(adamObject); //Add Device to list InsertNode(iCount, adamObject); iCount = iCount + 1; } } } } } Cursor.Current = Cursors.Default; }
/// <summary> /// Init APAX controller information /// </summary> /// <returns></returns> public bool RefreshConfiguration() { //Query device information and network informations if (AdamSocket.GetAdamDeviceList("255.255.255.255", 2000, out m_adamList_Group)) { for (int i = 0; i < m_adamList_Group.Count; i++) { m_adamObject = (AdamInformation)m_adamList_Group[i]; string tmpIP = string.Format("{0}.{1}.{2}.{3}", m_adamObject.IP[0], m_adamObject.IP[1], m_adamObject.IP[2], m_adamObject.IP[3]); if (string.Compare(m_szIP, tmpIP) == 0) { break; } } } else { MessageBox.Show("Get module information failed!", "Error"); return(true); } //APAX Coupler Information this.labModuleName.Text = "APAX-PAC"; this.txtFwVer.Text = string.Format("{0:X2}.{1:X2}", m_adamObject.FwVer[0], m_adamObject.FwVer[1]); //Firmware Version if (m_sDSPFWVer != "") { this.txtFwVer2.Text = m_sDSPFWVer.Substring(0, 4).Insert(2, "."); //Kernel Firmware Version } if (adamType == AdamType.Apax5070) { if (m_adamModbusSocket.Connect(adamType, m_szIP, ProtocolType.Udp)) //FPGA Firmware Version (Should use udp to get FPGA version) { uint o_dwVer; if (m_adamModbusSocket.Configuration().GetFpgaVersion(out o_dwVer)) { this.txtFpgaFwVer.Text = o_dwVer.ToString("X4").Insert(2, "."); } } if ((Array.IndexOf(m_szSlotInfo, APAX_5090_STR) == -1) || (m_adamObject.HardwareType[0] == 0x01 && m_adamObject.HardwareType[1] == 0x01)) { if (tabControl1.TabPages.Contains(tabSerial)) { tabControl1.TabPages.RemoveAt(tabControl1.TabPages.Count - 1); } } else { if (!tabControl1.TabPages.Contains(tabSerial)) { tabControl1.TabPages.Add(tabSerial); } m_listIndexOfApax5090 = new List <int>(); for (int idx = 0; idx < m_szSlotInfo.Length; idx++) { if ((m_szSlotInfo[idx] != null) && (m_szSlotInfo[idx].IndexOf(APAX_5090_STR) > -1)) { m_listIndexOfApax5090.Add(idx); } } m_iApax5090TcpPorVals = new int[AdamControl.APAX_MaxSlot][]; RefreshSerialModulesComPortSetting(); } } else { if (m_adamModbusSocket.Connect(m_szIP, ProtocolType.Udp, portNum)) //FPGA Firmware Version (Should use udp to get FPGA version) { uint o_dwVer; if (m_adamModbusSocket.Configuration().GetFpgaVersion(out o_dwVer)) { this.txtFpgaFwVer.Text = o_dwVer.ToString("X4").Insert(2, "."); } } } m_adamModbusSocket.Disconnect(); txtDeviceName.Text = m_adamObject.DeviceName; txtDeviceDesc.Text = m_adamObject.Description; RefreshCurrentModuleInfo(); //Current modules information //Network information txtMacAddress.Text = string.Format("{0:X02}-{1:X02}-{2:X02}-{3:X02}-{4:X02}-{5:X02}", //MAC address m_adamObject.Mac[0], m_adamObject.Mac[1], m_adamObject.Mac[2], m_adamObject.Mac[3], m_adamObject.Mac[4], m_adamObject.Mac[5]); txtIPAddress.Text = string.Format("{0}.{1}.{2}.{3}", //IP address m_adamObject.IP[0], m_adamObject.IP[1], m_adamObject.IP[2], m_adamObject.IP[3]); txtSubnetAddress.Text = string.Format("{0}.{1}.{2}.{3}", //subnet mask m_adamObject.Subnet[0], m_adamObject.Subnet[1], m_adamObject.Subnet[2], m_adamObject.Subnet[3]); txtDefaultGateway.Text = string.Format("{0}.{1}.{2}.{3}", //default gateway m_adamObject.Gateway[0], m_adamObject.Gateway[1], m_adamObject.Gateway[2], m_adamObject.Gateway[3]); numHostIdle.Text = m_adamObject.HostIdleTime.ToString(); // Refresh Modbus address mapping RefreshModbusAddressSetting(); // Refresh FSV settings RefreshFSVSettingInfo(); return(true); }