void drawDrillStatus(Display screen, GeneralStatus status, float loadFactor, float angle, float targetAngle) { using (Display.Frame f = screen.DrawFrame()) { if (status.AreFrontLightsOn) { f.DrawCollection("drillLights", translation: LIGHTS_OFFSET); } if (status.AreArmLightsOn) { f.DrawCollection("drillLights", translation: DRILL_ARM_CENTER, rotation: angle); } f.DrawCollection("drillsShapesBackground"); f.Draw(new Shape("SquareSimple", this.scheme.MedDark, position: new Vector2(32, 93), size: new Vector2(loadFactor * 108, 45))); f.DrawCollection("drillsShapesForeground"); if (!float.IsNaN(angle)) { if (!float.IsNaN(targetAngle)) { f.DrawCollection("drillShapesArm", translation: DRILL_ARM_CENTER, rotation: targetAngle, color: this.scheme.MedDark); } f.DrawCollection("drillShapesArm", translation: DRILL_ARM_CENTER, rotation: angle); } f.DrawText($"Full at {loadFactor * 100:000}%", INV_TEXT_POS, scale: 0.5f, alignment: TextAlignment.LEFT); f.DrawText(this.conStatus(), CON_TEXT_POS, scale: 0.5f, alignment: TextAlignment.LEFT); } }
void _updateScreens(GeneralStatus status, InventoriesController inventoryController) { if (this._drillSurface != null) { this._drawDrillStatus(this._drillSurface, status, inventoryController.LoadFactor, -status.ArmAngle, -status.ArmTarget); } }
void updateScreens(GeneralStatus status, InventoryWatcher invWatcher) { foreach (Display display in this.drillDisplays) { this.drawDrillStatus(display, status, invWatcher.LoadFactor, -status.ArmAngle, -status.ArmTarget); } }
//readonly List<Display> wheelDisplays; public ScreensController(GeneralStatus status, InventoryWatcher invWatcher, IEnumerable <IMyTextSurface> drillStatusSurfaces, IEnumerable <IMyTextSurface> wheelStatusSurfaces, ColorScheme scheme, string sprites, IProcessSpawner spawner) { this.scheme = scheme; var sprts = new ShapeCollections(this.scheme); sprts.Parse(sprites); this.drillDisplays = drillStatusSurfaces.Select(s => new Display(s, new Vector2(2, 25), scheme: this.scheme, sprites: sprts)).ToList(); //this.wheelDisplays = wheelStatusSurfaces.Select(s => new Display(s, new Vector2(2, 25), scheme: this.scheme)).ToList(); this.status = status; spawner.Spawn(p => this.updateScreens(status, invWatcher), "screens-update", period: 20); }
public ErrorCode GetGeneralStatus(out int state, out int currentMode, out int calibrationError, out int bCalIsBooting, out float tempC, out int upTimeSec, out int noMotionBiasCount, out int tempCompensationCount, out ErrorCode lastError) { GeneralStatus statusToFill = new GeneralStatus(); ErrorCode errCode = GetGeneralStatus(statusToFill); state = (int)statusToFill.state; currentMode = (int)statusToFill.currentMode; calibrationError = statusToFill.calibrationError; bCalIsBooting = statusToFill.bCalIsBooting ? 1 : 0; tempC = statusToFill.tempC; upTimeSec = statusToFill.upTimeSec; noMotionBiasCount = statusToFill.noMotionBiasCount; tempCompensationCount = statusToFill.tempCompensationCount; lastError = statusToFill.lastError; return(SetLastError(errCode)); }
public ScreensController(GeneralStatus status, InventoriesController inventoryController, IMyTextSurface drillStatusSurface, IMyTextSurface wheelStatusSurface, ColorScheme scheme, string sprites, IProcessSpawner spawner) { this._scheme = scheme; if (drillStatusSurface != null) { var offset = new Vector2(2, 25); var sprts = new ShapeCollections(this._scheme); sprts.Parse(sprites); this._drillSurface = new Display(drillStatusSurface, offset, scheme: this._scheme, sprites: sprts); } if (wheelStatusSurface != null) { this._wheelSurface = new Display(wheelStatusSurface, scheme: this._scheme); } this._status = status; spawner.Spawn(p => this._updateScreens(status, inventoryController), "screens-update", period: 20); }
public Program() { this.Runtime.UpdateFrequency = UpdateFrequency.Update1; var topLefts = new List <IMyTextSurface>(); var topRights = new List <IMyTextSurface>(); IMyTextSurface keyboard; IMyCockpit cockpit; this.manager = Process.CreateManager(this.Echo); this.initCockpit(out cockpit, topLefts, topRights, out keyboard); var ct = new CoordinatesTransformer(cockpit, this.manager); var logger = new Logger(this.manager, keyboard, new Color(0, 39, 15), new Color(27, 228, 33), this.Echo, 1.0f); this.cmd = new CommandLine("Boring machine", logger.Log, this.manager); var ini = new IniWatcher(this.Me, this.manager); var wc = new WheelsController(this.cmd, cockpit, this.GridTerminalSystem, ini, this.manager, ct); var ac = new ArmController(ini, this, this.cmd, cockpit, wc, this.manager); var iw = new InventoryWatcher(this.cmd, this.GridTerminalSystem, cockpit); var cc = new ConnectionClient(ini, this.GridTerminalSystem, this.IGC, this.cmd, this.manager, logger.Log); var rcs = new List <IMyRemoteControl>(); this.GridTerminalSystem.GetBlocksOfType(rcs, r => r.CubeGrid == this.Me.CubeGrid); IMyRemoteControl frc = rcs.First(r => r.DisplayNameText.Contains("Forward")); IMyRemoteControl brc = rcs.First(r => r.DisplayNameText.Contains("Backward")); var ap = new Autopilot(ini, wc, this.cmd, frc, logger.Log, this.manager); var ah = new PilotAssist(this.GridTerminalSystem, ini, logger.Log, this.manager, wc); ah.AddBraker(cc); ah.AddDeactivator(ap); var ar = new AutoRoutineHandler(this.cmd); // TODO parse routines new MiningRoutines(ini, this.cmd, ap, this.manager); var progs = new List <IMyProgrammableBlock>(); this.GridTerminalSystem.GetBlocksOfType(progs, pr => pr.CubeGrid == this.Me.CubeGrid); var genStatus = new GeneralStatus(this, ac, cc); new ScreensController(genStatus, iw, topLefts, topRights, this.scheme, cockpit.CustomData, this.manager); }
public Program() { this.Runtime.UpdateFrequency = UpdateFrequency.Update1; IMyTextSurface topLeft, topRight, keyboard; IMyCockpit cockpit; this.manager = Process.CreateManager(this.Echo); this.initCockpit(out cockpit, out topLeft, out topRight, out keyboard); var ct = new CoordinatesTransformer(cockpit, this.manager); var logger = new Logger(this.manager, keyboard, this.scheme.Light, this.scheme.Dark, this.Echo); logger.Log("Booting up..."); this.cmd = new CommandLine("Boring machine", logger.Log, this.manager); var genStatus = new GeneralStatus(this, this.cmd); var wb = new WheelBase(); var wheels = new List <IMyMotorSuspension>(); this.GridTerminalSystem.GetBlocksOfType(wheels, w => w.CubeGrid == this.Me.CubeGrid && w.DisplayNameText.Contains("Power")); wheels.ForEach(w => wb.AddWheel(new PowerWheel(w, wb, ct))); var ic = new InventoriesController(ct, this.GridTerminalSystem, cockpit, wb.CenterOfTurnZ + 2, this.manager); new ScreensController(genStatus, ic, topLeft, topRight, this.scheme, cockpit.CustomData, this.manager); }
/** * Get the status of the current (or previousley complete) calibration. * @param statusToFill */ public ErrorCode GetGeneralStatus(GeneralStatus statusToFill) { ErrorCode errCode = (ErrorCode)ReceiveCAN(COND_STATUS_1 | (int)_baseArbId); byte b3 = (byte)(_cache >> 0x18); byte b5 = (byte)(_cache >> 0x28); byte iCurrMode = (byte)((b5 >> 4) & 0xF); CalibrationMode currentMode = (CalibrationMode)(iCurrMode); /* shift up bottom nibble, and back down with sign-extension */ int calibrationErr = b5 & 0xF; calibrationErr <<= (32 - 4); calibrationErr >>= (32 - 4); int noMotionBiasCount = (byte)(_cache >> 0x24) & 0xF; int tempCompensationCount = (byte)(_cache >> 0x20) & 0xF; int upTimSec = (byte)(_cache >> 0x38); statusToFill.currentMode = currentMode; statusToFill.calibrationError = calibrationErr; statusToFill.bCalIsBooting = ((b3 & 1) == 1); statusToFill.state = GetState((int)errCode, _cache); statusToFill.tempC = (float)GetTemp(_cache); statusToFill.noMotionBiasCount = noMotionBiasCount; statusToFill.tempCompensationCount = tempCompensationCount; statusToFill.upTimeSec = upTimSec; statusToFill.lastError = errCode; /* build description string */ if (errCode != 0) { // same as NoComm statusToFill.description = "Status frame was not received, check wired connections and web-based config."; } else if (statusToFill.bCalIsBooting) { statusToFill.description = "Pigeon is boot-caling to properly bias accel and gyro. Do not move Pigeon. When finished biasing, calibration mode will start."; } else if (statusToFill.state == PigeonState.UserCalibration) { /* mode specific descriptions */ switch (currentMode) { case CalibrationMode.BootTareGyroAccel: statusToFill.description = "Boot-Calibration: Gyro and Accelerometer are being biased."; break; case CalibrationMode.Temperature: statusToFill.description = "Temperature-Calibration: Pigeon is collecting temp data and will finish when temp range is reached. Do not move Pigeon."; break; case CalibrationMode.Magnetometer12Pt: statusToFill.description = "Magnetometer Level 1 calibration: Orient the Pigeon PCB in the 12 positions documented in the User's Manual."; break; case CalibrationMode.Magnetometer360: statusToFill.description = "Magnetometer Level 2 calibration: Spin robot slowly in 360' fashion. "; break; case CalibrationMode.Accelerometer: statusToFill.description = "Accelerometer Calibration: Pigeon PCB must be placed on a level source. Follow User's Guide for how to level surfacee. "; break; } } else if (statusToFill.state == PigeonState.Ready) { /* definitely not doing anything cal-related. So just instrument the motion driver state */ statusToFill.description = "Pigeon is running normally. Last CAL error code was "; statusToFill.description += calibrationErr; statusToFill.description += "."; } else if (statusToFill.state == PigeonState.Initializing) { /* definitely not doing anything cal-related. So just instrument the motion driver state */ statusToFill.description = "Pigeon is boot-caling to properly bias accel and gyro. Do not move Pigeon."; } else { statusToFill.description = "Not enough data to determine status."; } return(SetLastError(errCode)); }
protected override object this[string index] { get { #region switch (index) { case "UserID": return UserID; case "GeneralID": return GeneralID; case "GeneralName": return GeneralName; case "HeadID": return HeadID; case "PicturesID": return PicturesID; case "GeneralLv": return GeneralLv; case "LifeNum": return LifeNum; case "GeneralType": return GeneralType; case "CareerID": return CareerID; case "PowerNum": return PowerNum; case "SoulNum": return SoulNum; case "IntellectNum": return IntellectNum; case "TrainingPower": return TrainingPower; case "TrainingSoul": return TrainingSoul; case "TrainingIntellect": return TrainingIntellect; case "HitProbability": return HitProbability; case "AbilityID": return AbilityID; case "Momentum": return Momentum; case "Description": return Description; case "GeneralStatus": return GeneralStatus; case "CurrExperience": return CurrExperience; case "Experience1": return Experience1; case "Experience2": return Experience2; case "HeritageType": return HeritageType; case "FeelLv": return FeelLv; case "FeelExperience": return FeelExperience; case "SaturationNum": return SaturationNum; case "HungerDate": return HungerDate; case "AtmanNum": return AtmanNum; case "Potential": return Potential; case "Attribute": return Attribute; case "AbilityNum": return AbilityNum; default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "UserID": _UserID = value.ToNotNullString(); break; case "GeneralID": _GeneralID = value.ToInt(); break; case "GeneralName": _GeneralName = value.ToNotNullString(); break; case "HeadID": _HeadID = value.ToNotNullString(); break; case "PicturesID": _PicturesID = value.ToNotNullString(); break; case "GeneralLv": _GeneralLv = value.ToShort(); break; case "LifeNum": _LifeNum = value.ToInt(); break; case "GeneralType": _GeneralType = value.ToEnum<GeneralType>(); break; case "CareerID": _CareerID = value.ToShort(); break; case "PowerNum": _PowerNum = value.ToShort(); break; case "SoulNum": _SoulNum = value.ToShort(); break; case "IntellectNum": _IntellectNum = value.ToShort(); break; case "TrainingPower": _TrainingPower = value.ToShort(); break; case "TrainingSoul": _TrainingSoul = value.ToShort(); break; case "TrainingIntellect": _TrainingIntellect = value.ToShort(); break; case "HitProbability": _HitProbability = value.ToDecimal(); break; case "AbilityID": _AbilityID = value.ToInt(); break; case "Momentum": _Momentum = value.ToShort(); break; case "Description": _Description = value.ToNotNullString(); break; case "GeneralStatus": _GeneralStatus = value.ToEnum<GeneralStatus>(); break; case "CurrExperience": _CurrExperience = value.ToInt(); break; case "Experience1": _Experience1 = value.ToInt(); break; case "Experience2": _Experience2 = value.ToInt(); break; case "HeritageType": _HeritageType = value.ToEnum<HeritageType>(); break; case "FeelLv": _FeelLv = value.ToShort(); break; case "FeelExperience": _FeelExperience = value.ToInt(); break; case "SaturationNum": _SaturationNum = value.ToShort(); break; case "HungerDate": _HungerDate = value.ToDateTime(); break; case "AtmanNum": _AtmanNum = value.ToInt(); break; case "Potential": _Potential = value.ToInt(); break; case "Attribute": _Attribute = ConvertCustomField<CacheList<GeneralProperty>>(value, index); break; case "AbilityNum": _AbilityNum = value.ToInt(); break; default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index)); } #endregion } }
public object Get(GeneralStatus request) { return(new HttpError(HttpStatusCode.OK, "All services are functional.")); }
protected override object this[string index] { get { #region switch (index) { case "UserID": return(UserID); case "GeneralID": return(GeneralID); case "GeneralName": return(GeneralName); case "HeadID": return(HeadID); case "PicturesID": return(PicturesID); case "GeneralLv": return(GeneralLv); case "LifeNum": return(LifeNum); case "GeneralType": return(GeneralType); case "CareerID": return(CareerID); case "PowerNum": return(PowerNum); case "SoulNum": return(SoulNum); case "IntellectNum": return(IntellectNum); case "TrainingPower": return(TrainingPower); case "TrainingSoul": return(TrainingSoul); case "TrainingIntellect": return(TrainingIntellect); case "HitProbability": return(HitProbability); case "AbilityID": return(AbilityID); case "Momentum": return(Momentum); case "Description": return(Description); case "GeneralStatus": return(GeneralStatus); case "CurrExperience": return(CurrExperience); case "Experience1": return(Experience1); case "Experience2": return(Experience2); case "HeritageType": return(HeritageType); case "FeelLv": return(FeelLv); case "FeelExperience": return(FeelExperience); case "SaturationNum": return(SaturationNum); case "HungerDate": return(HungerDate); case "AtmanNum": return(AtmanNum); case "Potential": return(Potential); case "Attribute": return(Attribute); case "AbilityNum": return(AbilityNum); default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index)); } #endregion } set { #region switch (index) { case "UserID": _UserID = value.ToNotNullString(); break; case "GeneralID": _GeneralID = value.ToInt(); break; case "GeneralName": _GeneralName = value.ToNotNullString(); break; case "HeadID": _HeadID = value.ToNotNullString(); break; case "PicturesID": _PicturesID = value.ToNotNullString(); break; case "GeneralLv": _GeneralLv = value.ToShort(); break; case "LifeNum": _LifeNum = value.ToInt(); break; case "GeneralType": _GeneralType = value.ToEnum <GeneralType>(); break; case "CareerID": _CareerID = value.ToShort(); break; case "PowerNum": _PowerNum = value.ToShort(); break; case "SoulNum": _SoulNum = value.ToShort(); break; case "IntellectNum": _IntellectNum = value.ToShort(); break; case "TrainingPower": _TrainingPower = value.ToShort(); break; case "TrainingSoul": _TrainingSoul = value.ToShort(); break; case "TrainingIntellect": _TrainingIntellect = value.ToShort(); break; case "HitProbability": _HitProbability = value.ToDecimal(); break; case "AbilityID": _AbilityID = value.ToInt(); break; case "Momentum": _Momentum = value.ToShort(); break; case "Description": _Description = value.ToNotNullString(); break; case "GeneralStatus": _GeneralStatus = value.ToEnum <GeneralStatus>(); break; case "CurrExperience": _CurrExperience = value.ToInt(); break; case "Experience1": _Experience1 = value.ToInt(); break; case "Experience2": _Experience2 = value.ToInt(); break; case "HeritageType": _HeritageType = value.ToEnum <HeritageType>(); break; case "FeelLv": _FeelLv = value.ToShort(); break; case "FeelExperience": _FeelExperience = value.ToInt(); break; case "SaturationNum": _SaturationNum = value.ToShort(); break; case "HungerDate": _HungerDate = value.ToDateTime(); break; case "AtmanNum": _AtmanNum = value.ToInt(); break; case "Potential": _Potential = value.ToInt(); break; case "Attribute": _Attribute = ConvertCustomField <CacheList <GeneralProperty> >(value, index); break; case "AbilityNum": _AbilityNum = value.ToInt(); break; default: throw new ArgumentException(string.Format("UserGeneral index[{0}] isn't exist.", index)); } #endregion } }