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> /// 设置单个通道亮度 /// </summary> /// <param name="Channel"></param> /// <param name="Value"></param> /// <returns></returns> public int SetIntensity(LightChn lightType, int Value) { return(opt.SetIntensity(SwitchChannel(lightType), Value)); }