Ejemplo n.º 1
0
        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;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 连接光源 0:串口连接,1:IP地址连接,2:SN连接
        /// </summary>
        public bool Connect(TimeSpan timeout)
        {
            int ret = 0;

            switch (this.Mode)
            {
            case 0:
                ret = opt.InitSerialPort(this.Config);
                break;

            case 1:
                ret = opt.CreateEtheConnectionByIP(this.Config);
                break;

            case 2:
                ret = opt.CreateEtheConnectionBySN(this.Config);
                break;

            default:
                ret = opt.CreateEtheConnectionByIP(this.Config);
                break;
            }
            return(ret == 0);
        }