Ejemplo n.º 1
0
        private void CreateRobotDispatcher()
        {
            try
            {
                WagoPane.ConnectToBK(m_BK); //Todo: Deviceinit wo?
                m_BK.SetConfig("127.0.0.1", 502);
                m_BK.Start();
                m_EventStopThread    = new ManualResetEvent(false);
                m_EventThreadStopped = new ManualResetEvent(false);
                RobotInterface DispatcherInterface = new RobotInterface(null, modulDisplay1, null, null,
                                                                        m_ModuleState, null);
                RobotInterface Robot1Interface = new RobotInterface(stationDisplay1, null, null, null,
                                                                    m_ModuleState, m_BK);
                RobotInterface Robot2Interface = new RobotInterface(stationDisplay2, modulDisplay1, resultTable1, partHistoryTable1,
                                                                    m_ModuleState, m_BK);

                m_RobotDispatcher = new DemoRobotDispatcher(m_EventStopThread, m_EventThreadStopped, DispatcherInterface, Robot1Interface, Robot2Interface);

                //ToDo: Anzeigeelemnte mit Ereignishandlern verbinden
                this.counterEditor1.ConnectEvent(m_RobotDispatcher.GetRefRobot2().GetRefCounter());
            }
            catch (SystemException e)
            {
                DlgError.HandleException(e);
            }
        }
 public void handleEvent(RobotInterface.RobotEvent re)
 {
     if (re.getRobotEventType() == RobotEvent.Type.LOOK)
     {
         RobotLookEvent rle = (RobotLookEvent)re;
         if (rle.getContactType().Equals(RobotLookEvent.ContactType.ROBOT)) {
             sawVictim = true;
             victimDistance = rle.getDistance();
             atEdge = false;
             nearEdge = false;
         }
         else if (rle.getContactType().Equals(RobotLookEvent.ContactType.EDGE) &&
             rle.getDistance() == 1)
         {
             atEdge = true;
         }
         else if (rle.getContactType().Equals(RobotLookEvent.ContactType.EDGE) &&
             rle.getDistance() < 3)
         {
             nearEdge = true;
         }
         else
         {
             sawVictim = false;
             victimDistance = 999;
         }
     }
 }
Ejemplo n.º 3
0
        protected override void CreateRobot(int Index, RobotInterface Robot)
        {
            switch (Index)
            {
            case 1:
                if (m_EventStopThread == null)
                {
                    m_EventStopThread = new ManualResetEvent(false);
                }
                m_EventThreadStopped = new ManualResetEvent(false);
                m_Robot1             = new DemoRobot1(Robot, m_EventStopThread, m_EventThreadStopped);
                break;

            case 2:
                if (m_EventStopThread == null)
                {
                    m_EventStopThread = new ManualResetEvent(false);
                }
                m_EventThreadStopped2 = new ManualResetEvent(false);
                m_Robot2 = new DemoRobot2(Robot, m_EventStopThread, m_EventThreadStopped);
                break;

            default:
                break;
            }
        }
Ejemplo n.º 4
0
 public DemoRobot2(RobotInterface Interface, ManualResetEvent Stop, ManualResetEvent Stopped)
     : base(Interface, Stop, Stopped)
 {
     m_BK         = (DemoBK)Interface.GetBK();
     m_TypeParams = new DemoTypeParams();
     m_NextState  = State.Unknown;
 }
Ejemplo n.º 5
0
 void Awake()
 {
     instance              = this;
     isConnectedToCommand  = false;
     isConnectedToRegister = false;
     isFetching            = false;
     robotIsMoving         = false;
 }
