hwConnect() 공개 메소드

public hwConnect ( IPCHardware hw ) : void
hw IPCHardware
리턴 void
예제 #1
0
        /*
         * are these really not needed anymore?
         * protected override void onPartDestroy()
         * {
         *  if (partActive) {
         *      vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);
         *
         *      //remove manouver-stuff when the part is destroyed
         *      if (this.vessel.isActiveVessel) {
         *          RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
         *          RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
         *          RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
         *      }
         *  }
         * }
         *
         * protected override void onDisconnect()
         * {
         *  //remove manouver sFlyByWire stuff when the part is disconnected
         *  if (this.vessel.isActiveVessel && partActive) {
         *      vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);//this is in here to avoid potential nastiness related to removing nonexistant FlightInputCallbacks.
         *      RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
         *      RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
         *      RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
         *  }
         * }
         */

        private void init()
        {
            //print("PROGCOM INITIALISING");
            //initialise cpu-emulator
            //lastLoaded = 128;
            CPU = new CPUem();

            windowID = Util.random();

            //connect various peripherals to the CPU
            //when possible, separate these out as normal partmodules

            //connect the console memory wrapper
            CPU.hwConnect(ConsoleMemWrapper);

            running = false;

            //iterate through all partmodules connected to the part, make sure all partmodules are aware of this part.
            print("scanning for local progCom hardware...");
            foreach (PartModule pm in this.part.Modules)
            {
                if (pm == this)
                {
                    continue;
                }
                //connect all hardware to this part
                if (pm is IPCHardware)
                {
                    //print("HARDWARE IS FOUND");
                    print("found " + pm.GetType().ToString());
                    try {
                        CPU.hwConnect((IPCHardware)pm);
                    }
                    catch (ArgumentException e) {
                        consoleWrite("Error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                    catch (Exception e) {
                        consoleWrite("Unexpected error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                }
                //make sure all partmodules can read the gui state
                if (pm is PCGUIListener)
                {
                    //print("GUIListener found!");
                    try {
                        ((PCGUIListener)pm).recGUIState(GUIstate);
                    }
                    catch (Exception e) {
                        consoleWrite("Error when connecting gui:");
                        consoleWrite(e.Message);
                    }
                }
            }

            //initialise the assembler
            assembler = new Assembler2();
        }
예제 #2
0
파일: ProgCom.cs 프로젝트: Binamrad/ProgCom
        /*
         * are these really not needed anymore?
        protected override void onPartDestroy()
        {
            if (partActive) {
                vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);

                //remove manouver-stuff when the part is destroyed
                if (this.vessel.isActiveVessel) {
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
                    RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
                }
            }
        }

        protected override void onDisconnect()
        {
            //remove manouver sFlyByWire stuff when the part is disconnected
            if (this.vessel.isActiveVessel && partActive) {
                vessel.OnFlyByWire -= new FlightInputCallback(performManouvers);//this is in here to avoid potential nastiness related to removing nonexistant FlightInputCallbacks.
                RenderingManager.RemoveFromPostDrawQueue(3, new Callback(drawGUI)); //close the GUI
                RenderingManager.RemoveFromPostDrawQueue(3, new Callback(monitor.draw));
                RenderingManager.RemoveFromPostDrawQueue(3, new Callback(keyb.draw));//start the keyboard
            }
        }
        */
        private void init()
        {
            //print("PROGCOM INITIALISING");
            //initialise cpu-emulator
            //lastLoaded = 128;
            CPU = new CPUem();

            windowID = Util.random();

            //connect various peripherals to the CPU
            //when possible, separate these out as normal partmodules

            //connect the console memory wrapper
            CPU.hwConnect(ConsoleMemWrapper);

            running = false;

            //iterate through all partmodules connected to the part, make sure all partmodules are aware of this part.
            print("scanning for local progCom hardware...");
            foreach (PartModule pm in this.part.Modules) {
                if (pm == this) continue;
                //connect all hardware to this part
                if (pm is IPCHardware) {
                    //print("HARDWARE IS FOUND");
                    print("found " + pm.GetType().ToString());
                    try {
                        CPU.hwConnect((IPCHardware)pm);
                    }
                    catch (ArgumentException e) {
                        consoleWrite("Error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                    catch (Exception e) {
                        consoleWrite("Unexpected error when connecting hardware:");
                        consoleWrite(e.Message);
                    }
                }
                //make sure all partmodules can read the gui state
                if (pm is PCGUIListener) {
                    //print("GUIListener found!");
                    try {
                        ((PCGUIListener)pm).recGUIState(GUIstate);
                    }
                    catch (Exception e) {
                        consoleWrite("Error when connecting gui:");
                        consoleWrite(e.Message);
                    }
                }
            }

            //initialise the assembler
            assembler = new Assembler2();
        }