private static void DebouncedSwitch_OnShortPress(uint data1, uint data2, DateTime time) { Lcd.Write("SSSS"); Debug.Print(_cntr++ + " Short press"); //Thread.Sleep(1000); //Lcd.Clear(); }
/// <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); } }
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); } }
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); }
public static void SendPacketMessage(Object state) { Debug.Print("Timer Trigger"); _lcd.Write("Send"); ushort pathLength = 1; int payloadValue = 25000; // byte payloadValue = (byte)_rand.Next(11); // Change both for different payload sizes byte[] payload = BitConverter.GetBytes(payloadValue); int payloadLength = payload.Length; int sendSize = AppGlobal.SendMessageSize; var routedMsg = new byte[sendSize]; ushort originator = AppGlobal.AppPipe.MACRadioObj.RadioAddress; AppGlobal.ClassificationType classificationType = AppGlobal.ClassificationType.Send; byte TTL = Byte.MaxValue; ushort[] path = { originator }; var headerSize = AppGlobal.MoteMessages.Compose.SendPacket(routedMsg, originator, classificationType, _sendMsgNum, TTL, (ushort)payloadLength); // add payload AppGlobal.MoteMessages.AddPayload.SendPacket(routedMsg, headerSize, payload, payloadLength); #if DBG_SIMPLE Debug.Print("\nSending to " + RoutingGlobal.Parent); #endif // If in a reset, do not forward TODO: Change this to "spray" if (RoutingGlobal._color == Color.Red) { #if DBG_VERBOSE || DBG_SIMPLE Debug.Print("\tIn a Reset wave... not forwarded"); #endif return; } // If parent is available, pass it on if (RoutingGlobal.IsParent) { Debug.Print("routed message len: " + routedMsg.Length); var status = RoutingGlobal.SendToParent(AppGlobal.AppPipe, routedMsg, sendSize); Debug.Print("status " + status); if (status != 999) { _sendMsgNum++; RoutingGlobal.UpdateNumTriesInCurrentWindow_Parent(1); #if !DBG_LOGIC Debug.Print("Updated numTriesInCurrentWindow for Parent " + RoutingGlobal.Parent + "; new value = " + RoutingGlobal.GetNumTriesInCurrentWindow_Parent()); #endif } else //Retry once { #if !DBG_LOGIC Debug.Print("Retrying packet"); #endif RoutingGlobal.CleanseCandidateTable(AppGlobal.AppPipe); Candidate tmpBest = CandidateTable.GetBestCandidate(false); AppGlobal.TempParent = tmpBest.GetMacID(); status = AppGlobal.SendToTempParent(AppGlobal.AppPipe, routedMsg, sendSize); if (status != 999) { _sendMsgNum++; tmpBest.UpdateNumTriesInCurrentWindow(1); #if !DBG_LOGIC Debug.Print("Updated numTriesInCurrentWindow for TempParent " + AppGlobal.TempParent + "; new value = " + tmpBest.GetNumTriesInCurrentWindow()); #endif } } } }