Ejemplo n.º 6
0
        protected void onGameRobotExit(BinaryReader message)
        {
            int            robotIndex = message.ReadByte();
            RobotInterface gameRobot  = robotsMap[robotIndex];
            List <Object>  objects    = new List <Object>();

            objects.Add(gameRobot);
            eventQueue.addFunction(new Event(GameProtocol.GAME_ROBOT_EXIT, objects));
        }
 static void StartRobotInterface()
 {
     ui_thread = new Thread(() =>
     {
         interfaceRobot = new RobotInterface();
         MsgProcessor.OnPositionDataProcessedEvent += interfaceRobot.OnPositionDataProcessedEvent;
         interfaceRobot.ShowDialog();
     });
     ui_thread.SetApartmentState(ApartmentState.STA);
     ui_thread.Start();
 }
Ejemplo n.º 8
0
        protected void putGameRobotEnter(BinaryReader message)
        {
            RobotInterface robotPlayer = createRobot(message);

            JesterLogger.log("GameSpace.putGameRobotEnter, getRobotIndex(): " + robotPlayer.getRobotIndex());
            robotsMap.Add(robotPlayer.getRobotIndex(), robotPlayer);

            List <Object> objects = new List <Object>();

            objects.Add(robotPlayer);
            eventQueue.addFunction(new Event(GameProtocol.GAME_ROBOT_ENTER, objects));
        }
Ejemplo n.º 9
0
        public DemoRobotDispatcher(ManualResetEvent Stop, ManualResetEvent Stopped, RobotInterface Dispatcher, RobotInterface Robot1, RobotInterface Robot2)
            : base(Stop, Stopped, Dispatcher, Robot1)
        {
            CreateRobot(2, Robot2);

            //hardware simulation starten
            DemoSimulator sim = new DemoSimulator();

            GetRefRobot2().EventStepExit += new OnStepExitEventHandler(sim.OnEventStepExitRobot2);
            sim.SetReferences((DemoBK)Robot2.GetBK());
            sim.Show();
        }
Ejemplo n.º 10
0
        protected void gameRobotReplacement(BinaryReader message)
        {
            int            clientId   = message.ReadInt16();
            int            robotIndex = message.ReadByte();
            Client         client     = clientsMap[clientId];
            RobotInterface gameRobot  = robotsMap[robotIndex];

            List <Object> objects = new List <Object>();

            objects.Add(client);
            objects.Add(gameRobot);
            eventQueue.addFunction(new Event(GameProtocol.GAME_ROBOT_REPLACEMENT, objects));
        }
Ejemplo n.º 11
0
        public void notifyCurrentPlayerRobot(RobotInterface robot, CompletionCallback callback)
        {
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot: " + robot);
            TurnGamePlayer robotPlayer = (TurnGamePlayer)robot;

            if (robotPlayer == null)
            {
                throw new Exception("NullPointerException()");
            }
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot:2");
            this.currentPlayer = robotPlayer;
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot:3");
            List <Object> objects = new List <Object>();

            objects.Add(robot);
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot(), robot:4");
            eventQueue.addFunction(new Event(TurnGameProtocol.NOTIFY_CURRENT_PLAYER_ROBOT, objects));
            JesterLogger.log("TurnGameSpace.notifyCurrentPlayerRobot() out");
        }
Ejemplo n.º 12
0
 public void handleEvent(RobotInterface.RobotEvent re)
 {
     // Turner is too stupid to handle events.
 }
Ejemplo n.º 13
0
 public DemoRobot1(RobotInterface Interface, ManualResetEvent Stop, ManualResetEvent Stopped)
     : base(Interface, Stop, Stopped)
 {
     m_BK         = (DemoBK)Interface.GetBK();
     m_TypeParams = new DemoTypeParams();
 }
Ejemplo n.º 14
0
 private RobotInterface.Constants.Heading getNewHeading(RobotInterface.Constants.Heading h, 
     RobotTurnAction.Direction d)
 {
     int headingAsInt = (int)h;
     if (d.Equals(RobotTurnAction.Direction.RIGHT)) {
         if (++headingAsInt > 3) headingAsInt = 0;
     } else {
         if (--headingAsInt < 0) headingAsInt = 3;
     }
     return (RobotInterface.Constants.Heading)headingAsInt;
 }
