コード例 #1
0
ファイル: TrafficHandler.cs プロジェクト: bm98/XPVTraffic
        /// <summary>
        /// Initialize the Link with LiveTraffic
        ///  this will init the receiver and pace outbound messages every 10 sec
        ///  Connects to default ports
        /// </summary>
        /// <param name="hostIP">The LiveTraffic plugin host</param>
        /// <returns>True if successfull (else see Error content)</returns>
        public bool EstablishLink(string hostIP, uint numAcft, uint numVFR)
        {
            Logger.Instance.Log($"TrafficHandler-EstablishLink to: {hostIP}");
            if (!Valid)
            {
                return(false);
            }

            m_numAcft = numAcft;
            m_numVFR  = numVFR;

            m_userAcft = new UserAcft( );
            // setup Comm
            m_host = hostIP;
            try {
                LT_Traffic      = new UDPsender(m_host, RealTraffic.PortTrafficUDP);
                LT_Weather      = new UDPsender(m_host, RealTraffic.PortWeatherUDP);
                LTLink          = new TCPclient(m_host, RealTraffic.PortLinkTCP);
                LTLink.LTEvent += LTLink_LTEvent;
            }
            catch (Exception e) {
                Error = $"Error: {e.Message}";
                Logger.Instance.Log($"TrafficHandler: {Error}");
                return(false);
            }
            //
            Valid = LTLink.Connect( ); // if successful this triggers the reception of messages;
            if (!Valid)
            {
                Error = $"Error: {LTLink.Error}";
            }

            Logger.Instance.Log($"TrafficHandler: {Error}");
            return(Valid);
        }
コード例 #2
0
ファイル: TrafficHandler.cs プロジェクト: bm98/XPVTraffic
 /// <summary>
 /// Shut Link to LiveTraffic down
 /// </summary>
 public void RemoveLink()
 {
     Logger.Instance.Log($"TrafficHandler-RemoveLink");
     Valid = false;
     Error = "";
     try {
         LTLink.LTEvent -= LTLink_LTEvent;
         LT_Traffic      = null;
         LT_Weather      = null;
         LTLink.Disconnect( );
         m_userAcft = null;
         POOL       = null;
     }
     catch (Exception e) {
         Error = $"Error: {e.Message}";
         Logger.Instance.Log($"TrafficHandler: {Error}");
     }
 }
コード例 #3
0
        /// <summary>
        ///  Constructor for the ImageProcessing class
        /// </summary>
        /// <param name="cameraData"></param>
        /// <param name="mainWindow"></param>
        public ImageProcessing(ICamera cameraData, MainWindow mainWindow)
        {
            // only genrate colorimage if the mainwindow is present and the color option is clicked
            if (mainWindow != null && mainWindow.colorClicked)
            {
                cameraData.GenerateColorImage(true);
                this.mainWindow = mainWindow;
                showWindow      = true;
            }


            this.cameraData = cameraData;

            // create UDPsender object responsible outgoing data(via UDP socket)
            udpSender = new UDPsender();

            // create TCPserv object responsible ingoing commands(via TCP socket)
            commands = new TCPserv(this);

            // create Thread for running the TCPserv and start it
            TCPthread = new Thread(commands.StartListening);
            TCPthread.Start();


            // listen for images from the Camera
            cameraData.EmguArgsProcessed += EmguImageReceived;

            // listen for status changes from the camera object's kinectSensor
            cameraData.ChangeStatusText += ChangeStatusText;

            // get handle to Kinectdata
            this.cameraData = cameraData;



            //this.screen = new DisplacementScreen();
            int[] irdims = cameraData.IRFrameDImensions();
            int   height = irdims[0];
            int   width  = irdims[1];



            this.screen = new ExtrapolationScreen(height, width);



            int padding = Properties.UserSettings.Default.IRPixelPadding;

            mask = new Rectangle(padding, padding, width - (padding * 2), height - (padding * 2));

            int kernelSize = Properties.UserSettings.Default.KernelSize;

            this.kernel = CvInvoke.GetStructuringElement(ElementShape.Ellipse, new System.Drawing.Size(kernelSize, kernelSize), new System.Drawing.Point(-1, -1));



            cols      = Properties.UserSettings.Default.GridColums;
            rows      = Properties.UserSettings.Default.GridRows;
            maxPoints = rows * cols;
            hung      = new Hungarian(maxPoints, maxPoints);
        }