public static void Turn_On_LED(String IPAddr, Int32 channel, int intensity) { long lRet = -1; OPTControllerAPI OPTController = new OPTControllerAPI(); if (IPAddr == "") { Console.WriteLine("\nIP Address is not regular!"); return; } lRet = OPTController.CreateEtheConnectionByIP(IPAddr); if (lRet != 0) { Console.WriteLine("\nFail to connect by IP"); return; } else { if (OPTController.TurnOnChannel(channel) == 0) { Console.WriteLine("\nChannel Turned On successfully!"); if (OPTController.SetIntensity(channel, intensity) == 0) { Console.WriteLine("Set intensity successfully"); } else { Console.WriteLine("Fail to set intensity"); return; } } else { Console.WriteLine("\nChannel Failed to Turned on!"); return; } lRet = OPTController.DestoryEtheConnect(); if (0 != lRet) { Console.WriteLine("Failed to disconnect Ethernet connection by IP"); return; } else { Console.WriteLine("Successfully disconnected Ethernet connection by IP"); } } return; }
/// <summary> /// 断开连接,0:串口1:网口 /// </summary> public void Disconnect() { int ret = 0; switch (this.Mode) { case 0: ret = opt.ReleaseSerialPort(); break; case 1: ret = opt.DestoryEtheConnect(); break; default: ret = opt.ReleaseSerialPort(); break; } }