Ejemplo n.º 15
0
 // Start is called before the first frame update
 void Start()
 {
     _GuideNavMeshAgent = _Guide.GetComponent <NavMeshAgent>();
     _RobotInterface    = _Guide.GetComponent <RobotInterface>();
 }
Ejemplo n.º 16
0
 public void handleEvent(RobotInterface.RobotEvent re)
 {
     // Walker doesn't care.
 }
Ejemplo n.º 17
0
 void Start()
 {
     instance = this;
     InvokeRepeating("ProcessMoveQueue", 0.0f, 0.015f);
 }
Ejemplo n.º 18
0
        public override bool callFunction(int fnc, BinaryReader message, CompletionCallback callback = null)
        {
            bool ret = base.callFunction(fnc, message, callback);

            JesterLogger.log("TurnGameSpace.callFunction, ret: " + ret + ", fnc: " + fnc);

            if (ret)
            {
                return(true);
            }

            switch (fnc)
            {
            case TurnGameProtocol.NOTIFY_CURRENT_PLAYER:
                JesterLogger.log("NOTIFY_CURRENT_PLAYER ");
                int clientId = message.ReadInt16();
                JesterLogger.log("clientId: " + clientId);
                Client client = clientsMap[clientId];
                JesterLogger.log("client: " + client);
                notifyCurrentPlayer(client, callback);
                return(true);

            case TurnGameProtocol.NOTIFY_CURRENT_PLAYER_ROBOT:
                JesterLogger.log("TurnGameSpace.NOTIFY_CURRENT_PLAYER_ROBOT");
                int robotIndex = message.ReadByte();
                JesterLogger.log("TurnGameSpace.RobotsMap sz: " + robotsMap.Count + ", robotIdx: " + robotIndex);
                List <int> dellist = new List <int>(robotsMap.Keys);
                for (int i = 0; i < dellist.Count; i++)
                {
                    JesterLogger.log("TurnGameSpace.RobotsMap, i: " + i + ", key: " + dellist[i]);
                }
                RobotInterface robot = robotsMap[robotIndex];
                JesterLogger.log("TurnGameSpace.RobotsMap 2....");
                notifyCurrentPlayerRobot(robot, callback);
                return(true);

            case TurnGameProtocol.TURN_STARTED:
                List <Object> objects = new List <Object>();
                objects.Add(message);
                eventQueue.addFunction(new Event(TurnGameProtocol.TURN_STARTED, objects));
                return(true);

            case TurnGameProtocol.TURN_FINISHED:
                objects = new List <Object>();
                objects.Add(message);
                eventQueue.addFunction(new Event(TurnGameProtocol.TURN_FINISHED, objects));
                return(true);

            case TurnGameProtocol.MATCH_STARTED:
                objects = new List <Object>();
                objects.Add(message);
                eventQueue.addFunction(new Event(TurnGameProtocol.MATCH_STARTED, objects));
                return(true);

            case TurnGameProtocol.MATCH_FINISHED:
                objects = new List <Object>();
                objects.Add(message);
                eventQueue.addFunction(new Event(TurnGameProtocol.MATCH_FINISHED, objects));
                return(true);

            case TurnGameProtocol.SET_SELECTABLES_BY_PLAYER:
                int        playerId   = message.ReadInt32();
                bool       selectable = message.ReadBoolean();
                GamePlayer gamePlayer = gamePlayersMap[id];
                objects = new List <Object>();
                objects.Add(gamePlayer);
                objects.Add(selectable);
                eventQueue.addFunction(new Event(TurnGameProtocol.SET_SELECTABLES_BY_PLAYER, objects));
                return(true);

            case TurnGameProtocol.SET_THIS_PLAYER_SELECTABLES:
                selectable = message.ReadBoolean();
                objects    = new List <Object>();
                objects.Add(thisPlayer);
                objects.Add(selectable);
                eventQueue.addFunction(new Event(TurnGameProtocol.SET_THIS_PLAYER_SELECTABLES, objects));
                return(true);
            }

            return(false);
        }