string doInit() { // initialization of each module goes here: // when all initialization is done, set init to true. // set autogyro defaults. LIMIT_GYROS = 1; minAngleRad = 0.09f; CTRL_COEFF = 0.75; /* * Log("Init:" + currentInit.ToString()); * double progress = currentInit * 100 / 3; * string sProgress = progressBar(progress); * StatusLog(sProgress, getTextBlock(sTextPanelReport)); */ Echo("Init"); if (currentInit == 0) { //StatusLog("clear",textLongStatus,true); StatusLog(DateTime.Now.ToString() + OurName + ":" + moduleName + ":INIT", textLongStatus, true); // if (!modeCommands.ContainsKey("launch")) modeCommands.Add("launch", MODE_LAUNCH); // if(!modeCommands.ContainsKey("godock")) modeCommands.Add("godock", MODE_DOCKING); sInitResults += initSerializeCommon(); Deserialize(); sInitResults += gridsInit(); sInitResults += BlockInit(); initLogging(); sInitResults += thrustersInit(gpsCenter); sInitResults += rotorsNavInit(); sInitResults += wheelsInit(gpsCenter); sInitResults += sensorInit(); // sInitResults += camerasensorsInit(gpsCenter); sInitResults += connectorsInit(); sInitResults += gyrosetup(); GyroControl.UpdateGyroList(gyros); GyroControl.SetRefBlock(gpsCenter); sInitResults += lightsInit(); initShipDim(); sInitResults += modeOnInit(); // handle mode initializting from load/recompile.. init = true; } currentInit++; if (init) { currentInit = 0; bWantFast = false; } Log(sInitResults); return(sInitResults); }
string doInit() { // initialization of each module goes here: // when all initialization is done, set init to true. /* * if(currentInit==0) initLogging(); * * // Log("Init:" + currentInit.ToString()); * double progress = currentInit * 100 / 3; * string sProgress = progressBar(progress); * StatusLog(moduleName + sProgress, textPanelReport); */ do { // echoInstructions("Init:" + currentInit + " | "); switch (currentInit) { case 0: sInitResults += gridsInit(); break; case 1: /* * add commands to set modes * For Example: * if(!modeCommands.ContainsKey("launchprep")) modeCommands.Add("launchprep", MODE_LAUNCHPREP); */ modeCommands.Clear(); // if (!modeCommands.ContainsKey("findore")) modeCommands.Add("findore", MODE_FINDORE); // if (!modeCommands.ContainsKey("doscan")) modeCommands.Add("doscan", MODE_DOSCAN); if (!modeCommands.ContainsKey("mine")) { modeCommands.Add("mine", MODE_MINE); } if (!modeCommands.ContainsKey("bore")) { modeCommands.Add("bore", MODE_BORESINGLE); } break; case 2: initLogging(); break; case 3: StatusLog(DateTime.Now.ToString() + " " + OurName + ":" + moduleName + ":INIT", textLongStatus, true); break; case 4: sInitResults += SerializeInit(); Deserialize(); break; case 5: break; case 6: sInitResults += DefaultOrientationBlockInit(); break; case 7: initShipDim(shipOrientationBlock); break; case 8: sInitResults += connectorsInit(); break; case 9: sInitResults += thrustersInit(shipOrientationBlock); break; case 10: sInitResults += camerasensorsInit(shipOrientationBlock); break; case 11: sInitResults += SensorInit(shipOrientationBlock); break; case 12: sInitResults += tanksInit(); break; case 13: sInitResults += gyrosetup(); break; case 14: GyroControl.UpdateGyroList(gyros); break; case 15: sInitResults += drillInit(); break; case 16: sInitResults += ejectorsInit(); break; case 17: initCargoCheck(); break; case 18: initAsteroidsInfo(); break; case 19: // Deserialize(); break; case 20: initOreLocInfo(); break; case 21: initPower(); break; case 22: tanksInit(); break; case 23: sInitResults += modeOnInit(); break; case 24: if (sensorsList.Count < 2) { // bStartupError = true; sStartupError += "\nNot enough Sensors detected!"; } if (!HasDrills()) { // bStartupError = true; sStartupError += "\nNo Drills found!"; } break; case 25: Serialize(); init = true; break; } currentInit++; // echoInstructions("EInit:" + currentInit + " | "); Echo("%=" + (float)Runtime.CurrentInstructionCount / (float)Runtime.MaxInstructionCount); }while (!init && (((float)Runtime.CurrentInstructionCount / (float)Runtime.MaxInstructionCount) < 0.5f)); if (init) { currentInit = 0; } // Log(sInitResults); Echo("Init exit"); return(sInitResults); }
string doInit() { // Echo("InitA:" + currentInit + ":"+Runtime.CurrentInstructionCount+ "/"+Runtime.MaxInstructionCount); // initialization of each module goes here: // when all initialization is done, set init to true. Log("Init:" + currentInit.ToString()); Echo(gtsAllBlocks.Count.ToString() + " Blocks"); /* * double progress = currentInit * 100 / 3; // 3=Number of expected INIT phases. * string sProgress = progressBar(progress); * StatusLog(moduleName + sProgress, textPanelReport); */ if (shipOrientationBlock != null) { // anchorPosition = shipOrientationBlock; // currentPosition = anchorPosition.GetPosition(); } // Echo("InitB:" + currentInit + ":"+Runtime.CurrentInstructionCount+ "/"+Runtime.MaxInstructionCount); if (currentInit == 0) { // Echo("Init0:" + currentInit + ":"+Runtime.CurrentInstructionCount+ "/"+Runtime.MaxInstructionCount); // StatusLog("clear", textLongStatus, true); // only MAIN module should clear long status on init. StatusLog(DateTime.Now.ToString() + " " + OurName + ":" + moduleName + ":INIT", textLongStatus, true); /* * if(!modeCommands.ContainsKey("launchprep")) modeCommands.Add("launchprep", MODE_LAUNCHPREP); */ sInitResults += gridsInit(); initLogging(); initTimers(); sInitResults += SerializeInit(); Deserialize(); // get info from savefile to avoid blind-rewrite of (our) defaults } else if (currentInit == 1) { Deserialize();// get info from savefile to avoid blind-rewrite of (our) defaults sInitResults += DefaultOrientationBlockInit(); initCargoCheck(); initPower(); sInitResults += thrustersInit(shipOrientationBlock); sInitResults += gyrosetup(); GyroControl.UpdateGyroList(gyros); if (gtsAllBlocks.Count < 300) { currentInit = 2; // go ahead and do next step. } } if (currentInit == 2) { sInitResults += wheelsInit(shipOrientationBlock); sInitResults += rotorsNavInit(); sInitResults += wheelsInit(shipOrientationBlock); sInitResults += sensorInit(true); if (gtsAllBlocks.Count < 100) { currentInit = 3; // go ahead and do next step. } } if (currentInit == 3) { sInitResults += connectorsInit(); sInitResults += tanksInit(); sInitResults += drillInit(); sInitResults += controllersInit(); if (gtsAllBlocks.Count < 100) { currentInit = 4; // go ahead and do next step. } } if (currentInit == 4) { sInitResults += ejectorsInit(); sInitResults += antennaInit(); sInitResults += gasgenInit(); sInitResults += camerasensorsInit(shipOrientationBlock); sInitResults += airventInit(); // Serialize(); autoConfig(); bWantFast = false; if (bGotAntennaName) { sBanner = "*" + OurName + ":" + moduleName + " V" + sVersion + " "; } if (sBanner.Length > 34) { sBanner = OurName + ":" + moduleName + "\nV" + sVersion + " "; } if (shipOrientationBlock is IMyShipController) { MyShipMass myMass; myMass = ((IMyShipController)shipOrientationBlock).CalculateShipMass(); gridBaseMass = myMass.BaseMass; }//// initShipDim(); sInitResults += modeOnInit(); // handle mode initializing from load/recompile.. init = true; // we are done } currentInit++; if (init) { currentInit = 0; } Log(sInitResults); return(sInitResults); }
string doInit() { // initialization of each module goes here: // when all initialization is done, set init to true. if (currentInit == 0) { initLogging(); } Log("Init:" + currentInit.ToString()); double progress = currentInit * 100 / 3; string sProgress = progressBar(progress); StatusLog(moduleName + sProgress, textPanelReport); Echo("Init: " + currentInit.ToString()); if (currentInit == 0) { //StatusLog("clear",textLongStatus,true); StatusLog(DateTime.Now.ToString() + " " + OurName + ":" + moduleName + ":INIT", textLongStatus, true); if (!modeCommands.ContainsKey("findore")) { modeCommands.Add("findore", MODE_FINDORE); } gridsInit(); sInitResults += initSerializeCommon(); Deserialize(); initShipDim(); } else if (currentInit == 1) { sInitResults += BlockInit(); anchorPosition = gpsCenter; currentPosition = anchorPosition.GetPosition(); sInitResults += connectorsInit(); sInitResults += thrustersInit(gpsCenter); sInitResults += camerasensorsInit(gpsCenter); sInitResults += sensorInit(); // sInitResults += gearsInit(); sInitResults += tanksInit(); sInitResults += gyrosetup(); GyroControl.UpdateGyroList(gyros); sInitResults += drillInit(); sInitResults += ejectorsInit(); initCargoCheck(); Deserialize(); // bWantFast = false; sInitResults += modeOnInit(); init = true; } currentInit++; if (init) { currentInit = 0; } Log(sInitResults); Echo("Init exit"); return(sInitResults); }
string doInit() { // initialization of each module goes here: // when all initialization is done, set init to true. // set autogyro defaults. // LIMIT_GYROS = 1; // minAngleRad = 0.09f; // CTRL_COEFF = 0.75; // TODO: change to more atomic init Echo("Init:" + currentInit); if (currentInit == 0) { //StatusLog("clear",textLongStatus,true); StatusLog(DateTime.Now.ToString() + OurName + ":" + moduleName + ":INIT", textLongStatus, true); // if (!modeCommands.ContainsKey("launch")) modeCommands.Add("launch", MODE_LAUNCH); // if(!modeCommands.ContainsKey("godock")) modeCommands.Add("godock", MODE_DOCKING); if (!modeCommands.ContainsKey("scantest")) { modeCommands.Add("scantest", MODE_SCANTEST); } sInitResults += SerializeInit(); Deserialize(); sInitResults += gridsInit(); sInitResults += DefaultOrientationBlockInit(); initLogging(); } else if (currentInit == 1) { sInitResults += thrustersInit(shipOrientationBlock); sInitResults += rotorsNavInit(); sInitResults += wheelsInit(shipOrientationBlock); sInitResults += SensorInit(shipOrientationBlock); sInitResults += camerasensorsInit(shipOrientationBlock); sInitResults += connectorsInit(); } else if (currentInit == 2) { sInitResults += gyrosetup(); GyroControl.UpdateGyroList(gyros); GyroControl.SetRefBlock(shipOrientationBlock); sInitResults += lightsInit(); sInitResults += camerasensorsInit(shipOrientationBlock); calculateGridBBPosition(shipOrientationBlock); initShipDim(shipOrientationBlock); sInitResults += modeOnInit(); // handle mode initializting from load/recompile.. init = true; } currentInit++; if (init) { currentInit = 0; // bWantFast = false; } Log(sInitResults); // Echo("XXInit:"+currentInit); return(sInitResults); }
string doInit() { // Echo("InitA:" + currentInit + ":"+Runtime.CurrentInstructionCount+ "/"+Runtime.MaxInstructionCount); // initialization of each module goes here: // when all initialization is done, set init to true. if (bStartupError) { Echo("(RE)INIT:" + sStartupError); } Log("Init:" + currentInit.ToString()); // Echo(gtsAllBlocks.Count.ToString() + " Blocks"); /* * double progress = currentInit * 100 / 3; // 3=Number of expected INIT phases. * string sProgress = progressBar(progress); * StatusLog(moduleName + sProgress, textPanelReport); */ if (shipOrientationBlock != null) { // anchorPosition = shipOrientationBlock; // currentPosition = anchorPosition.GetPosition(); } // Echo("InitB:" + currentInit + ":"+Runtime.CurrentInstructionCount+ "/"+Runtime.MaxInstructionCount); do { // Echo("Init:" + currentInit); echoInstructions("Init:" + currentInit + " "); switch (currentInit) { case 0: sStartupError = ""; if (bStartupError) { gridsInit(); // check the entire grid again } bStartupError = false; StatusLog(DateTime.Now.ToString() + " " + OurName + ":" + moduleName + ":INIT", textLongStatus, true); break; case 2: sInitResults += gridsInit(); break; case 3: initLogging(); break; case 4: initTimers(); break; case 5: sInitResults += SerializeInit(); Deserialize(); // get info from savefile to avoid blind-rewrite of (our) defaults break; case 6: sInitResults += DefaultOrientationBlockInit(); break; case 7: initCargoCheck(); break; case 8: initPower(); break; case 9: sInitResults += thrustersInit(shipOrientationBlock); break; case 10: sInitResults += gyrosetup(); GyroControl.UpdateGyroList(gyros); break; case 11: if (shipOrientationBlock is IMyRemoteControl) { Vector3D playerPosition; bool bGotPlayer = ((IMyRemoteControl)shipOrientationBlock).GetNearestPlayer(out playerPosition); IMyRemoteControl myR = (IMyRemoteControl)shipOrientationBlock; myR.SetCollisionAvoidance(false); myR.SetDockingMode(false); myR.Direction = Base6Directions.Direction.Forward; myR.FlightMode = FlightMode.OneWay; myR.ClearWaypoints(); /* * if (bGotPlayer) * { * // we are a pirate faction. chase the player. * myR.AddWaypoint(playerPosition, "Name"); * myR.SetAutoPilotEnabled(true); * setMode(MODE_ATTACK); * } */ } break; case 12: sInitResults += wheelsInit(shipOrientationBlock); break; case 13: sInitResults += rotorsNavInit(); break; case 14: sInitResults += connectorsInit(); break; case 15: sInitResults += tanksInit(); break; case 16: sInitResults += drillInit(); sInitResults += controllersInit(); break; case 17: sInitResults += SensorInit(shipOrientationBlock); break; case 18: sInitResults += ejectorsInit(); break; case 19: sInitResults += antennaInit(); break; case 20: sInitResults += gasgenInit(); sInitResults += camerasensorsInit(shipOrientationBlock); sInitResults += airventInit(); break; case 21: autoConfig(); break; case 22: // bWantFast = false; if (bGotAntennaName) { sBanner = "*" + OurName + ":" + moduleName + " V" + sVersion + " "; } if (sBanner.Length > 34) { sBanner = OurName + ":" + moduleName + "\nV" + sVersion + " "; } if (shipOrientationBlock is IMyShipController) { MyShipMass myMass; myMass = ((IMyShipController)shipOrientationBlock).CalculateShipMass(); gridBaseMass = myMass.BaseMass; } sInitResults += modeOnInit(); // handle mode initializing from load/recompile.. break; case 23: // do startup error check init = true; // we are done sStartupError = ""; bStartupError = false; if (shipOrientationBlock == null) { bStartupError = true; sStartupError += "\nNo Ship Controller"; } if (ionThrustCount < 1 && hydroThrustCount < 1 && atmoThrustCount < 1) { // no thrusters if (wheelSledList.Count < 1) { // no sled wheels && no thrusters if (rotorNavRightList.Count < 1) { bStartupError = true; sStartupError += "\nNo Propulsion Method Found"; sStartupError += "\nNo Thrusters.\nNo NAV Rotors\nNo Sled Wheels"; } } else { // sled wheels, but not thrusters... bStartupError = true; sStartupError += "\nNo Valid Propulsion Method Found"; sStartupError += "\nSled wheels, but No Thrusters.\nNo NAV Rotors"; } } else { // we DO have thrusters if (gyros.Count < 1) { // thrusters, but no gyros bStartupError = true; sStartupError += "\nNo Gyros Found"; } // check for sled wheels? if (shipOrientationBlock is IMyShipController) { // can check gravity.. } } // check for [WCCS] timer, but no Wico Craft Save.. and vice-versa if (TimerTriggerFind(sSubModuleTimer)) { // there is a submodule timer trigger if (SaveFile == null) { // no save text panel bStartupError = true; sStartupError += "\nSubmodule timer, but no text\n panel named:" + SAVE_FILE_NAME; } } else { if (bSupportSubModules) { bStartupError = true; sStartupError += "\nSubmodules Enabled, but no\n timer containing:" + sSubModuleTimer; if (SaveFile == null) { // no save text panel bStartupError = true; sStartupError += "\n No text\n panel containing:" + SAVE_FILE_NAME; } } } if (!bStartupError) { init = true; } else { currentInit = -1; // start init all over again } break; } currentInit++; // echoInstructions("EInit:" + currentInit + " | "); // Echo("%=" + (float)Runtime.CurrentInstructionCount / (float)Runtime.MaxInstructionCount); }while (!init && (((float)Runtime.CurrentInstructionCount / (float)Runtime.MaxInstructionCount) < 0.2f)); /* * if (currentInit == 0) * { * // Echo("Init0:" + currentInit + ":"+Runtime.CurrentInstructionCount+ "/"+Runtime.MaxInstructionCount); * // StatusLog("clear", textLongStatus, true); // only MAIN module should clear long status on init. * StatusLog(DateTime.Now.ToString() + " " + OurName + ":" + moduleName + ":INIT", textLongStatus, true); * * sInitResults += gridsInit(); * initLogging(); * initTimers(); * sInitResults += SerializeInit(); * * Deserialize(); // get info from savefile to avoid blind-rewrite of (our) defaults * } * else if (currentInit == 1) * { * Deserialize();// get info from savefile to avoid blind-rewrite of (our) defaults * * sInitResults += DefaultOrientationBlockInit(); * initCargoCheck(); * initPower(); * sInitResults += thrustersInit(shipOrientationBlock); * sInitResults += gyrosetup(); * GyroControl.UpdateGyroList(gyros); * if (gtsAllBlocks.Count < 300) currentInit = 2; // go ahead and do next step. * } * if (currentInit == 2) * { * sInitResults += wheelsInit(shipOrientationBlock); * sInitResults += rotorsNavInit(); * sInitResults += wheelsInit(shipOrientationBlock); * sInitResults += sensorInit(true); * * if (gtsAllBlocks.Count < 100) currentInit = 3; // go ahead and do next step. * } * if (currentInit == 3) * { * sInitResults += connectorsInit(); * sInitResults += tanksInit(); * sInitResults += drillInit(); * sInitResults += controllersInit(); * if (gtsAllBlocks.Count < 100) currentInit = 4; // go ahead and do next step. * } * if (currentInit == 4) * { * sInitResults += ejectorsInit(); * sInitResults += antennaInit(); * sInitResults += gasgenInit(); * sInitResults += camerasensorsInit(shipOrientationBlock); * sInitResults += airventInit(); * * // Serialize(); * * autoConfig(); * bWantFast = false; * * if (bGotAntennaName) * sBanner = "*" + OurName + ":" + moduleName + " V" + sVersion + " "; * * if(sBanner.Length>34) * { * sBanner = OurName + ":" + moduleName + "\nV" + sVersion + " "; * } * * if (shipOrientationBlock is IMyShipController) * { * MyShipMass myMass; * myMass = ((IMyShipController)shipOrientationBlock).CalculateShipMass(); * * gridBaseMass = myMass.BaseMass; * }//// * initShipDim(shipOrientationBlock); * * sInitResults += modeOnInit(); // handle mode initializing from load/recompile.. * * if(currentInit==5) * { * sStartupError = ""; * bStartupError = false; * if (shipOrientationBlock == null) * { * bStartupError = true; * sStartupError += "\nNo Ship Controller"; * } * if (ionThrustCount < 1 && hydroThrustCount < 1 && atmoThrustCount < 1) * { * // no thrusters * if (wheelSledList.Count < 1) * { * // no sled wheels && no thrusters * if (rotorNavRightList.Count < 1) * { * bStartupError = true; * sStartupError += "\nNo Propulsion Method Found"; * sStartupError += "\nNo Thrusters.\nNo NAV Rotors\nNo Sled Wheels"; * * } * } * else * { * // sled wheels, but not thrusters... * bStartupError = true; * sStartupError += "\nNo Valid Propulsion Method Found"; * sStartupError += "\nSled wheels, but No Thrusters.\nNo NAV Rotors"; * } * } * else * { * // we DO have thrusters * if (gyros.Count < 1) * { * // thrusters, but no gyros * bStartupError = true; * sStartupError += "\nNo Gyros Found"; * } * // check for sled wheels? * if (shipOrientationBlock is IMyShipController) * { * // can check gravity.. * } * } * // check for [WCCS] timer, but no Wico Craft Save.. and vice-versa * if (TimerTriggerFind(sSubModuleTimer)) * { * // there is a submodule timer trigger * if (SaveFile == null) * { // no save text panel * * bStartupError = true; * sStartupError += "\nSubmodule timer, but no text\n panel named:" + SAVE_FILE_NAME; * * } * } * else * { * if (bSubModules) * { * bStartupError = true; * sStartupError += "\nSubmodules Enabled, but no\n timer containing:" + sSubModuleTimer; * if (SaveFile == null) * { // no save text panel * * bStartupError = true; * sStartupError += "\n No text\n panel containing:" + SAVE_FILE_NAME; * * } * * } * } * * } * init = true; // we are done * } * * currentInit++; */ if (init) { currentInit = 0; } Log(sInitResults); return(sInitResults); }