Exemplo n.º 1
0
    public void Process(string callbackString = "")
    {
        List<Action<MyIGCMessage>> callbacks;

        foreach (var kv in this.listeners) {
            string channel = kv.Key;
            IMyBroadcastListener listener = kv.Value;

            if (listener.HasPendingMessage && this.handlers.TryGetValue(channel, out callbacks)) {
                while (listener.HasPendingMessage) {
                    MyIGCMessage msg = listener.AcceptMessage();
                    foreach (Action<MyIGCMessage> handle in callbacks) {
                        handle(msg);
                    }
                }
            }
        }

        if (this.unicastListener != null) {
            if (this.unicastListener.HasPendingMessage) {
                while (this.unicastListener.HasPendingMessage) {
                    MyIGCMessage msg = this.unicastListener.AcceptMessage();
                    if (this.unicastHandlers.TryGetValue(msg.Tag, out callbacks)) {
                        foreach (Action<MyIGCMessage> handle in callbacks) {
                            handle(msg);
                        }
                    }
                }
            }
        }
    }
 public Communication(IMyProgrammableBlock pb, IMyIntergridCommunicationSystem igc)
 {
     this.igc          = igc;
     broadcastListener = igc.RegisterBroadcastListener(listenerId);
     unicastListener   = igc.UnicastListener;
     this.pb           = pb;
 }
Exemplo n.º 3
0
        public Program()
        {
            //gets all programmable blocks, where the block's name starts with "Dock"
            int hangarCount = GetAllHangars();

            Echo(String.Format("Found {0} Hangar Controllers", hangarCount));

            antenna = GridTerminalSystem.GetBlockWithName("Dock Request Antenna") as IMyRadioAntenna; //TODO: Remove specific name requrement
            if (antenna != null)
            {
                antenna.AttachedProgrammableBlock = Me.EntityId;
                listener = IGC.RegisterBroadcastListener(MESSAGE_TAG);
                listener.SetMessageCallback("REQUEST_WAITING");
            }
            logger = GridTerminalSystem.GetBlockWithName("LCD Logger") as IMyTextPanel;
            Echo(string.Format("ANTENNA FOUND: {0}", antenna != null));
            Echo(string.Format("LOGGER FOUND: {0}", logger != null));
            if (logger == null)
            {
                logger = Me.GetSurface(0);
            }
            logger.ContentType = ContentType.TEXT_AND_IMAGE;
            logger.FontSize    = FONT_SIZE;
            string loggerText = logger.GetText();

            if (!loggerText.Contains("DOCKING LOG"))
            {
                Echo("LOGGER TEXT DOES NOT INCLUDE HEADER. Only Found:\n" + loggerText);
                logger.WriteText(LOGGER_HEADER);
            }
        }
        public GreedleManager(IMyIntergridCommunicationSystem IGC, IMyTextSurface outputSurface)
        {
            this.IGC = IGC;
            this.responseListener = IGC.RegisterBroadcastListener("greedle_response");
            this.responseListener.SetMessageCallback("Message Callback");
            this.greedles      = new List <Greedle>();
            this.outputSurface = outputSurface;

            commandTree = new PanelCommander.CommandTree()
            {
                label    = "Greedle Commands",
                commands = new List <PanelCommander.Command>()
                {
                    new PanelCommander.Command()
                    {
                        label = "List", action = ListGreedles
                    },
                    new PanelCommander.Command()
                    {
                        label = "Check For Greedle Updates", action = CheckForUpdates
                    }
                },
                subtrees = new List <PanelCommander.CommandTree>(),
            };
            ListGreedles();
        }
