private DataGenerator CreateGenerator(SimulatorItem item) { switch (item.Id) { case ItemId.SawtoothWave: case ItemId.SineWave: case ItemId.SquareWave: case ItemId.TriangleWave: case ItemId.WhiteNoise: { NumericScale scale = ((NumericTag)item).Scale; return(new WaveFormGenerator(GetWaveForm(item.Id), scale)); } case ItemId.IncrementalCount: { NumericScale scale = ((NumericTag)item).Scale; return(new CountGenerator(scale)); } case ItemId.ModulatedPulse: case ItemId.PeriodicPulse: return(new DiscreteGenerator(item.Id == ItemId.PeriodicPulse)); case ItemId.TimeText: return(new TextGenerator()); default: throw new InvalidOperationException("Invalid tag id."); } }
public override int GetHashCode() { int result = ProviderType != null?ProviderType.GetHashCode() : 0; result = 29 * result + (DataTypeName != null ? DataTypeName.GetHashCode() : 0); result = 29 * result + NumericPrecision.GetHashCode(); result = 29 * result + NumericScale.GetHashCode(); result = 29 * result + ColumnSize.GetHashCode(); result = 29 * result + IsLong.GetHashCode(); return(result); }
protected override object GetValueAtTime(DateTime time) { if (_periodic) { // Reference: https://en.wikipedia.org/wiki/Pulse_wave NumericScale scale = new NumericScale(-1, 1); var generator = new WaveFormGenerator(WaveForm.Sawtooth, scale); // use a 25% duty cycle (25% of 2 = 0.5) return(generator.GetValue(time, 20) >= 0.5f); } else { // Reference: https://en.wikipedia.org/wiki/Pulse-width_modulation NumericScale scale = new NumericScale(0, 100); var sawToothGenerator = new WaveFormGenerator(WaveForm.Sawtooth, scale); var sineGenerator = new WaveFormGenerator(WaveForm.Sine, scale); return(sawToothGenerator.GetValue(time) < sineGenerator.GetValue(time)); } }
public WaveFormGenerator(WaveForm waveForm, NumericScale scale) { _waveForm = waveForm; _scale = scale; }
/// <summary> /// Get datatype description /// </summary> /// <returns>datatype description</returns> public string GetDataTypeDescription() { return(SqlCreator.GetSQLServerDataType(DataType, ColumnSize.ToString(), NumericPrecision.ToString(), NumericScale.ToString())); }
public CountGenerator(NumericScale scale) { _scale = scale; }