private void ReadOption(GMDataReader reader, OptionsFlags flag) { if (reader.ReadWideBoolean()) { Options |= flag; } }
/// <summary> /// When the form is closed, set our Options flags based on which checkboxes were selected. /// The caller can then check the Options property against the flags to extract the items. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void OutputForm_FormClosed(object sender, FormClosedEventArgs e) { byte options = 0x00; byte flag = 0x01; for (int i = 0; i < chklstOptions.Items.Count; i++) { if (chklstOptions.GetItemChecked(i)) { options |= flag; } flag <<= 1; } _options = (OptionsFlags)options; // copy }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); Unknown = reader.ReadUInt64(); Options = (OptionsFlags)reader.ReadUInt64(); Scale = reader.ReadUInt32(); WindowColor = reader.ReadUInt32(); ColorDepth = reader.ReadUInt32(); Resolution = reader.ReadUInt32(); Frequency = reader.ReadUInt32(); VertexSync = reader.ReadUInt32(); Priority = reader.ReadUInt32(); SplashBackImage = reader.ReadPointerObject <GMTextureItem>(); SplashFrontImage = reader.ReadPointerObject <GMTextureItem>(); SplashLoadImage = reader.ReadPointerObject <GMTextureItem>(); LoadAlpha = reader.ReadUInt32(); Constants = new GMList <Constant>(); Constants.Unserialize(reader); }
private byte[] CalculateRawHash(object seed, DateTime timestamp, OptionsFlags instanceOptions) { if (!(seed is Seed)) throw new Exception("Unknown seed object"); Seed castSeed = (Seed)seed; List<byte> data = new List<byte>(); if ((instanceOptions & OptionsFlags.HashUserLogins) == OptionsFlags.HashUserLogins) data.AddRange(Encoding.ASCII.GetBytes(castSeed.userLogins)); if ((instanceOptions & OptionsFlags.HashItemId) == OptionsFlags.HashItemId) data.AddRange(castSeed.itemId.ToByteArray()); if ((instanceOptions & OptionsFlags.HashTimestamp) == OptionsFlags.HashTimestamp) data.AddRange(BitConverter.GetBytes(timestamp.Ticks)); MD5 md5 = MD5.Create(); return md5.ComputeHash(data.ToArray()); }
/// <summary> /// Gets the filename extension for each of the output file options available. /// </summary> /// <param name="oneOption">One option to get the extension for. Should NOT be a /// bitwise composite of options for this function.</param> /// <returns></returns> public string GetExtensionFor(OptionsFlags oneOption) { string ext = String.Empty; switch (oneOption) { case OptionsFlags.MainResults: ext = ".csv"; break; case OptionsFlags.OptimalAlignments: ext = ".align.txt"; break; case OptionsFlags.CharacterErrorTable: ext = ".table.csv"; break; case OptionsFlags.ConfusionMatrix: ext = ".matrix.csv"; break; case OptionsFlags.OptimalAlignmentsWithStreams: ext = ".salign.txt"; break; case OptionsFlags.CharacterErrorTableFromStreams: ext = ".stable.csv"; break; case OptionsFlags.ConfusionMatrixFromStreams: ext = ".smatrix.csv"; break; default: Debug.Fail("Invalid OptionsFlags parameter in OutputForm.GetExtensionFor."); break; } return(ext); }
public Measurement(String meterPacket) { packet = meterPacket; if (meterPacket.Length != 12) { throw (new ArgumentException("incorrect format input string should be 12 char long")); } //convert range char to number range = (int)char.GetNumericValue(meterPacket[0]); var displayDigits = meterPacket.Substring(1, 5); SwitchPosition = (SwitchPositions)meterPacket[6]; status = (StatusFlags)(0x0f & meterPacket[7]); //colate all option flags into one enum options = (OptionsFlags)(0x0f & meterPacket[8]); options |= (OptionsFlags)((0x0f & meterPacket[9]) << 4); options |= (OptionsFlags)((0x0f & meterPacket[11]) << 12); options |= (OptionsFlags)((0x0f & meterPacket[10]) << 8); var measInfo = new UT61EMeter.UnitScaling(SwitchPosition, range, status, options); units = measInfo.units; if (!decimal.TryParse(displayDigits, out value)) { nonNumvalue = displayDigits; value = 99999; } else { nonNumvalue = null; value *= measInfo.valueMuntiplyer; } }
public UnitScaling(SwitchPositions switchPosition, int range, StatusFlags status, OptionsFlags options) { //todo could add lots of data validation here to check settings match behavior but beyond the scope of intial version switch (switchPosition) { case SwitchPositions.V: if (options.HasFlag(OptionsFlags.VoltAmpHz)) { if (status.HasFlag(StatusFlags.dutyCycle)) { units = "% V"; //todo } else { units = "Hz V"; //todo } } else { if (range == 4) { units = "mV"; valueMuntiplyer = 0.01M; } else { units = "V"; valueMuntiplyer = 1 / (decimal)Math.Pow(10, 4 - range); } if (status.HasFlag(StatusFlags.negertive)) { valueMuntiplyer *= -1; } if (options.HasFlag(OptionsFlags.AC)) { units += " AC"; } } break; case SwitchPositions.Ohms: units = "Ohms"; break; case SwitchPositions.F: units = "F"; //todo break; case SwitchPositions.uA: if (options.HasFlag(OptionsFlags.VoltAmpHz)) { //todo if (status.HasFlag(StatusFlags.dutyCycle)) { units = "% uA"; //todo } else { units = "Hz uA"; //todo } } else { units = "uA"; valueMuntiplyer = 1 / (decimal)Math.Pow(10, 2 - range); if (status.HasFlag(StatusFlags.negertive)) { valueMuntiplyer *= -1; } if (options.HasFlag(OptionsFlags.AC)) { units += " AC"; } } break; case SwitchPositions.mA: if (options.HasFlag(OptionsFlags.VoltAmpHz)) { //todo if (status.HasFlag(StatusFlags.dutyCycle)) { units = "% mA"; //todo } else { units = "Hz mA"; //todo } } else { units = "mA"; valueMuntiplyer = 1 / (decimal)Math.Pow(10, 3 - range); if (status.HasFlag(StatusFlags.negertive)) { valueMuntiplyer *= -1; } if (options.HasFlag(OptionsFlags.AC)) { units += " AC"; } } break; case SwitchPositions.A: if (options.HasFlag(OptionsFlags.VoltAmpHz)) { if (status.HasFlag(StatusFlags.dutyCycle)) { units = "% A"; //todo } else { units = "Hz A"; //todo } } else { units = "A"; valueMuntiplyer = 0.001M; if (status.HasFlag(StatusFlags.negertive)) { valueMuntiplyer *= -1; } if (options.HasFlag(OptionsFlags.AC)) { units += " AC"; } } break; case SwitchPositions.BEEP: units = "BEEP"; //todo - future task not important break; case SwitchPositions.DIODE: units = "DIODE"; //todo - future task not important break; case SwitchPositions.HZdutycycle: if (status.HasFlag(StatusFlags.dutyCycle)) { units = "%"; //todo } else { units = "Hz"; //todo } //todo break; default: throw (new ArgumentException("switch positon given is invaid")); } }
private void WriteOption(GMDataWriter writer, OptionsFlags flag) { writer.WriteWideBoolean((Options & flag) == flag); }
public override void Unserialize(GMDataReader reader) { base.Unserialize(reader); reader.VersionInfo.OptionBitflag = (reader.ReadInt32() == int.MinValue); reader.Offset -= 4; if (reader.VersionInfo.OptionBitflag) { Unknown = reader.ReadUInt64(); Options = (OptionsFlags)reader.ReadUInt64(); Scale = reader.ReadInt32(); WindowColor = reader.ReadUInt32(); ColorDepth = reader.ReadUInt32(); Resolution = reader.ReadUInt32(); Frequency = reader.ReadUInt32(); VertexSync = reader.ReadUInt32(); Priority = reader.ReadUInt32(); SplashBackImage = reader.ReadPointerObject <GMTextureItem>(); SplashFrontImage = reader.ReadPointerObject <GMTextureItem>(); SplashLoadImage = reader.ReadPointerObject <GMTextureItem>(); LoadAlpha = reader.ReadUInt32(); } else { Options = 0; ReadOption(reader, OptionsFlags.FullScreen); ReadOption(reader, OptionsFlags.InterpolatePixels); ReadOption(reader, OptionsFlags.UseNewAudio); ReadOption(reader, OptionsFlags.NoBorder); ReadOption(reader, OptionsFlags.ShowCursor); Scale = reader.ReadInt32(); ReadOption(reader, OptionsFlags.Sizeable); ReadOption(reader, OptionsFlags.StayOnTop); WindowColor = reader.ReadUInt32(); ReadOption(reader, OptionsFlags.ChangeResolution); ColorDepth = reader.ReadUInt32(); Resolution = reader.ReadUInt32(); Frequency = reader.ReadUInt32(); ReadOption(reader, OptionsFlags.NoButtons); VertexSync = reader.ReadUInt32(); ReadOption(reader, OptionsFlags.ScreenKey); ReadOption(reader, OptionsFlags.HelpKey); ReadOption(reader, OptionsFlags.QuitKey); ReadOption(reader, OptionsFlags.SaveKey); ReadOption(reader, OptionsFlags.ScreenShotKey); ReadOption(reader, OptionsFlags.CloseSec); Priority = reader.ReadUInt32(); ReadOption(reader, OptionsFlags.Freeze); ReadOption(reader, OptionsFlags.ShowProgress); SplashBackImage = reader.ReadPointerObject <GMTextureItem>(); SplashFrontImage = reader.ReadPointerObject <GMTextureItem>(); SplashLoadImage = reader.ReadPointerObject <GMTextureItem>(); ReadOption(reader, OptionsFlags.LoadTransparent); LoadAlpha = reader.ReadUInt32(); ReadOption(reader, OptionsFlags.ScaleProgress); ReadOption(reader, OptionsFlags.DisplayErrors); ReadOption(reader, OptionsFlags.WriteErrors); ReadOption(reader, OptionsFlags.AbortErrors); ReadOption(reader, OptionsFlags.VariableErrors); ReadOption(reader, OptionsFlags.CreationEventOrder); } Constants = new GMList <Constant>(); Constants.Unserialize(reader); }