Exemplo n.º 5
0
 public FileSystemServer()
 {
     Runtime.UpdateFrequency = UpdateFrequency.Update1;
     try
     {
         StorageReader storage_data = new StorageReader(Storage);
         if (Storage.Length > 0)
         {
             uint num_users = storage_data.ReadUInt32();
             for (uint i = 0U; i != num_users; i++)
             {
                 string user_name = storage_data.ReadString();
                 string password  = storage_data.ReadString();
                 if (!(users.ContainsKey(user_name)))
                 {
                     users.Add(user_name, new User(user_name, password));
                 }
             }
             uint num_files = storage_data.ReadUInt32();
             for (uint i = 0U; i != num_files; i++)
             {
                 string    path             = storage_data.ReadString();
                 string    owner            = storage_data.ReadString();
                 FileFlags read_write_flags = (FileFlags)(storage_data.ReadByte());
                 byte[]    data             = storage_data.ReadByteSequence();
                 files.Add(path, new File(path, owner, (read_write_flags & FileFlags.CanEveryoneRead) == FileFlags.CanEveryoneRead, (read_write_flags & FileFlags.CanEveryoneWrite) == FileFlags.CanEveryoneWrite, data));
             }
         }
     }
     catch (StorageReaderArgumentException e)
     {
         Echo(e.ToString());
     }
     fileSystemListener = IGC.RegisterBroadcastListener(fileSystemServerTag);
 }
Exemplo n.º 6
0
        void Start()
        {
            gridSystem = GridTerminalSystem;
            gridId     = Me.CubeGrid.EntityId;
            if (string.IsNullOrWhiteSpace(turretGroup))
            {
                turrets = GetBlocks <IMyLargeTurretBase>(useSubgrids);
            }
            else
            {
                turrets = GetBlocks <IMyLargeTurretBase>(turretGroup, useSubgrids);
            }
            wcTurrets = new WcPbApi();
            if (string.IsNullOrWhiteSpace(rcName))
            {
                rc = GetBlock <IMyRemoteControl>();
            }
            else
            {
                rc = GetBlock <IMyRemoteControl>(rcName, useSubgrids);
            }
            if (rc == null)
            {
                throw new Exception("Remote control block not found.");
            }
            origin = rc.GetPosition();

            if (receiveHelpMsgs)
            {
                helpListener = IGC.RegisterBroadcastListener("AttackDrone_" + commsId);
                helpListener.SetMessageCallback("");
            }

            startRuntime = -1;
        }
Exemplo n.º 7
0
    public void AddListener(string channel)
    {
        IMyBroadcastListener listener = this.p.IGC.RegisterBroadcastListener(channel);

        listener.SetMessageCallback(channel);
        this.listeners[channel] = listener;
    }
Exemplo n.º 8
0
        string initDockingInfo()
        {
            string s = "";

            _BASE_IGCChannel = IGC.RegisterBroadcastListener("BASE?");
            _BASE_IGCChannel.SetMessageCallback(_BASE_IGCChannel.Tag);

            _CON_IGCChannel = IGC.RegisterBroadcastListener("CON?");
            _CON_IGCChannel.SetMessageCallback(_CON_IGCChannel.Tag);

            _COND_IGCChannel = IGC.RegisterBroadcastListener("COND?");
            _COND_IGCChannel.SetMessageCallback(_COND_IGCChannel.Tag);

            dockingInfo.Clear();
            dockingAlllights = GetBlocksContains <IMyLightingBlock>(sBaseConnector);
            //GetTargetBlocks<IMyLightingBlock>();

            if (localBaseConnectors.Count < 1)
            {
                s += connectorsInit();
            }

            Echo(localBaseConnectors.Count + " Base Connectors");
            for (int i = 0; i < localBaseConnectors.Count; i++)
            {
                //		IMyShipConnector connector = localBaseConnectors[i]  as IMyShipConnector;
                addDockingInfo(localBaseConnectors[i]);
            }
            // load from text panel...
            s += "DI:" + dockingInfo.Count;
//            Echo("EO:iDI()");
            return(s);
        }
        public Program()
        {
            Program.MyInstance      = this;
            Runtime.UpdateFrequency = UpdateFrequency.Update1;
            SetRadarController();
            SetShipController();
            SayMyName(MY_PREFIX);
            GetMeTheTurrets();
            int i = 0;

            try {
                string[] data = Storage.Split(';');
                AEGISUseRadarData    = bool.Parse(data[i++]);
                AEGISIsOnline        = bool.Parse(data[i++]);
                AEGISTargetsNeutrals = bool.Parse(data[i++]);
            }
            catch (Exception e) {
                e.ToString();
                int f = 0;
                if (++f >= i)
                {
                    AEGISUseRadarData = false;
                }
                if (++f >= i)
                {
                    AEGISIsOnline = true;
                }
                if (++f >= i)
                {
                    AEGISTargetsNeutrals = false;
                }
            }
            AEGISListener = IGC.RegisterBroadcastListener(MY_PREFIX);
            AEGISListener.SetMessageCallback();
        }
