Beispiel #1
0
 private void BroadcastBasis()
 {
     IGC.SendBroadcastMessage(_turtleInit, "A;" + _basisVecA);
     IGC.SendBroadcastMessage(_turtleInit, "B;" + _basisVecB);
     IGC.SendBroadcastMessage(_turtleInit, "Up;" + _basisVecUp);
     IGC.SendBroadcastMessage(_turtleInit, "Origin;" + _origin);
 }
Beispiel #2
0
        private void LogStatus <TData>(TData status)
        {
            var statusString = $"[{uuid}] {status}";

            IGC.SendBroadcastMessage(this.statusTag, statusString);
            this.statusLogger.OutputLine(statusString, false);
        }
        public void Main(string argument, UpdateType updateSource)
        {
            // Echo some information about 'me' and why we were run
            Echo("Source=" + updateSource.ToString());
            Echo("Me=" + Me.EntityId.ToString("X"));
            Echo(Me.CubeGrid.CustomName);

            if (!_areWeInited)
            {
                InitMessageHandlers();
                _areWeInited = true;
            }

            // always check for IGC messages in case some aren't using callbacks
            _wicoIGC.ProcessIGCMessages();
            if ((updateSource & UpdateType.IGC) > 0)
            {
                // we got a callback for an IGC message.
                // but we already processed them.
            }
            else if ((updateSource & _utTriggers) > 0)
            {
                // if we got a 'trigger' source, send out the received argument
                IGC.SendBroadcastMessage(_broadCastTag, argument);
                Echo("Sending Message:\n" + argument);
            }
            else if ((updateSource & _utUpdates) > 0)
            {
                // it was an automatic update

                // this script doesn't have anything to do in this section
            }
        }
 public void Main(string argument, UpdateType updateSource)
 {
     if (argument.Equals("door"))
     {
         IGC.SendBroadcastMessage(channel, data, TransmissionDistance.TransmissionDistanceMax);
     }
 }
Beispiel #5
0
 void CallHelp(Vector3D position)
 {
     if (callHelp)
     {
         IGC.SendBroadcastMessage <Vector3D>(commsTag, position);
     }
 }
 void BroadcastStatus()
 {
     if (Initialized)
     {
         IGC.SendBroadcastMessage("ACC", Cruise.AdaptiveTargetSpeed, TransmissionDistance.CurrentConstruct);
     }
 }
Beispiel #7
0
        void NavGoTarget(Vector3D vTarget, int modeArrival = MODE_ARRIVEDTARGET, int stateArrival = 0, double DistanceMin = 50, string TargetName = "", double maxSpeed = 9999, bool bGo = true)
        {
            string data = NAVSerializeCommand(vTarget, modeArrival, stateArrival, DistanceMin, TargetName, maxSpeed, bGo);

            IGC.SendBroadcastMessage(WICOB_NAVSTART, data, TransmissionDistance.CurrentConstruct);
//            sStartupError += "Sent message=\n" + data;
        }
        void HandleMessage()
        {
            while (directiveListener.HasPendingMessage)
            {
                var directive = GreedleDirective.FromJSON(JSON.Parse(directiveListener.AcceptMessage().As <string>()));
                switch (directive.type)
                {
                case GreedleDirective.DirectiveType.Respond:
                    IGC.SendBroadcastMessage(
                        "greedle_response",
                        JSON.Stringify(GreedleResponse.ToJSON(new GreedleResponse()
                    {
                        name     = name,
                        position = mainControl.GetPosition()
                    }))
                        ); break;

                case GreedleDirective.DirectiveType.Target:
                {
                    if (directive.targetDirective.addressedTo == name)
                    {
                        Target(directive.targetDirective.target);
                    }
                    break;
                }
                }
            }
        }
Beispiel #9
0
        public void Main(string argument, UpdateType updateSource)
        {
            // Echo some information aboue 'me' and why we were run
            Echo("Source=" + updateSource.ToString());
            Echo("Me=" + Me.EntityId.ToString("X"));
            Echo(Me.CubeGrid.CustomName);

            if (!bInit)
            {
                InitMessageHandlers();
                bInit = true;
            }

            // use if not setting callbacks for any of the desired channels
            //            if (bInit) wicoIGC.ProcessIGCMessages();

            if ((updateSource & UpdateType.IGC) > 0)
            {
                // we got a callback for an IGC message.
                // There might be multiple incoming IGC messages
                wicoIGC.ProcessIGCMessages();
            }
            else if ((updateSource & utTriggers) > 0)
            {
                // if we got a 'trigger' source, send out the received argument
                IGC.SendBroadcastMessage(sBroadCastTag, argument);
            }
            else if ((updateSource & utUpdates) > 0)
            {
                // it was an automatic update
            }
        }
