Esempio n. 1
0
        static void Main(string[] args)
        {
            #region Camera
            RaspberryCamera tempCamera = RaspberryCamera.GetInstance();
            tempCamera.StartStreaming(pictureSize, fps);
            Console.WriteLine("Init Camera --- success");
            #endregion

            #region Init UDP manager

            Console.Write("Init UDP manager");
            UdpManager tempUdpManager = UdpManager.GetInstance();
            tempUdpManager.InitUdp(LocalUdpPort, InterNetwork.UdpListenTaskDelegate);
            Console.WriteLine(" --- success");

            #endregion

            #region Init Serial Manager

            Console.Write("Init SERIAL manager ");
            SerialManager tempSerialManager = SerialManager.GetInstance();
            while (true)
            {
                string[] ports    = SerialManager.GetAllVaildPorts();
                bool     signFind = false;
                foreach (string i in ports)
                {
                    if (i.Contains("USB"))
                    {
                        SerialManager.SerialPortWithGuid portWithGuid = tempSerialManager.Add(i, BaudRate, Parity.None, RaspberrySerial.TargetDataReceivedEventHandler);
                        RaspberrySerial.PortGuid = portWithGuid.Guid;
                        RaspberrySerial.StartReceive(portWithGuid.Serial);
                        Console.Write("Select" + i);
                        signFind = true;
                        break;
                    }
                }
                if (!signFind)
                {
                    Console.WriteLine("The system is waiting for a serial port device");
                    Thread.Sleep(1000);
                }
                else
                {
                    break;
                }
            }
            Console.WriteLine(" --- success");
            #endregion
            if (Debugger.IsAttached)
            {
                while (true)
                {
                    Thread.Sleep(1000);
                }
            }

            Console.ReadLine();
            tempCamera.StopStreaming();
            StateManager.GetInstance().FindServer = false;
            tempSerialManager.GetPort(RaspberrySerial.PortGuid).Serial.Dispose();
            Environment.Exit(0);
        }
Esempio n. 2
0
 public static RaspberryCamera GetInstance()
 {
     return(_instance ?? (_instance = new RaspberryCamera()));
 }