Exemplo n.º 10
0
        public Program()
        {
            IMyTerminalBlock b = GridTerminalSystem.GetBlockWithName(ScreenName);

            Screen = (b as IMyTextSurface) ?? (b as IMyTextSurfaceProvider)?.GetSurface(0);
            if (Screen == null)
            {
                Screen = Me.GetSurface(0);
            }
            Screen.ContentType = VRage.Game.GUI.TextPanel.ContentType.TEXT_AND_IMAGE;
            Listener           = IGC.RegisterBroadcastListener(BroadcastTag);
            Listener.SetMessageCallback("incoming_message");
            if (Listener.IsActive)
            {
                Echo("Listener registered. Callback set.");
            }
            else
            {
                Echo("Listener not registered!");
            }
            if (!long.TryParse(Storage, out DroneID))
            {
                DroneID = 0;
            }
        }
Exemplo n.º 11
0
        public Program()
        {
            drill  = GridTerminalSystem.GetBlockWithName(drill_name) as IMyShipDrill;
            piston = GridTerminalSystem.GetBlockWithName(piston_name) as IMyPistonBase;

            broadcast_listener = IGC.RegisterBroadcastListener(broadcast_tag);
            broadcast_listener.SetMessageCallback(broadcast_tag);
        }
Exemplo n.º 12
0
 void BaseInitInfo()
 {
     baseList.Clear();
     // load from text panel
     BaseDeserialize();
     _BASEIGCChannel = IGC.RegisterBroadcastListener("BASE");
     _BASEIGCChannel.SetMessageCallback(_BASEIGCChannel.Tag);
 }
Exemplo n.º 13
0
        // States
        // - OPEN
        // - OPENING
        // - CLOSED
        // - CLOSING
        // - UNKNOWN -> stopped in non-closed/open state, or moving to unknown state
        // - null -> default, requires init


        // Inputs
        // - CLOSE
        // - OPEN
        // - OBSERVE -> default, observes states, locks when available and change state accordingly
        // - RESTART -> reruns init

        public Program()
        {
            var config           = new Config(Me.CustomData);
            var blashDoorChannel = config.Get("blastDoorChannel", "BlastDoor");

            broadcastListener = IGC.RegisterBroadcastListener(blashDoorChannel);
            broadcastListener.SetMessageCallback("radioCommand");
        }
 public HangarManagerProgram()
 {
     hangarBroadcastListener = IGC.RegisterBroadcastListener("hangar.server");
     shipCommands.Add("discover", DiscoverHangarCommand, "name");
     shipCommands.Add("register", RegisterShipCommand, "name");
     shipCommands.Add("dock", DockShipCommand, "width", "height", "length");
     shipCommands.Add("undock", UndockShipCommand, "width", "height", "length");
 }
Exemplo n.º 15
0
 public Program()
 {
     // подписываемся на канал
     listener = IGC.RegisterBroadcastListener(TAG);
     // указываем какой будет приходить argument в метод Main()
     listener.SetMessageCallback(TAG);
     Echo("Status: init ok");
 }