Beispiel #10
0
        public void Main(string argument, UpdateType updateSource)
        {
            IMyTextPanel LCDWritingScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(lcdName);



            // If setupcomplete is false, run Setup method.
            if (!setupcomplete)
            {
                Echo("Running setup.");
                Setup();
            }
            else
            {
                // Create our message. We first make it a string, and then we "box" it as an object type.
                string messageOut = LCDWritingScreen.GetText();

                // Through the IGC variable we issue the broadcast method. IGC is "pre-made",
                // so we don't have to declare it ourselves, just go ahead and use it.
                IGC.SendBroadcastMessage(broadcastChannel, messageOut, TransmissionDistance.TransmissionDistanceMax);

                // To create a listener, we use IGC to access the relevant method.
                // We pass the same tag argument we used for our message.
                IGC.RegisterBroadcastListener(broadcastChannel);
            }
        }
Beispiel #11
0
        public void Main(string argument, UpdateType updateSource)
        {
            count++;
            string message = "test message " + count;

            IGC.SendBroadcastMessage <string>(TAG, message, TransmissionDistance.TransmissionDistanceMax);
            Echo("send: " + message);
        }
Beispiel #12
0
 private void SetEnemy(MyDetectedEntityInfo info)
 {
     lastEnemy   = new Enemy(info);
     contactTime = Clock.Runtime;
     if (!detected && callHelp)
     {
         IGC.SendBroadcastMessage <Vector3D>(commsTag, info.Position);
     }
     detected = true;
 }
Beispiel #13
0
 public void Message(string message)
 {
     Echo(message);
     logScreen?.WriteText(message, true);
     logScreen?.WriteText("\n", true);
     if (!string.IsNullOrEmpty(TransmitTag) && (Antenna?.IsWorking ?? false))
     {
         IGC.SendBroadcastMessage(TransmitTag, message);
     }
 }
        public void SendMessage(string request)
        {
            Dictionary <string, object> message = new Dictionary <string, object>
            {
                ["shipID"]  = Me.CubeGrid.EntityId,
                ["request"] = request
            };

            Echo(string.Format("Sending message:\n{0}", EncodeMessage(message)));
            IGC.SendBroadcastMessage("docking", EncodeMessage(message));
        }
 void Abort(bool selfDestruct = false)
 {
     schedule.Clear();
     if (selfDestruct)
     {
         foreach (string code in Register.GetMissionCodes())
         {
             IGC.SendBroadcastMessage(code, "ABORT");
         }
     }
     AbortAllLaunches();
 }
Beispiel #16
0
        public void Main(string argument, UpdateType updateSource)
        {
            if (
                (updateSource & (UpdateType.Trigger | UpdateType.Terminal)) > 0 || // run by a terminal action
                (updateSource & (UpdateType.Mod)) > 0 || // script run by a mod
                (updateSource & (UpdateType.Script)) > 0 // this pb run by another script (PB)
                )
            {                                            // script was run because of an action
                if (argument != "")
                {
                    // if we are given an argument, send it out over our broadcast channel
                    IGC.SendBroadcastMessage(_broadCastTag, argument);
                    Echo("Sending message:\n" + argument);
                }
            }

            if ((updateSource & UpdateType.IGC) > 0)
            { // script was run because of incoming IGC message
                if (_myBroadcastListener.HasPendingMessage)
                {
                    var myIGCMessage = _myBroadcastListener.AcceptMessage();
                    if (myIGCMessage.Tag == _broadCastTag)
                    { // This is our tag
                        if (myIGCMessage.Data is string)
                        {
                            string lightName = myIGCMessage.Data.ToString();

                            IMyInteriorLight light;

                            light = GridTerminalSystem.GetBlockWithName(lightName) as IMyInteriorLight;
                            if (light == null)
                            {
                                Echo("Oh my! I couldn't find that block...");
                                Echo(lightName);
                                return;
                            }

                            light.Enabled = !light.Enabled;
                            Echo("I have toggled the light!");
                        }
                        else // if(msg.Data is XXX)
                        {
                            // handle other data types here...
                        }
                    }
                    else
                    {
                        // handle other tags here
                    }
                }
            }
        }
