示例#1
0
 public Demuxer()
 {
     temporaryStorage = new Dictionary <int, MSDU>();
     buffer           = new byte[0];
     lastAPID         = -1;
     lastFrame        = -1;
     FrameLoss        = 0;
     LengthFails      = 0;
     CRCFails         = 0;
     FrameJumps       = 0;
     Bugs             = 0;
     Packets          = 0;
     manager          = null;
 }
示例#2
0
        public static void HandleFile(string filename, XRITHeader fileHeader, DemuxManager dm = null)
        {
            if (dm != null)
            {
                dm.incProductCount(fileHeader.Product.ID);
            }

            if (byCompressionTypeHandler.ContainsKey((int)fileHeader.Compression))
            {
                byCompressionTypeHandler[(int)fileHeader.Compression](filename, fileHeader);
            }
            else if (byProductIdHandler.ContainsKey(fileHeader.Product.ID))
            {
                byProductIdHandler[fileHeader.Product.ID](filename, fileHeader);
            }
            else
            {
                DefaultHandler(filename, fileHeader);
            }
        }
示例#3
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            base.Initialize();
            mtx          = new Mutex();
            cn           = new Connector();
            demuxManager = new DemuxManager();
            demuxManager.RecordToFile = config.RecordIntermediateFile;
            cn.StatisticsAvailable   += (Statistics_st data) => {
                mtx.WaitOne();
                statistics = data;
                mtx.ReleaseMutex();

                if (data.phaseCorrection != lastPhaseCorrection && lastPhaseCorrection != -1)
                {
                    //UIConsole.GlobalConsole.Error(String.Format("Costas Loop Desync! Phase correction was {0} and now is {1}.", lastPhaseCorrection, data.phaseCorrection));
                    //desyncCount++;
                }
                frameLockLed.Color     = data.frameLock == 1 ? Color.Lime : Color.Red;
                lastPhaseCorrection    = data.phaseCorrection;
                satelliteBusyLed.Color = data.vcid != 63 && data.frameLock == 1 ? Color.Lime : Color.Red;
                if (heartBeatLed.Color != Color.Lime)
                {
                    heartBeatLed.Color = Color.Lime;
                    heartBeatCount     = 0;
                }
            };
            cn.ChannelDataAvailable       += (byte[] data) => demuxManager.parseBytes(data);
            cn.ConstellationDataAvailable += (float[] data) => cons.updateConstellationData(data);
            statistics = new Statistics_st();
            cn.Start();

            FDImageManager.Start();
            XXImageManager.Start();
            NHImageManager.Start();
            SHImageManager.Start();
            USImageManager.Start();
            FMImageManager.Start();
        }
示例#4
0
 public Demuxer(DemuxManager manager) : this()
 {
     this.manager = manager;
 }