Exemplo n.º 16
0
            public void ListenToEveryIndirectMsg(string tag, Action <MyIGCMessage> reader)
            {
                IMyBroadcastListener l = p.IGC.RegisterBroadcastListener(tag);

                while (l.HasPendingMessage)
                {
                    reader(l.AcceptMessage());
                }
            }
Exemplo n.º 17
0
            public InterGridComms(IMyIntergridCommunicationSystem comms, IngameTime time, IMyProgrammableBlock me)
            {
                commands       = new Dictionary <string, Action <object> >();
                keepaliveChann = comms.RegisterBroadcastListener("ServerKeepAlive");

                this.comms = comms;
                this.time  = time;
                this.me    = me;
            }
Exemplo n.º 18
0
            public AntennaHandler(Program _program)
            {
                parent_program = _program;

                _myBroadcastListener = parent_program.IGC.RegisterBroadcastListener(_recallRequestTag);
                _myUnicastListener   = parent_program.IGC.UnicastListener;
                //_myUnicastListener = parent_program.IGC.RegisterBroadcastListener(_responseTag);
                _myUnicastListener.SetMessageCallback("UNICAST");
                _myBroadcastListener.SetMessageCallback(_recallRequestTag);
            }
Exemplo n.º 19
0
        public Program()
        {
            // let them know we are alive
            Echo("Creator");

            // register a broadcast channel for our tag
            _myBroadcastListener = IGC.RegisterBroadcastListener(_broadCastTag);

            // Ask to be called back --to Main()-- when a message is received
            _myBroadcastListener.SetMessageCallback(_broadCastTag); // the callback agrument does NOT need to be the same as the tag
        }
            protected void AddListener(string subtag, bool withCallback = false)
            {
                string realTag         = ToRealTag(subtag);
                IMyBroadcastListener l = p.IGC.RegisterBroadcastListener(realTag);

                if (withCallback)
                {
                    l.SetMessageCallback(realTag);
                }
                listGroupListener.Add(l);
            }
Exemplo n.º 21
0
        public Program()
        {
            settings = new Settings(Me);
            settings.Load();

            storage = new StorageData(this);
            storage.Load();

            transmitTag        += settings.followerSystemId.Value;
            transmitCommandTag += settings.followerSystemId.Value;

            // Prioritize the given cockpit name
            rc = GetBlock <IMyShipController>(settings.cockpitName.Value, true);
            if (rc == null) // Second priority cockpit
            {
                rc = GetBlock <IMyCockpit>();
            }
            if (rc == null) // Third priority remote control
            {
                rc = GetBlock <IMyRemoteControl>();
            }
            if (rc == null) // No cockpits found.
            {
                throw new Exception("No cockpit/remote control found. Set the cockpitName field in settings.");
            }

            thrust = new ThrusterControl(rc, settings.tickSpeed.Value, GetBlocks <IMyThrust>());
            gyros  = new GyroControl(rc, settings.tickSpeed.Value, GetBlocks <IMyGyro>());

            if (settings.enableCollisionAvoidence.Value)
            {
                cameras = GetBlocks <IMyCameraBlock>();
            }

            if (settings.tickSpeed.Value == UpdateFrequency.Update10)
            {
                echoFrequency = 10;
            }
            else if (settings.tickSpeed.Value == UpdateFrequency.Update100)
            {
                echoFrequency = 1;
            }

            leaderListener = IGC.RegisterBroadcastListener(transmitTag);
            leaderListener.SetMessageCallback("");
            commandListener = IGC.RegisterBroadcastListener(transmitCommandTag);
            commandListener.SetMessageCallback("");

            Echo("Ready.");
            if (!storage.IsDisabled)
            {
                Runtime.UpdateFrequency = settings.tickSpeed.Value;
            }
        }