Beispiel #17
0
        public void Main(string argument)
        {
            var config     = new Config(Me.CustomData);
            var accessCode = config.Get("AccessCode");
            var channel    = config.Get("BroadcastChannel");
            var message    = new BlastDoorRadioMessage()
            {
                AccessCode = accessCode,
                Command    = argument,
            };

            IGC.SendBroadcastMessage(channel, message.Serialize(), TransmissionDistance.TransmissionDistanceMax);
        }
        public void Main(string argument, UpdateType updateType)
        {
            string tag1        = "pack";
            string tag2        = "pack2";
            string messageOut1 = antenna.GetPosition().ToString();
            string messageOut2 = controller.GetShipVelocities().LinearVelocity.ToString();

            Echo(messageOut2);
            IGC.SendBroadcastMessage(tag1, messageOut1, TransmissionDistance.TransmissionDistanceMax);
            IGC.RegisterBroadcastListener(tag1);
            IGC.SendBroadcastMessage(tag2, messageOut2, TransmissionDistance.TransmissionDistanceMax);
            IGC.RegisterBroadcastListener(tag2);
        }
        public void Main(string argument, UpdateType updateSource)
        {
            bool RecalculateRunwayHeadings = false;

            if (argument == "recalculate")
            {
                RecalculateRunwayHeadings = true;
            }

            if (!SetupComplete)
            {
                Setup();
            }

            // Init storage
            InitializeStorage();


            // Set default data if
            if (!IsDataFormatValid())
            {
                SetDefaultData();
                return;
            }


            // Validate GPS strings.
            bool IsTouchdownZoneAValid = ValidateGPSFormat(config.Get("TouchdownZone", "GPSA").ToString());
            bool IsTouchdownZoneBValid = ValidateGPSFormat(config.Get("TouchdownZone", "GPSB").ToString());

            if (!IsTouchdownZoneAValid || !IsTouchdownZoneBValid)
            {
                throw new Exception("Please enter the runway data or see the guide for help.");
            }

            int RunwayHDGA = config.Get("Runway", "HeadingA").ToInt16();
            int RunwayHDGB = config.Get("Runway", "HeadingB").ToInt16();

            if (RunwayHDGA == -1 || RunwayHDGB == -1 || RecalculateRunwayHeadings)
            {
                FindCockpitBlock();
                DetectRunwayHeadings();
                return;
            }


            // Construct & send message.
            string message = config.ToString();

            IGC.SendBroadcastMessage(antennaChannel, message);
        }
Beispiel #20
0
        private void LogLine(string msg, bool broadcast = true)
        {
            IMyTextSurfaceProvider prov = Me;
            var disp = Me.GetSurface(0);

            disp.ContentType = ContentType.TEXT_AND_IMAGE;
            disp.WriteText(msg + Environment.NewLine, true);
            Echo(msg + Environment.NewLine);
            if (this.msgHandler != null && broadcast)
            {
                // TODO: this belongs to a MessageSender class(maybe)
                IGC.SendBroadcastMessage(this.tag, $"[{uuid}] {msg}");
            }
        }
Beispiel #21
0
        bool SubProcessSendBroadcastMessage()
        {
            var message = MyTuple.Create
                          (
                Me.CubeGrid.EntityId,
                Me.CubeGrid.CustomName,
                lastShipPosition,
                informationTerminals.Text
                          );

            IGC.SendBroadcastMessage(StateBroadcastTag, message);

            return(true);
        }
Beispiel #22
0
        public void Main(string argument, UpdateType updateSource)
        {
            // Calculate and Output for informational purposes
            _runcount++;
            Echo(_runcount.ToString() + ":" + updateSource.ToString());

            if (
                (updateSource & (UpdateType.Trigger | UpdateType.Terminal)) > 0 || // run by a terminal action
                (updateSource & (UpdateType.Mod)) > 0 || // script run by a mod
                (updateSource & (UpdateType.Script)) > 0 // this pb run by another script (PB)
                )
            {                                            // script was run because of an action
                if (argument != "")
                {
                    // if we are given an argument, send it out over our broadcast channel
                    IGC.SendBroadcastMessage(_broadCastTag, argument);
                    Echo("Sending message:\n" + argument);
                }
            }

            if ((updateSource & UpdateType.IGC) > 0)
            { // script was run because of incoming IGC message
                while (_myBroadcastListener.HasPendingMessage)
                {
                    MyIGCMessage myIGCMessage = _myBroadcastListener.AcceptMessage();
                    if (myIGCMessage.Tag == _broadCastTag)
                    { // This is our tag
                        if (myIGCMessage.Data is string)
                        {
                            string str = myIGCMessage.Data.ToString();
                            Echo("Received IGC Public Message");
                            Echo("Tag=" + myIGCMessage.Tag);
                            Echo("Data=" + myIGCMessage.Data.ToString());
                            Echo("Source=" + myIGCMessage.Source.ToString("X"));
                        }
                        else // if(msg.Data is XXX)
                        {
                            // handle other data types here...
                        }
                    }
                    else
                    {
                        // handle other tags here
                    }
                }
            }
        }
