//********************************************************************** /// <summary> /// Check the velocity devices in the Devices.ini are available or not. /// If some devices are unavailable, the Devices.ini should be changed to give /// tester all available devices. /// Author: Sashimi. /// </summary> public static List <String> CheckVelocityDeviceAvailable(List <string> keyName) { // There are all devices in Device.ini. List <string> notAvailable = new List <string>(); string groupName = "VelocityDevices"; ClientEngine ve = ClientEngine.GetClientEngine(); string GDDpath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "mds"); int startupflag = ve.Startup(GDDpath); Console.WriteLine("GDDPath:" + startupflag); CommsChannel channel = ve.OpenChannel(CommStack.BACnetIp); foreach (string deviceIP in keyName) { if (channel != null) { string strIP = myparseToValue(groupName, deviceIP); DeviceNode node = channel.StrToEntity(strIP); if (node != null) { Console.WriteLine("The device:" + deviceIP + "(" + strIP + ")" + " is availabe"); } else { notAvailable.Add(deviceIP); Console.WriteLine("There is no device in this ip address." + deviceIP + "(" + strIP + ")!"); } } else { Console.WriteLine("This channel is not available!"); } } channel.Dispose(); return(notAvailable); }
/// <summary> /// Check the velocity devices in the Devices.ini are available or not. /// If some devices are unavailable, the Devices.ini should be changed to give /// tester all available devices. /// </summary> /// <returns>list</returns> public static List <String> CheckVelocityDeviceAvailable() { // There are all devices in Device.ini. List <string> notAvailable = new List <string>(); IDictionary <string, string> AllDeviceInfo = new Dictionary <string, string> (); IDictionary <string, string> VelDeviceInfo = new Dictionary <string, string> (); AllDeviceInfo = AppConfigOper.mainOp.DevConfigs; foreach (string key in AllDeviceInfo.Keys) { if (key.ToUpper().StartsWith("VELOCITY")) { VelDeviceInfo.Add(key, AllDeviceInfo[key]); } } foreach (KeyValuePair <string, string> device in VelDeviceInfo) { Console.WriteLine("VelDeviceInfo: key={0},value={1}", device.Key, device.Value); } string NformPath = ""; RegistryKey Key; Key = Registry.LocalMachine; //Nform in Register table // The path is based on your pc // RegistryKey myreg = Key.OpenSubKey("software\\Liebert\\Nform"); RegistryKey myreg = Key.OpenSubKey("software\\Wow6432Node\\Liebert\\Nform"); NformPath = myreg.GetValue("InstallDir").ToString(); myreg.Close(); Console.WriteLine("NformPath:" + NformPath); ClientEngine ve = ClientEngine.GetClientEngine(); string GDDpath = System.IO.Path.Combine(NformPath, @"bin\mds"); System.IO.Directory.CreateDirectory(GDDpath); int startupflag = ve.Startup(GDDpath); Console.WriteLine("GDDPath:" + GDDpath); Console.WriteLine("startupflag:" + startupflag); CommsChannel channel = null; try { channel = ve.OpenChannel(CommStack.BACnetIp); } catch (Exception e) { Console.WriteLine("Can not open this channel! because: " + e.StackTrace.ToString()); } foreach (string deviceIp in VelDeviceInfo.Values) { if (channel != null) { DeviceNode node = channel.StrToEntity(deviceIp); if (node != null) { Console.WriteLine("The device:" + deviceIp + " is availabe"); } else { notAvailable.Add(deviceIp); Console.WriteLine("There is no device in this ip address." + deviceIp + "!"); } } else { Console.WriteLine("This channel is not available!"); } } channel.Dispose(); return(notAvailable); }
/// <summary> /// Check the velocity devices in the Devices.ini are available or not. /// If some devices are unavailable, the Devices.ini should be changed to give /// tester all available devices. /// </summary> /// <returns>list</returns> public static List <String> CheckVelocityDeviceAvailable() { // There are all devices in Device.ini. List <string> notAvailable = new List <string>(); Hashtable DeviceInfo = new Hashtable(); string DeviceConfigFile = AppConfigOper.getConfigValue("DeviceConfig"); DeviceInfo = AppConfigOper.GetDevicesInfo("velocity", DeviceConfigFile); string NformPath = ""; RegistryKey Key; Key = Registry.LocalMachine; //Nform in Register table RegistryKey myreg = Key.OpenSubKey("software\\Wow6432Node\\Liebert\\Nform"); NformPath = myreg.GetValue("InstallDir").ToString(); myreg.Close(); Console.WriteLine("NformPath:" + NformPath); ClientEngine ve = ClientEngine.GetClientEngine(); string GDDpath = System.IO.Path.Combine(NformPath, @"bin\mds"); System.IO.Directory.CreateDirectory(GDDpath); int startupflag = ve.Startup(GDDpath); Console.WriteLine("GDDPath:" + GDDpath); Console.WriteLine("startupflag:" + startupflag); CommsChannel channel = null; try { channel = ve.OpenChannel(CommStack.BACnetIp); } catch (Exception e) { Console.WriteLine("Can not open this channel! because: " + e.StackTrace.ToString()); } foreach (string deviceIp in DeviceInfo.Values) { if (channel != null) { DeviceNode node = channel.StrToEntity(deviceIp); if (node != null) { Console.WriteLine("The device:" + deviceIp + " is availabe"); } else { notAvailable.Add(deviceIp); Console.WriteLine("There is no device in this ip address." + deviceIp + "!"); } } else { Console.WriteLine("This channel is not available!"); } } channel.Dispose(); return(notAvailable); }