public void Kill() { Int32 ExcelHwnd = excel.Hwnd; Process[] localExcel = Process.GetProcessesByName("EXCEL"); foreach (Process Pgm in localExcel) { // xlMinimized keeps the screen from flashing when the user interface is made visible to set the MainWindowHandle try { excel.WindowState = XlWindowState.xlMinimized; } catch (Exception e1) { // Skip it catchData = "No window to minimize - excel.Kill: " + path + e1.Message; } // Excel won't have an Hwnd (window Handle) until it's visible. excel.Visible = true; if ((Pgm.ProcessName == "EXCEL") && (ExcelHwnd == Pgm.MainWindowHandle.ToInt32())) { Pgm.Kill(); } } }
public static BigPolyArray[] GetEncryptedDataInBatches(EncCal encCal, Pgm picture, int size = 3) { var encryptedData = new BigPolyArray[picture.Length * size]; Parallel.For(0, picture.Length, l => { int slotCount = encCal.CrtBuilder.SlotCount; var values1 = new BigUInt[encCal.CrtBuilder.SlotCount]; var values2 = new BigUInt[encCal.CrtBuilder.SlotCount]; var values3 = new BigUInt[encCal.CrtBuilder.SlotCount]; Parallel.For(0, slotCount, i => { values1[i] = new BigUInt(encCal.GetBitCount(), 0); values2[i] = new BigUInt(encCal.GetBitCount(), 0); values3[i] = new BigUInt(encCal.GetBitCount(), 0); }); Parallel.For(0, picture.Width, i => { values1[i].Set(picture.Data[(l * picture.Length) + i]); values2[i + 1].Set(picture.Data[(l * picture.Length) + i]); values3[i + 2].Set(picture.Data[(l * picture.Length) + i]); }); encryptedData[size * l] = encCal.GetEnc(encCal.CrtBuilder.Compose(values1.ToList())); encryptedData[size * l + 1] = encCal.GetEnc(encCal.CrtBuilder.Compose(values2.ToList())); encryptedData[size * l + 2] = encCal.GetEnc(encCal.CrtBuilder.Compose(values3.ToList())); }); return(encryptedData); }
public EngineModule(Program p) : base(p) { tsToggle = (tf) => SetEnabledAbsToggle(GetThrustBlocks(tf, Pgm, Me, Pgm.GetShipController())); tsEnable = (tf, on) => SetEnabled(GetThrustBlocks(tf, Pgm, Me, Pgm.GetShipController()), on); tsPower = (tf, modifier) => { var lst = GetThrustBlocks(tf, Pgm, Me, Pgm.GetShipController()); if (0 != modifier && 0 < lst.Count) { var current = 0f; foreach (var b in lst) { current += (b as IMyThrust).ThrustOverridePercentage; } if (100f == modifier) { modifier = 0 < current ? 0 : 1; // Toggle between 0% and 100% thrust } else { modifier = MathHelper.Clamp((current / lst.Count) + Math.Sign(modifier) * 0.1f, 0, 1); // Inc./dec. thrust by 10% } } SetThrustAbsPct(lst, modifier); }; }
public void TestLocalFuncQuery() { string pgm = @" function bar(x, y) = (y + x); function foo(x) = bar(x,1); program incr(w) { return iter(c in w) { case(((foo(c)-1)==c)&&true||false): yield(c + 0 + 1); }; } == js(incr); "; StringWriter sw = new StringWriter(); Pgm.Run(pgm, sw, "bek_master.html"); string s = sw.ToString(); Console.WriteLine(s); Assert.IsTrue(s.Contains("foo")); }
public void TestBase16() { string bek = @" function E(x)=ite(x < 10, x + 48, x + 55); function D(x)=ite(x < 58, x - 48, x - 55); program base16encode(input){ replace { @""[\0-\xFF]"" ==> [E(#0 >> 4),E(#0 & 0xF)]; } } program base16decode(input){ replace { ""[A-Z0-9]{2}"" ==> [(D(#0) << 4) + D(#1)]; } } // Identity Encoder program ID(_){replace { ""."" ==> [#0];}} == js(base16encode); BYTES = regex(@""^[\0-\xFF]*$""); //domain of sequences of bytes ID_BYTES = restrict(ID,BYTES); //identity over sequences of bytes ed = join(base16encode, base16decode); //composition, first encode then decode eq(ID_BYTES, ed); "; StringWriter sw = new StringWriter(); Pgm.Run(bek, sw, ""); string s = sw.ToString(); Console.WriteLine(s); Assert.IsTrue(s.Contains("Result: Equivalent")); }
static void Main(string[] args) { var inputNodes = File.ReadAllLines(@".\input.txt").Select(s => s.Replace(" ", "")).ToList(); for (int i = 0; i < inputNodes.Count; i++) { var tempSplit = inputNodes[i].Split(new string[] { "<->", "," }, StringSplitOptions.RemoveEmptyEntries) .Select(s => int.Parse(s)) .ToList(); var pgm = new Pgm(tempSplit[0]); pgm.Neighbours.AddRange(tempSplit.GetRange(1, tempSplit.Count - 1)); programs.Add(pgm); } TraverseChildrens(0); Console.WriteLine($"Day 12 - Assignment 1: The number of programs in this group is: {programs.Count(p => p.Visited)}"); //Eftersom uppgift ett redan har gjort grupp 1 int numberOfGroups = 1; while (programs.Any(p => !p.Visited)) { numberOfGroups++; TraverseChildrens(programs.First(p => p.Visited == false).Id); } Console.WriteLine($"Day 12 - Assignment 2: The number of groups is: {numberOfGroups}"); }
public void TestBase64Equiv() { string bek = @" function E(x)=(ite(x<=25,x+65,ite(x<=51,x+71,ite(x<=61,x-4,ite(x==62,'+','/'))))); function D(x)=(ite(x=='/',63,ite(x=='+',62,ite(x<='9',x+4,ite(x<='Z',x-65,x-71))))); program base64encode(_){ replace { @""[\0-\xFF]{3}"" ==> [E(Bits(7,2,#0)), E((Bits(1,0,#0)<<4)|Bits(7,4,#1)), E((Bits(3,0,#1)<<2)|Bits(7,6,#2)), E(Bits(5,0,#2))]; @""[\0-\xFF]{2}$"" ==> [E(Bits(7,2,#0)), E((Bits(1,0,#0)<<4)|Bits(7,4,#1)), E(Bits(3,0,#1)<<2), '=']; @""[\0-\xFF]$"" ==> [E(Bits(7,2,#0)), E(Bits(1,0,#0)<<4), '=', '=']; } } program base64decode(_){ replace { ""[a-zA-Z0-9+/]{4}"" ==> [(D(#0)<<2)|bits(5,4,D(#1)), (bits(3,0,D(#1))<<4)|bits(5,2,D(#2)), (bits(1,2,D(#2))<<6)|D(#3)]; ""[a-zA-Z0-9+/]{3}=$"" ==> [(D(#0)<<2)|bits(5,4,D(#1)), (bits(3,0,D(#1))<<4)|bits(5,2,D(#2))]; ""[a-zA-Z0-9+/]{2}==$""==> [(D(#0)<<2)|bits(5,4,D(#1))]; } } program ID(w){return iter(x in w){case (true):yield(x);};} == BYTES = regex(@""^[\0-\xFF]*$""); //domain of sequences of bytes ID_BYTES = restrict(ID,BYTES); //identity over sequences of bytes ed = join(base64encode, base64decode); //composition, first encode then decode eq(ID_BYTES, ed); "; StringWriter sw = new StringWriter(); Pgm.Run(bek, sw, ""); string s = sw.ToString(); Console.WriteLine(s); Assert.IsTrue(s.Contains("Equivalent")); }
public void Refresh(OutputPanel _lcds, IMyShipController _sc = null) { sc = _sc ?? Pgm.GetShipController(MultiMix_UsedBlocks); lcds = _lcds; lcds.SetFont("Monospace", 1.25f); lcds.SetAlign(2); }
public void SetInten(UInt32 inten, Pgm pgm) { //if (!pgm.Runtime.PgmDict.ContainsKey(lastPgmId)) lastPgmId = 0; //if (pgm.PgmId >= lastIntenPgmId) //{ // //last = (last & 0x000ffffff) | (inten & 0x0ff000000); // lastIntenPgmId = pgm.PgmId; //} }
public override void Set(Clr val, Pgm pgm) { //if (!pgm.Runtime.PgmDict.ContainsKey(lastPgmId)) lastPgmId = 0; //if (pgm.PgmId >= lastPgmId) //{ // //last = (last & 0x0ff000000) | (val & 0x000ffffff); // lastPgmId = pgm.PgmId; // SetInten(val, pgm); //} }
public void Refresh(OutputPanel _lcd, AlignModule _align, IMyShipController _sc = null) { lcd = _lcd; align = _align; sc = _sc ?? Pgm.GetShipController(MultiMix_UsedBlocks); RefreshThrustsList(_align?.RocketMode ?? false); hydrogenTanks.Clear(); if (null != downCamera) { downCamera.EnableRaycast = false; } downCamera = null; parachute = null; IMyGasTank hb = null; IMyBatteryBlock bb = null; IMyCameraBlock cb = null; IMyParachute pb = null; GatherBlocks(Pgm , a => SameGrid(Me, a) && !NameContains(a, MultiMix_IgnoreBlocks) , b => { if (ToType(b, ref hb) && hb.IsWorking && SubtypeContains(hb, "Hydrogen")) { hydrogenTanks.Add(hb); return(false); } return(true); } , c => { if (ToType(c, ref bb) && bb.IsWorking) { batteries.Add(bb); return(false); } return(true); } , d => { if (ToType(d, ref cb) && cb.IsWorking && NameContains(cb, "Down")) { downCamera = cb; cb.EnableRaycast = true; return(false); } return(true); } , e => { if (ToType(e, ref pb) && pb.IsWorking) { parachute = pb; return(false); } return(true); } ); if (null == stateMachine) { SetRunState(false); } }
public static void IncreaseState(string newPgm, string newPvw, string newNext) { if (Pgm.Equals(newPgm) && Pvw.Equals(newPvw)) { Console.WriteLine("id: {0} / state: {1}", id, state); return; } state += 1; Pgm = newPgm; Pvw = newPvw; Next = newNext; Console.WriteLine("id: {0} / state: {1}", id, state); }
IEnumerable <int> DoDescend() { var rc = Pgm.GetShipController(); if (null == rc) { yield break; } rc.DampenersOverride = false; yield return(100); rc = Pgm.GetShipController(); if (null != rc) { rc.DampenersOverride = true; } }
static void Main(string[] args) { //var location = args[0]; //var InputFileName = args[1]; Pgm Picture = new Pgm(location + InputFileName); EncCal encCal = new EncCal("1x^4096 + 1", 4096, 40961, 12, 10); var encryptedDataBat = GetEncryptedDataInBatches(encCal, Picture); var binForm = new BinaryFormatter(); using (TcpClient client = new TcpClient(SERVER_IP, PORT_NO)) { using (NetworkStream nwStream = client.GetStream()) { //Fixing the buffer size - not mandatory client.ReceiveBufferSize = 131116; binForm.Serialize(nwStream, encryptedDataBat.Length); Wait(nwStream, binForm); //Send public key SendEncryptedArray(new BigPolyArray[] { encCal.GetPublicKey() }, nwStream, binForm); //Send encrypted data SendEncryptedArray(encryptedDataBat, nwStream, binForm); //Receive results BigPolyArray[] encryptedResults = ReceiveEncryptedArray(encryptedDataBat.Length / 3, client, nwStream, binForm); byte[] results; //Decrypte data GetResults(Picture, "edg", encryptedResults, encCal, location, InputFileName, out results); Console.ReadLine(); client.Close(); } } Console.WriteLine("Press return to exit."); Console.ReadLine(); }
public static void Load(XElement root) { XElement xpN = root.Element("GrpSeqs"); foreach (XElement cur in xpN.Elements("GrpSeq")) { GrpSeq grpseq = new GrpSeq((string)cur.Attribute(@"nm")); foreach (XElement stp in cur.Elements("step")) { List <Grp> stplst = new List <Grp>(); grpseq.GrpList.Add(stplst); foreach (XElement grp in stp.Elements("grp")) { stplst.Add(Pgm.ParseGrp(null, grp)); } } } }
public void Refresh(AscendDecendModule _asc, IMyShipController _sc = null) { asc = _asc; sc = _sc ?? Pgm.GetShipController(MultiMix_UsedBlocks); gyros.Clear(); IMyGyro g = null; GatherBlocks(Pgm , a => SameGrid(Me, a) && !NameContains(a, MultiMix_IgnoreBlocks) , b => { if (ToType(b, ref g) && g.IsWorking) { gyros.Add(g); return(false); } return(true); } ); maxYaw = (0 < gyros.Count ? gyros[0].GetMaximum <float>("Yaw") : 0); }
public void TestLooping() { string program = @" program RegexEscape(_){ replace { ""\t"" ==> ""\\t""; ""\n"" ==> ""\\n""; ""\f"" ==> ""\\f""; ""\r"" ==> ""\\r""; @""(\ |\#|\$|\(|\)|\*|\+|\.|\?|\[|\\|\^|\{|\|)"" ==> ['\\',#0]; else ==> [#0]; }} == a =join(RegexEscape,RegexEscape); eqB(1,RegexEscape,a); "; StringWriter sw = new StringWriter(); Pgm.Run(program, sw, ""); Assert.IsTrue(sw.ToString().Contains("Not Partial-Equivalent")); }
public void TestEndCase() { string program = @" program alpha(w) { return iter(c in w) [ b := false; ] { case(c in " + "\"[a-zA-Z ]\"" + @"): yield(c); } end { case(true): yield(';'); }; } program beta(w) { return iter(c in w) [ b := false; ] { case(c in " + "\"[a-zA-Z ]\"" + @"): yield(c); } end { case(!b): yield(';'); }; } == image(alpha, " + "\"Hello World\"" + @"); eq(alpha,beta); "; StringWriter sw = new StringWriter(); Pgm.Run(program, sw, ""); string s = sw.ToString(); Assert.IsTrue(s.Contains("Result: Equivalent")); }
public void caesarcipher() { string sample = @" // Caesar used a simple cipher // where all the letters were shifted by 3 function foo(x)= (x + 1 + 1); program caesarcipher(w) { return iter(c in w) { case(true): yield(c + 3); }; } == display(caesarcipher); js(caesarcipher);"; StringWriter sw = new StringWriter(); Pgm.Run(sample, sw, "../../bek.master.html"); string s = sw.ToString(); Console.WriteLine(s); Assert.IsTrue(s.Contains("foo")); }
public void TestOutput() { string program = @" program alpha(w) { return iter(c in w) [ b := false; ] { case(c in " + "\"[a-zA-Z ]\"" + @"): yield(c); end case(true): yield(';'); }; } == display(inv(alpha, " + "\"Hello World;\"" + @"));"; StringWriter sw = new StringWriter(); Pgm.Run(program, sw, ""); string s = sw.ToString(); Assert.IsTrue(s.Contains("Fig_1")); }
public void TestPreimage() { string program = @" program alpha(w) { return iter(c in w) { case(c == 'Y') : yield('H'); case((c in " + "\"[a-zA-Z ]\"" + @") && (c != 'H')): yield(c); end case(true): yield(';'); }; } == display(invimage(alpha," + "\"Hello World\"" + @")); "; StringWriter sw = new StringWriter(); Pgm.Run(program, sw, ""); string s = sw.ToString(); Assert.IsTrue(s.Contains("Fig_1")); }
static byte[] GetByteFromEnc(BigPolyArray[] valList, EncCal encCal, Pgm picture, int divisor = 1, int offsetLeft = 0) { var ret = new byte[picture.Length * picture.Width]; int slotCount = encCal.CrtBuilder.SlotCount; Parallel.For(0, valList.Length, l => { var values = new List <BigUInt>(slotCount); var plain = encCal.GetDecrypted(valList[l]); encCal.CrtBuilder.Decompose(plain, values); Parallel.For(0, picture.Width, i => { double val = Convert.ToDouble(values[i + offsetLeft].ToDecimalString()) / divisor; ret[l * picture.Width + i] = Convert.ToByte(val < 0 || val > 40000 ? 0 : val > 255 ? 255 : val); }); }); return(ret); }
public void BasicDisplay() { string program = @" function dec(x)=(x-48); program alpha(w) { return iter(c in w) [ b := false; ] { case(true): yield(dec(c), ' '); }; } == display(alpha);"; StringWriter sw = new StringWriter(); Pgm.Run(program, sw, "bek_master.html"); string s = sw.ToString(); Console.WriteLine(s); Assert.IsTrue(s.Contains("Fig_1")); }
public void TestImage() { string program = @" program alpha(w) { return iter(c in w) { case((c == 'h') || (c == 'l')): yield('X'); case(c == 'o'): yield(c); case(true): yield('i'); }; } == image(alpha, " + "\"hello\"" + @"); "; StringWriter sw = new StringWriter(); Pgm.Run(program, sw, ""); Assert.IsTrue(sw.ToString().Contains("XiXXo")); }
public void AddMenu(MenuManager menuMgr) { if (1 > GetThrustBlocks(ThrustFlags.All, Pgm, Me).Count) { return; // No thrusters found } const int p = 16; // padding MenuItem tt; menuMgr.Add( tt = Menu("Engine/Thrust settings").Add( Menu(() => GetText(1, "All Thrusters", p)) .Collect(this) .Enter("toggleEngines", () => tsToggle(ThrustFlags.All)) .Left(() => tsEnable(ThrustFlags.All, true)) .Right(() => tsEnable(ThrustFlags.All, false)), Menu("Engine types").Add( Menu(() => GetText(1, "Atmospheric", p + 0)) .Collect(this) .Enter("toggleAtmos", () => tsToggle(ThrustFlags.Atmospheric)) .Left(() => tsEnable(ThrustFlags.Atmospheric, true)) .Right(() => tsEnable(ThrustFlags.Atmospheric, false)), Menu(() => GetText(1, "Ion", p + 8)) .Collect(this) .Enter("toggleIon", () => tsToggle(ThrustFlags.Ion)) .Left(() => tsEnable(ThrustFlags.Ion, true)) .Right(() => tsEnable(ThrustFlags.Ion, false)), Menu(() => GetText(1, "Hydrogen", p + 2)) .Collect(this) .Enter("toggleHydro", () => tsToggle(ThrustFlags.Hydrogen)) .Left(() => tsEnable(ThrustFlags.Hydrogen, true)) .Right(() => tsEnable(ThrustFlags.Hydrogen, false)) ) ) ); if (null == Pgm.GetShipController()) { menuMgr.WarningText += "\n ShipController missing. Some features unavailable!"; } else { MenuItem md = Menu("Directions"); MenuItem mo = Menu("Override thrust"); int[] pad = new[] { p + 2, p + 1, p + 3, p + 1, p + 2, p + 0 }; int i = 0; foreach (string txt in Pgm.DIRECTIONS) { ThrustFlags tf = (ThrustFlags)(1 << i); int j = i++; md.Add( Menu(() => GetText(1, txt, pad[j])) .Collect(this) .Enter("toggle" + txt, () => tsToggle(tf)) .Left(() => tsEnable(tf, true)) .Right(() => tsEnable(tf, false)) ); mo.Add( Menu(() => GetText(2, txt, pad[j])) .Collect(this) .Enter("thrust" + txt, () => tsPower(tf, 100f)) .Left(() => tsPower(tf, -1)) .Right(() => tsPower(tf, 1)) .Back(() => tsPower(tf, 0)) ); } tt.Add(md, mo); } }
private void btnOK_Click(object sender, System.EventArgs e) { if (currentProject != null) { if (!string.IsNullOrEmpty(content.Trim())) { this.Hide(); if (isProjectBased) { currentPgm = new ProjectBasedPgm(currentProject, cmbPrograms.Text); } else { currentPgm = new FileBasedPgm(currentProject, this.txtProject.Text); } if (this.pgmDialogMode == PgmDialogMode.SaveProgram || this.pgmDialogMode == PgmDialogMode.SaveProgramAs) { this.cmbPrograms.SelectedIndexChanged -= new System.EventHandler(this.cmbPrograms_SelectedIndexChanged); string today = DateTime.Now.ToShortDateString(); if (programRow == null) { programRow = this.CreateProgramRow(currentProject); } programRow[ColumnNames.PGM_CONTENT] = content; programRow[ColumnNames.PGM_AUTHOR] = txtAuthor.Text.ToString(); programRow[ColumnNames.PGM_COMMENT] = txtComment.Text.ToString(); programRow[ColumnNames.PGM_NAME] = cmbPrograms.Text.ToString(); string createDate = txtDateCreated.Text.ToString(); DateTime tryDateTime; if (DateTime.TryParse(createDate, out tryDateTime) == false) { createDate = DateTime.Now.ToString(); } programRow[ColumnNames.PGM_CREATE_DATE] = createDate; programRow[ColumnNames.PGM_MODIFY_DATE] = DateTime.Now.ToString(); cmbPrograms.Enabled = true; currentPgm.PgmSave(programRow); this.cmbPrograms.Refresh(); this.cmbPrograms.SelectedIndexChanged += new System.EventHandler(this.cmbPrograms_SelectedIndexChanged); } else { if (programRow == null) { //programRow = currentPgm.PgmLoad(this.txtProject.Text); } } } else { // DEFECT: 231 if (this.pgmDialogMode == PgmDialogMode.SaveProgram || this.pgmDialogMode == PgmDialogMode.SaveProgramAs) { MsgBox.ShowWarning(SharedStrings.WARNING_CANNOT_SAVE_BLANK_PGM); } else { MsgBox.ShowWarning(SharedStrings.WARNING_CANNOT_OPEN_PROGRAM); } DialogResult = DialogResult.OK; } } else { if (string.IsNullOrEmpty(txtComment.Text)) { DialogResult = DialogResult.None; } else { if (this.pgmDialogMode == PgmDialogMode.SaveProgram || this.pgmDialogMode == PgmDialogMode.SaveProgramAs) { Epi.Analysis.FileBasedPgm.PgmSave(this.ProgramName.ToString(), txtComment.Text.ToString()); } } if (!isProjectBased) { DialogResult = DialogResult.OK; } else { DialogResult = DialogResult.None; } } }
void StatusDisplay() { if (null == lcd || displayUpdateTick > Pgm.totalTicks) { return; } displayUpdateTick = Pgm.totalTicks + TPS / 6; sb1.Append('\u2022', 7).Append($" Status Display ").Append('\u2022', 7).Append(DateTime.Now.ToString(" HH\\:mm\\:ss\\.fff")); if (!sc.ControlThrusters) { sb1.Append("\n") .Append(sc.MoveIndicator.ToString()).Append(Pgm.MoveIndicator2Command(sc.MoveIndicator)) .Append(sc.RollIndicator.ToString()); } sb1.Append($"\n Mode: {OperationMode} \u2022 State: {curState}"); sb1.Append("\n Alignment: ").Append((align.Active ? "Enabled" : "Off")).Append(" \u2022 AlignMode: ").Append(align.RocketMode ? "Rocket" : "Ship").Append(align.Inverted ? " (Inverted)" : ""); string alti = (double.IsNaN(altitudeSurface) ? "---" : $"{altitudeSurface:0.0}"); string altiDiff = ((double.IsNaN(altitudeDiff) || Math.Abs(altitudeDiff) < 1) ? "" : ((altitudeDiff > 0) ? " ^^^" : " vvv")); sb1.Append($"\n Altitude: {alti} m{altiDiff} \u2022 Gravity: {gravity:0.000} g"); sb1.Append($"\n Spd: {currSpeed:0.00} m/s \u2022 Acc.: {currAccl:0.00} \u2022 Atm.: {atmosphereDensity:0.0}"); if (Mode.Descend == mode) { sb1.Append($"\n BrakeDistance: {brakeDistance:0.00} \u2022 AlignDiff: {align.AlignDifference:0.000}"); sb1.Append($"\n Raycast: {raycastName}"); } sb1.Append($"\n Mass: {shipMass.PhysicalMass:#,##0} \u2022 Cargo: {shipMass.PhysicalMass - shipMass.BaseMass:#,##0}"); sb1.Append("\n Controller: ").Append(sc?.CustomName ?? "<NONE>"); sb1.Append($"\n Requested: ").Append(NumStr(totalThrustWanted, "N")).Append(" \u2022 Current: ").Append(NumStr(sumThrustCurEff, "N")); sb1.Append(sb2); if (0 < hydrogenTanks.Count) { if (hydroTanksUpdateTick < Pgm.totalTicks) { hydroTanksUpdateTick = Pgm.totalTicks + TPS / 3; hydroTanksPctFilled = 0; hydroTanksFillLevel = 0; hydroTanksGiving = 0; foreach (var h in hydrogenTanks) { if (h.IsWorking && !h.Stockpile) { hydroTanksFillLevel += h.Capacity * h.FilledRatio; hydroTanksPctFilled += h.FilledRatio; hydroTanksGiving++; } } hydroTanksPctFilled /= hydrogenTanks.Count; } AppendPctBar(sb1, $"\n Hydr:", -hydroTanksPctFilled, 30, false).Append($" {hydroTanksPctFilled * 100:0.0}% in {hydroTanksGiving} tanks"); } if (0 < batteries.Count) { if (batteriesUpdateTick < Pgm.totalTicks) { batteriesUpdateTick = Pgm.totalTicks + TPS; battStoredPower = 0; battMaxPower = 0; battNumCharging = 0; foreach (var b in batteries) { if (b.IsWorking) { battStoredPower += b.CurrentStoredPower; battMaxPower += b.MaxStoredPower; battNumCharging += b.IsCharging ? 1 : 0; } } battAllCharging = battNumCharging == batteries.Count; } AppendPctBar(sb1, "\n Batt:", (battStoredPower / battMaxPower) * (battAllCharging ? 1 : -1), 30, false); if (battAllCharging) { sb1.Append($" {chargeAnim[execCount & 3]} Recharging"); } } lcd.WritePublicText(sb1); }
public static void GetResults(Pgm picture, string name, BigPolyArray[] encArr, EncCal encCal, string location, string InputFileName, out byte[] decArr) { decArr = GetByteFromEnc(encArr, encCal, picture); picture.Save(location + "e_" + name + "_" + InputFileName, decArr); }
public virtual void Set(Clr val, Pgm pgm) { this.val = val; }