Exemplo n.º 22
0
        //grid map

        public Program()
        {
            //load program state
            if (alreadyRun & _ini.TryParse(Storage))
            {
                Vector3D.TryParse(_ini.Get("Basis", "A").ToString(), out _basisVecA);
                Vector3D.TryParse(_ini.Get("Basis", "B").ToString(), out _basisVecB);
                Vector3D.TryParse(_ini.Get("Basis", "Up").ToString(), out _basisVecUp);
                Vector3D.TryParse(_ini.Get("Basis", "Origin").ToString(), out _origin);
            }
            //load config
            else
            {
                MyIniParseResult result;
                if (!_ini.TryParse(Me.CustomData, out result))
                {
                    throw new Exception(result.ToString());
                }

                string           nameA  = _ini.Get("Basis", "A").ToString("A");
                IMyTerminalBlock blockA = GridTerminalSystem.GetBlockWithName(nameA);
                Vector3D         pointA = blockA.GetPosition();

                string           nameB  = _ini.Get("Basis", "B").ToString("B");
                IMyTerminalBlock blockB = GridTerminalSystem.GetBlockWithName(nameB);
                Vector3D         pointB = blockB.GetPosition();

                string           nameUp  = _ini.Get("Basis", "Up").ToString("Up");
                IMyTerminalBlock blockUp = GridTerminalSystem.GetBlockWithName(nameUp);
                Vector3D         pointUp = blockUp.GetPosition();

                string           nameOrigin  = _ini.Get("Basis", "Origin").ToString("Origin");
                IMyTerminalBlock blockOrigin = GridTerminalSystem.GetBlockWithName(nameOrigin);
                _origin = blockOrigin.GetPosition();


                _basisVecA  = Vector3D.Normalize(pointA - _origin);
                _basisVecB  = Vector3D.Normalize(pointB - _origin);
                _basisVecUp = Vector3D.Normalize(pointUp - _origin);

                _basisVecA  = Me.CubeGrid.WorldMatrix.Forward;
                _basisVecB  = Me.CubeGrid.WorldMatrix.Right;
                _basisVecUp = Me.CubeGrid.WorldMatrix.Up;

                alreadyRun = true;
            }

            //IGC
            _turtleListenerInit = IGC.RegisterBroadcastListener(_turtleInit);
            _turtleListenerInit.SetMessageCallback(_turtleInit);

            Runtime.UpdateFrequency |= UpdateFrequency.Update100;
        }
Exemplo n.º 23
0
            public Spaceship(IMyGridTerminalSystem system, IMyIntergridCommunicationSystem igc)
            {
                this.system = system;
                this.igc    = igc;

                cpu = FindRunningPB(system);

                control   = FindBlockOfType <IMyRemoteControl>(system, this, Settings.TAG);
                connector = FindBlockOfType <IMyShipConnector>(system, this, Settings.TAG);
                debug     = FindBlockOfType <IMyTextPanel>(system, this, Settings.TAG);
                if (debug == null)
                {
                    IMyCockpit cockpit = FindBlockOfType <IMyCockpit>(system, this, Settings.TAG);
                    if (cockpit.SurfaceCount > 0)
                    {
                        debug = cockpit.GetSurface(0);
                    }
                }
                debug.Font        = "Monospace";
                debug.ContentType = ContentType.TEXT_AND_IMAGE;

                /*
                 *  screen = cockpit.GetSurface(0);
                 *  screen.ContentType = ContentType.SCRIPT;
                 *  MySpriteDrawFrame frame = screen.DrawFrame();
                 *
                 *
                 *  frame.Add(new MySprite(SpriteType.TEXTURE, "SquareSimple", new Vector2(0, 0), new Vector2(512, 512), Color.Black));
                 *  frame.Add(MySprite.CreateText("Ftiaxe Me!!!", "DEBUG", Color.White));
                 *  frame.Dispose();
                 */

                listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL);
                listener = igc.RegisterBroadcastListener(Settings.COMM_CHANNEL);
                listener.SetMessageCallback(Settings.COMM_CHANNEL);
                thrusters = new ThrustersManager(this, control, system);

                autopilot = new Autopilot(this, control, FindBlockOfType <IMyGyro>(system, this));
                cas       = new CollisionAvoidanceSystem(this);
                fd        = new FlightDirector(this);

                if (connector.Status == MyShipConnectorStatus.Connected)
                {
                    flags = SpaceshipFlags.Dock;
                }
                else
                {
                    flags = SpaceshipFlags.Idle;
                }
            }