Beispiel #23
0
        public void Main(string argument, UpdateType updateSource)
        {
            IMyTextPanel lcdWriteScreen = (IMyTextPanel)GridTerminalSystem.GetBlockWithName(lcdName);


            IMyRemoteControl remoteControl = (IMyRemoteControl)GridTerminalSystem.GetBlockWithName(remoteControllerName);

            List <MyWaypointInfo> mywaypoint = new List <MyWaypointInfo>();

            remoteControl.GetWaypointInfo(mywaypoint);

            foreach (MyWaypointInfo item in mywaypoint)
            {
                Echo(item.Coords.ToString());
            }
            wayPoint = mywaypoint[0];

            Echo(wayPoint.ToString());

            // If setupcomplete is false, run Setup method.
            if (!setupcomplete)
            {
                Echo("Running setup.");
                Setup();
            }
            else
            {
                // Create our message. We first make it a string, and then we "box" it as an object type.
                string sendCords = lcdWriteScreen.GetText();

                // Through the IGC variable we issue the broadcast method. IGC is "pre-made",
                // so we don't have to declare it ourselves, just go ahead and use it.
                if (sendCords.ToLower() == "send" && wayPoint.Coords != null)
                {
                    IGC.SendBroadcastMessage(broadcastChannel, wayPoint.ToString(), TransmissionDistance.TransmissionDistanceMax);
                }
                else
                {
                    Echo("Broadcasting failed.");
                }
                // To create a listener, we use IGC to access the relevant method.
                // We pass the same tag argument we used for our message.
                IGC.RegisterBroadcastListener(broadcastChannel);
            }
        }
Beispiel #24
0
        public void Main(string arg)
        {
            // If setupcomplete is false, run Setup method.
            if (setupcomplete == false)
            {
                Echo("Running setup.");
                Setup();
            }
            else
            {
                string tag1 = "Traffic Control";
                IGC.RegisterBroadcastListener(tag1);

                // Create a list for broadcast listeners.
                List <IMyBroadcastListener> listeners = new List <IMyBroadcastListener>();

                // The method argument below is the list we wish IGC to populate with all Listeners we've made.
                // Our Listener we created will be at index 0, because we only have that one Listener so far.
                IGC.GetBroadcastListeners(listeners);

                // We don't want to try receiving messages if we don't have any.
                // So we access the HasPendingMessage property to check if our Listener has any unread messages.
                if (listeners[0].HasPendingMessage)
                {
                    MyIGCMessage message = new MyIGCMessage();
                    message = listeners[0].AcceptMessage();
                    string messagetext = message.Data.ToString();

                    if (messagetext.Contains("Requesting Docking Clearance"))
                    {
                        IMyShipConnector dockingPort = GridTerminalSystem.GetBlockWithName("Docking Port 1") as IMyShipConnector;

                        string messageOut = "Clearance denied.";

                        if (dockingPort != null)
                        {
                            messageOut = $"Clearance granted. Proceed to Docking Port #{dockingPort.EntityId} at {dockingPort.Position.ToString()}";
                        }

                        IGC.SendBroadcastMessage(tag1, messageOut, TransmissionDistance.TransmissionDistanceMax);
                    }
                }
            }
        }
