Exemplo n.º 1
0
        public static void Main()
        {
            Debug.EnableGCMessages(false);
            var radarInt = new RadarInterface();

            radarInt.TurnOff();
            Debug.Print(DebuggingSupport.SetupBorder);
            Debug.Print(VersionInfo.VersionBuild(Assembly.GetExecutingAssembly()));
            _lcd.Write("Clnt");

            Thread.Sleep(3000);
            try
            {
                var macBase = SystemGlobal.GetMAC();
                //#warning delete this when fixed
                //				macBase.OnReceive+=(mac, time) => { };
                Debug.Print(DebuggingSupport.MacInfo(macBase));
                Debug.Print(DebuggingSupport.SetupBorder);

                macBase.OnNeighborChange += Routing.Routing_OnNeighborChange;

                // Set up serial & pass it on to the components that need it
                var serialComm = new SerialComm("COM1", AppMsgHandler.SerialCallback_client_node);
                temComm = serialComm;
                serialComm.Open();

                if (macBase is OMAC)
                {
                    const int waitForMac = 30;
#if !DBG_LOGIC
                    Debug.Print("Waiting " + waitForMac + " sec");
#endif
                    Thread.Sleep(waitForMac * 1000);
                }

                // Initialize System Global
                SystemGlobal.Initialize(SystemGlobal.NodeTypes.Client);

                // Set up the local manager
                //LocalServer.Initialize(macBase, Lcd, SensorNodeGlobal.PinDefs.EnactResetPort);
                //LocalServer.Initialize(macBase, null);

                // Initialize shared vars
                VersionInfo.Initialize(Assembly.GetExecutingAssembly());

                // Set the app version
                //LocalManagerGlobal.Shared.SharedVars.ProgramVersion = VersionInfo.AppVersion;

                //Initialize routing
                var routing = new Routing(macBase, null, 1);

                // Allow additional sleep to "time-shift" routing and heartbeats (NetManager)
                const int additionalSleep = 60;
#if !DBG_LOGIC
                Debug.Print("Additional sleep to \"time-shift\" routing and heartbeats (NetManager)");
#endif
                Thread.Sleep(additionalSleep * 1000);

                // Initialize application message handler
                AppMsgHandler.Initialize(macBase, _lcd, serialComm, SendPacketInterval);

                // Initialize the Net Manager
                NetManager.Initialize(macBase);

                // Initialize the Neighborhood Manager
                NeighborInfoManager.Initialize(macBase);

                // Sleep forever
                Thread.Sleep(Timeout.Infinite);
            }

            catch (Exception ex)
            {
                Debug.Print("System exception " + ex);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// The main program
        /// </summary>
        /// <exception cref="InvalidOperationException"></exception>
        /// <exception cref="IOException"></exception>
        public static void Main()
        {
            var radarInt = new RadarInterface();

            radarInt.TurnOff();

            Debug.Print(DebuggingSupport.SetupBorder);
            Debug.Print(VersionInfo.VersionBuild(Assembly.GetExecutingAssembly()));
            _lcd.Write("Rely");

            Thread.Sleep(3000);
            try
            {
                var macBase = SystemGlobal.GetMAC();
                //#warning delete this when fixed
                //				macBase.OnReceive+=(mac, time) => { };
                Debug.Print(DebuggingSupport.MacInfo(macBase));
                Debug.Print(DebuggingSupport.SetupBorder);

                macBase.OnNeighborChange += Routing.Routing_OnNeighborChange;

                if (macBase is OMAC)
                {
                    const int waitForMac = 30;
#if !DBG_LOGIC
                    Debug.Print("Waiting " + waitForMac + " sec");
#endif
                    Thread.Sleep(waitForMac * 1000);
                }

                // Initialize System Global
                SystemGlobal.Initialize(SystemGlobal.NodeTypes.Relay);

                // Set up the local manager
                //LocalServer.Initialize(macBase, Lcd, SensorNodeGlobal.PinDefs.EnactResetPort);
                //LocalServer.Initialize(macBase, null);

                // Initialize shared vars
                VersionInfo.Initialize(Assembly.GetExecutingAssembly());

                // Set the app version
                //LocalManagerGlobal.Shared.SharedVars.ProgramVersion = VersionInfo.AppVersion;

                //Initialize routing
                var routing = new Routing(macBase, null, 1);

                // Allow additional sleep to "time-shift" routing and heartbeats (NetManager)
                const int additionalSleep = 60;
#if !DBG_LOGIC
                Debug.Print("Additional sleep to \"time-shift\" routing and heartbeats (NetManager)");
#endif
                Thread.Sleep(additionalSleep * 1000);

                // Initialize application message handler
                AppMsgHandler.Initialize(macBase, _lcd);

                // Initialize the Net Manager
                NetManager.Initialize(macBase);

                // Initialize the Neighborhood Manager
                NeighborInfoManager.Initialize(macBase);

                //SystemGlobal.PrintNeighborList(macBase);

                // todo *** remove this
                //var neighborList = MACBase.NeighborListArray();
                //while (true)
                //{
                //    macBase.NeighborList(neighborList);
                //    SystemGlobal.PrintNeighborList("Neighbor list for Relay [" + macBase.MACRadioObj.RadioAddress + "]: ", neighborList);
                //    Thread.Sleep(30 * 1000);
                //}

                // Sleep forever
                Thread.Sleep(Timeout.Infinite);
            }

            catch (Exception ex)
            {
                Debug.Print("System exception " + ex);
            }
        }
Exemplo n.º 3
0
        public static void Main()
        {
            Samraksh.eMote.RadarInterface radarInt = new Samraksh.eMote.RadarInterface();
            radarInt.TurnOff();
            Debug.Print(DebuggingSupport.SetupBorder); //===================
            Debug.EnableGCMessages(false);             // We don't want to see garbage collector messages in the Output window

            Debug.Print(VersionInfo.VersionBuild(Assembly.GetExecutingAssembly()));
            Thread.Sleep(3000);

            _lcd.Write("Base");

            try
            {
                var macBase = SystemGlobal.GetMAC();

                Debug.Print(DebuggingSupport.MacInfo(macBase));
                Debug.Print(DebuggingSupport.SetupBorder);                      //===================
                macBase.OnNeighborChange += Routing.Routing_OnNeighborChange;
                //macBase.OnReceiveAll += macBase_OnReceiveAll;

                // Set up serial & pass it on to the components that need it
                var serialComm = new SerialComm("COM1", AppMsgHandler.SerialCallback_base_node);
                serialComm.Open();

                // Periodically send Base Watchdog message to PC
                //		This is similar to Heartbeat in Net Manager but does not indicate network liveness.
                //		Instead, it is used
                //		- by the PC Visualizer Data Collector to determine if the Base node is connected to the PC and is running
                //		- by Visualizer to determine if Data Collector is running and connected to the Base node
                var baseWatchdogTimer = new SimplePeriodicTimer(callBackValue =>
                {
                    var msg = BaseGlobal.PCMessages.Compose.BaseWatchdog(_baseLiveMsgNum);
                    _baseLiveMsgNum++;
                    serialComm.Write(msg);
                }, null, 0, BaseGlobal.BaseWatchdogIntervalMs);
                baseWatchdogTimer.Start();

                if (macBase is OMAC)
                {
                    const int waitForMac = 30;
#if !DBG_LOGIC
                    Debug.Print("\tWaiting " + waitForMac + " sec");
#endif
                    Thread.Sleep(waitForMac * 1000);
                }

                // Initialize System Global
                SystemGlobal.Initialize(SystemGlobal.NodeTypes.Base);

                // Initialize routing
                var routing = new Routing(macBase, null);

                // Allow additional sleep to "time-shift" routing and heartbeats (NetManager)
                Thread.Sleep(60 * 1000);

                // Initialize application message handler
                AppMsgHandler.Initialize(macBase, _lcd, serialComm);

                // Initialize network manager
                NetManager.Initialize(macBase, serialComm);

                // Initialize neighborhood manager
                NeighborInfoManager.Initialize(macBase, serialComm);
            }
            catch
            {
                //Lcd.Write("Err");
                //Thread.Sleep(Timeout.Infinite);
            }

            // Sleep forever
            Thread.Sleep(Timeout.Infinite);
        }