示例#5
0
        public HeadlessMain()
        {
            AppDomain.CurrentDomain.UnhandledException += CrashReport.DefaultExceptionHandler;
            ManageConfig();

            EventMaster.On(EventTypes.ConfigChangeEvent, d => {
                var data = (ConfigChangeEventData)d.Data;
                ProgConfig.UpdateProperty(data.Name, data.Value);
                EventMaster.Post("configSaved", data.Name);
                SetConfigVars();
            });

            SetConfigVars();

            var fdFolder  = PacketManager.GetFolderByProduct(NOAAProductID.GOES13_ABI, (int)ScannerSubProduct.INFRARED_FULLDISK);
            var xxFolder  = PacketManager.GetFolderByProduct(NOAAProductID.GOES13_ABI, (int)ScannerSubProduct.INFRARED_AREA_OF_INTEREST);
            var nhFolder  = PacketManager.GetFolderByProduct(NOAAProductID.GOES13_ABI, (int)ScannerSubProduct.INFRARED_NORTHERN);
            var shFolder  = PacketManager.GetFolderByProduct(NOAAProductID.GOES13_ABI, (int)ScannerSubProduct.INFRARED_SOUTHERN);
            var usFolder  = PacketManager.GetFolderByProduct(NOAAProductID.GOES13_ABI, (int)ScannerSubProduct.INFRARED_UNITEDSTATES);
            var fmFolder  = PacketManager.GetFolderByProduct(NOAAProductID.GOES16_ABI, (int)ScannerSubProduct.NONE);
            var unkFolder = PacketManager.GetFolderByProduct(NOAAProductID.GOES13_ABI, (int)ScannerSubProduct.NONE); // Same for any unknown ABI

            FDImageManager  = new ImageManager(fdFolder, "Full Disk");
            XXImageManager  = new ImageManager(xxFolder, "Area of Interest");
            NHImageManager  = new ImageManager(nhFolder, "Northern Hemisphere");
            SHImageManager  = new ImageManager(shFolder, "Southern Hemisphere");
            USImageManager  = new ImageManager(usFolder, "United States");
            FMImageManager  = new ImageManager(fmFolder, "FM1");
            UNKImageManager = new ImageManager(unkFolder, "Unknown");

            FDImageManager.InitMapDrawer();
            XXImageManager.InitMapDrawer();
            NHImageManager.InitMapDrawer();
            SHImageManager.InitMapDrawer();
            USImageManager.InitMapDrawer();
            FMImageManager.InitMapDrawer();
            UNKImageManager.InitMapDrawer();

            directoryHandler = new DirectoryHandler(FileHandler.FinalFileFolder, "/data");

            mtx = new Mutex();
            cn  = new Connector();

            demuxManager = new DemuxManager {
                RecordToFile = ProgConfig.RecordIntermediateFile
            };
            cn.StatisticsAvailable += data => {
                mtx.WaitOne();
                statistics = data;
                mtx.ReleaseMutex();

                if (ProgConfig.SaveStatistics)
                {
                    ThreadPool.QueueUserWorkItem((a) => StatisticsManager.Update(new DBStatistics {
                        SCID                  = data.scid,
                        VCID                  = data.vcid,
                        PacketNumber          = (long)data.packetNumber,
                        VitErrors             = data.vitErrors,
                        FrameBits             = data.frameBits,
                        RSErrors0             = data.rsErrors [0],
                        RSErrors1             = data.rsErrors [1],
                        RSErrors2             = data.rsErrors [2],
                        RSErrors3             = data.rsErrors [3],
                        SignalQuality         = data.signalQuality,
                        SyncCorrelation       = data.syncCorrelation,
                        PhaseCorrection       = data.phaseCorrection,
                        LostPackets           = (long)data.lostPackets,
                        AverageVitCorrections = data.averageVitCorrections,
                        AverageRSCorrections  = data.averageRSCorrections,
                        DroppedPackets        = (long)data.droppedPackets,
                        SyncWord              =
                            $"{data.syncWord[0]:X02}{data.syncWord[1]:X02}{data.syncWord[2]:X02}{data.syncWord[3]:X02}",
                        FrameLock = data.frameLock > 0,
                    }));
                }

                stModel.Refresh(statistics);
                httpsv.WebSocketServices.Broadcast(stModel.toJSON());
            };

            cn.ChannelDataAvailable       += demuxManager.parseBytes;
            cn.ConstellationDataAvailable += data => {
                var cm = new ConstellationModel(data);
                if (httpsv.IsListening)
                {
                    httpsv.WebSocketServices.Broadcast(cm.toJSON());
                }
            };

            statistics = new Statistics_st();
            stModel    = new StatisticsModel(statistics);
            UIConsole.Log("Headless Main Created");
            UIConsole.Log($"HTTP Server at port {ProgConfig.HTTPPort}");
            httpsv = new HttpServer(ProgConfig.HTTPPort)
            {
                RootPath = Path.GetFullPath(Path.Combine(".", "web"))
            };

            httpsv.OnGet += HandleHTTPGet;
            httpsv.AddWebSocketService("/mainws", () => new WSHandler {
                dh = directoryHandler
            });

            UIConsole.MessageAvailable += (data) => {
                var cm = new ConsoleModel(data.Priority.ToString(), data.Message);
                if (httpsv.IsListening)
                {
                    httpsv.WebSocketServices["/mainws"].Sessions.Broadcast(cm.toJSON());
                }

                messageListMutex.WaitOne();
                if (messageList.Count >= MAX_CACHED_MESSAGES)
                {
                    messageList.RemoveAt(0);
                }
                messageList.Add(data);
                messageListMutex.ReleaseMutex();
            };
        }