Exemplo n.º 24
0
        public Program()
        {
            // Echo some information about 'me' when I'm compiled
            Echo("Creator.");
            Echo("Me=" + Me.EntityId.ToString());
            Echo(Me.CubeGrid.CustomName);

            // register a broadcast listener
            _bListener = IGC.RegisterBroadcastListener(BroadcastTag); // What it listens for
            _bListener.SetMessageCallback(BroadcastTag);              // What it will run the PB with once it has a message

            // save the unicast listener
            _uListener = IGC.UnicastListener;
            _uListener.SetMessageCallback(UnicastTag); // set PB callback argument to be used
        }
Exemplo n.º 25
0
        public void setUp()
        {
            control    = GridTerminalSystem.GetBlockWithName("Targetting Ray/Remote") as IMyShipController;
            XROT       = GridTerminalSystem.GetBlockWithName("Targetting Ray/Yaw Rotor") as IMyMotorStator;
            YROT       = GridTerminalSystem.GetBlockWithName("Targetting Ray/Pitch Rotor") as IMyMotorStator;
            camera     = GridTerminalSystem.GetBlockWithName("Targetting Ray/Camera") as IMyCameraBlock;
            soundBlock = GridTerminalSystem.GetBlockWithName("Targetting Ray/Sound Block") as IMySoundBlock;
            if (camera != null && camera.EnableRaycast == false)
            {
                camera.EnableRaycast = true;
            }

            misCMDListener = IGC.RegisterBroadcastListener(misCMDTag);
            misCMDListener.SetMessageCallback();
        }