Beispiel #25
0
        private IEnumerable <IMyBroadcastListener> UpdateBroadcast()
        {
            var broadcastTag = $"{Me.CubeGrid.EntityId}.NIN.NAME";

            if (_broadcastTag != broadcastTag)
            {
                IGC.UnregisterBroadcastListener(_broadcastTag);
                _broadcastTag = broadcastTag;
            }
            var broadcastListener = IGC.RegisterBroadcastListener(broadcastTag);

            yield return(null);

            IGC.SendBroadcastMessage(broadcastTag, _priority);

            yield return(null);

            while (broadcastListener.HasPendingMessage)
            {
                var message          = broadcastListener.AcceptMessage();
                var priorityReceived = -1;
                try
                {
                    priorityReceived = (int)message.Data;
                }
                catch
                {
                    EchoManager.Print($"Received an invalid message in broadcast channel: {message.Data}");
                }

                if (!_ignorePriority && priorityReceived > _priority)
                {
                    Disable();
                }

                yield return(null);
            }

            EnableIfReady();

            yield return(broadcastListener);
        }
        public void Main(string argument, UpdateType updateSource)
        {
            // Init storage
            InitializeStorage();


            // Set default data if
            if (!IsDataFormatValid() || argument == "reset")
            {
                SetDefaultData();
                return;
            }


            // Construct & send message.
            string message = config.ToString();

            IGC.SendBroadcastMessage(AntennaChannel, message);

            Echo("Broadcasting on \"" + AntennaChannel + "\"..");
        }
Beispiel #27
0
 public void Main()
 {
     while (Listener.HasPendingMessage)
     {
         MyIGCMessage message = Listener.AcceptMessage();
         if (message.Data is string)
         {
             Print("Recieved message: " + document.OuterXml);
         }
         else
         {
             Print("Message is not " + typeof(string).FullName + ", but is " + message.Data.GetType().FullName);
         }
     }
     if (count >= 100U)
     {
         IGC.SendBroadcastMessage(Channel, document.OuterXml, TransmissionDistance.AntennaRelay);
         count = 0U;
     }
     ++count;
 }
Beispiel #28
0
 public void Main(string arg)
 {
     if (setupcomplete == false)
     {
         Echo("Running setup.");
         Setup();
     }
     else if (setupcomplete == true && requestSent == false)
     {
         string messageOut = "Requesting Docking Clearance";
         IGC.SendBroadcastMessage(tag1, messageOut, TransmissionDistance.TransmissionDistanceMax);
         Echo("Requesting Clearance");
         requestSent = true;
     }
     else if (requestSent == true && clearanceReceived == false)
     {
         // Now that we've requested clearance, listen for a clearance response.
         IGC.RegisterBroadcastListener(tag1);
         List <IMyBroadcastListener> listeners = new List <IMyBroadcastListener>();
         IGC.GetBroadcastListeners(listeners);
         Echo("checking messages");
         if (listeners[0].HasPendingMessage)
         {
             Echo("message received");
             clearance         = listeners[0].AcceptMessage();
             clearanceReceived = true;
         }
         else
         {
             requestSent = false;
         }
     }
     else if (clearanceReceived == true)
     {
         Echo(clearance.Data.ToString());
     }
 }
        int runcount = 0; // used to show running multiple times

        public void Main(string argument, UpdateType updateSource)
        {
            // Echo some information aboue 'me' and why we were run
            Echo(updateSource.ToString());
            Echo("Me=" + Me.EntityId.ToString());
            Echo(Me.CubeGrid.CustomName);
            runcount++;
            Echo("Runs=" + runcount.ToString());

            // if there is a message pending, process it
            if (_bListener.HasPendingMessage || _uListener.HasPendingMessage)
            {
                if (!HandleMessages())
                {
                    return;
                }
            }
            else
            {
                // if we were run when there's not a pending message, send out a broadcast message
                Echo("Sending Broadcast Message");
                IGC.SendBroadcastMessage <string>(BroadcastTag, "Me=" + Me.EntityId.ToString() + ":" + Me.CubeGrid.CustomName + "\n" + argument, TransmissionDistance.AntennaRelay);
            }
        }
Beispiel #30
0
 public void Main(string argument, UpdateType updateSource)
 {
     if ((updateSource & UpdateType.Terminal) > 0)
     {
         // отправляем сообщение
         count++;
         string message = "test message " + count;
         IGC.SendBroadcastMessage <string>(TAG, message, TransmissionDistance.TransmissionDistanceMax);
         Echo("send: " + message);
     }
     else if ((updateSource & UpdateType.IGC) > 0)
     {
         // получаем ответ
         Echo("argument: " + argument);
         if (listener.HasPendingMessage)
         {
             MyIGCMessage message = listener.AcceptMessage();
             if (message.Data is string)
             {
                 Echo("result: " + message.Data.ToString());
             }
         }
     }
 }