Exemplo n.º 26
0
        void NavInitIGC()
        {
            _AddNavListener = IGC.RegisterBroadcastListener(WICOB_NAVADDTARGET);         // What it listens for
            _AddNavListener.SetMessageCallback(WICOB_NAVADDTARGET);                      // What it will run the PB with once it has a message

            _StartNavListener = IGC.RegisterBroadcastListener(WICOB_NAVSTART);           // What it listens for
            _StartNavListener.SetMessageCallback(WICOB_NAVSTART);                        // What it will run the PB with once it has a message

            _ResetNavListener = IGC.RegisterBroadcastListener(WICOB_NAVRESET);           // What it listens for
            _ResetNavListener.SetMessageCallback(WICOB_NAVRESET);                        // What it will run the PB with once it has a message

            _LaunchNavListener = IGC.RegisterBroadcastListener(WICOB_NAVLAUNCH);         // What it listens for
            _LaunchNavListener.SetMessageCallback(WICOB_NAVLAUNCH);                      // What it will run the PB with once it has a message

            _OrbitalNavListener = IGC.RegisterBroadcastListener(WICOB_NAVORBITALLAUNCH); // What it listens for
            _OrbitalNavListener.SetMessageCallback(WICOB_NAVORBITALLAUNCH);              // What it will run the PB with once it has a message
        }
        public SubsystemManager(ExecutionContext context)
        {
            Context = context;

            ParseConfigs();
            if (OutputMode == OutputMode.Profile)
            {
                profiler = new Profiler(Context.Program.Runtime, PROFILER_HISTORY_COUNT, PROFILER_NEW_VALUE_FACTOR);
            }

            GeneralListener = Context.IGC.RegisterBroadcastListener(GeneralChannel);

            Context.WCAPI = new WcPbApi();
            if (!Context.WCAPI.Activate(context.Program.Me))
            {
                Context.WCAPI = null;
            }
        }
            public AutoConnectionDispatcher(MyGridProgram program, CommandLine command, MyIni ini, Action <string> logger, IProcessManager manager)
            {
                this.logger  = logger;
                this.manager = manager;
                // Station level initialization
                this.stationName   = ini.GetThrow(INI_GENERAL_SECTION, INI_NAME_KEY).ToString();
                this.referenceName = ini.GetThrow(INI_GENERAL_SECTION, INI_REFERENCE_KEY).ToString();
                IMyTerminalBlock reference = program.GridTerminalSystem.GetBlockWithName(this.referenceName);

                if (reference == null)
                {
                    throw new ArgumentException($"Could not find reference block '{this.referenceName}'");
                }
                this.igc         = program.IGC;
                this.transformer = new CoordinatesTransformer(reference, manager);
                this.log("initializing");
                // Connectors initialization
                var sections = new List <string>();

                ini.GetSections(sections);
                foreach (string sectionName in sections.Where(s => s.StartsWith(AutoConnector.IniConnectorPrefix)))
                {
                    var connector = new AutoConnector(this.stationName, sectionName, program, this.logger, this.transformer, ini);
                    this.autoConnectors.Add(new AutoConnectionServer(ini, this.igc, connector, manager, this.logger));
                }
                this.log($"has {this.autoConnectors.Count} auto connectors");
                this.registerCommands(command, program);

                IMyBroadcastListener listener = this.igc.RegisterBroadcastListener("StationConnectionRequests");

                this.manager.Spawn(p => {
                    if (listener.HasPendingMessage)
                    {
                        MyIGCMessage msg = listener.AcceptMessage();
                        command.StartCmd($"{msg.As<string>()} {msg.Source}", CommandTrigger.Antenna);
                    }
                }, "ac-dispatcher");

                this.manager.AddOnSave(save);
            }
Exemplo n.º 29
0
 public void Main(string argument, UpdateType updateSource)
 {
     if ((updateSource & UpdateType.IGC) > 0)
     {
         if (universalListener != null && universalListener.HasPendingMessage)
         {
             MyIGCMessage        message = universalListener.AcceptMessage();
             List <IMyTextPanel> panels  = new List <IMyTextPanel>();
             GridTerminalSystem.GetBlocksOfType(panels);
             if (panels.Count > 0)
             {
                 panels[0].WriteText(message.Tag + " " + message.Source + " " + message.Data + "\n", false);
             }
         }
     }
     else
     {
         universalListener = IGC.RegisterBroadcastListener(argument);
         universalListener.SetMessageCallback();
         Echo("CURRENT LISTENING CODE: " + argument);
     }
 }
Exemplo n.º 30
0
        public Program()
        {
            //hardware
            _remote    = GridTerminalSystem.GetBlockWithName("Remote [t]") as IMyRemoteControl;
            _gyro      = GridTerminalSystem.GetBlockWithName("Gyroscope [t]") as IMyGyro;
            _connector = GridTerminalSystem.GetBlockWithName("Connector [t]") as IMyShipConnector;
            _messageBuilder.AppendLine("Hardware located.");
            //IGC
            IGC.UnicastListener.SetMessageCallback();
            _turtleListenerInit = IGC.RegisterBroadcastListener(_turtleInit);
            _turtleListenerInit.SetMessageCallback(_turtleInit);
            var op = GridTerminalSystem.GetBlockWithName("Operator [t]") as IMyProgrammableBlock;

            _turtleOperatorID = op.GetId();
            _messageBuilder.AppendLine("IGC loaded.");
            // load program state
            Load();
            // custom data reset - log info
            Me.CustomData            = "\t\tPROGRAM LOG:\n\n" + _messageBuilder;
            Runtime.UpdateFrequency |= UpdateFrequency.Once;
            _stateMachine            = Idle();
        }