private void ExecSignalSetting(ControllerState ioState) { if (_Signal != null) { switch (_Signal.GetType().Name) { case "PwmSineWave": { PublicApis.PwmSineWave signal = (PublicApis.PwmSineWave)_Signal; int idx = PublicConfig.SignalBaseNum * signal.Ch + signal.Id; ioState.PwmSineHz[idx] = signal.Freq; ioState.PwmSineGain[idx] = signal.Gain; ioState.PwmSinePhase[idx] = signal.Phase; } break; case "PwmWhiteNoise": { PublicApis.PwmWhiteNoise signal = (PublicApis.PwmWhiteNoise)_Signal; int idx = signal.Ch; ioState.PwmWhiteNoiseGain[idx] = signal.Gain; } break; case "SpioutSineWave": { PublicApis.SpioutSineWave signal = (PublicApis.SpioutSineWave)_Signal; int idx = PublicConfig.SignalBaseNum * signal.Ch + signal.Id; ioState.SpioutSineHz[idx] = signal.Freq; ioState.SpioutSineGain[idx] = signal.Gain; ioState.SpioutSinePhase[idx] = signal.Phase; } break; case "SpioutWhiteNoise": { PublicApis.SpioutWhiteNoise signal = (PublicApis.SpioutWhiteNoise)_Signal; int idx = signal.Ch; ioState.SpioutWhiteNoiseGain[idx] = signal.Gain; } break; default: break; } } }
private void CheckSignalParam() { if (_Signal != null) { switch (_Signal.GetType().Name) { case "PwmSineWave": { if (_Signal.Ch >= PublicConfig.PwmChNum) { throw new Exception( "Set コマンド内 Signal.Ch 設定エラー⇒" + _Signal.Ch + "\n" + "Ch 設定値範囲は 0 以上 " + PublicConfig.PwmChNum + " 未満。" ); } PublicApis.PwmSineWave signal = (PublicApis.PwmSineWave)_Signal; if (signal.Id >= PublicConfig.SignalBaseNum) { throw new Exception( "Set コマンド内 Signal.Id 設定エラー⇒" + signal.Id + "\n" + "Id 設定値範囲は 0 以上 " + PublicConfig.SignalBaseNum + " 未満。" ); } } break; case "PwmWhiteNoise": if (_Signal.Ch >= PublicConfig.PwmChNum) { throw new Exception( "Set コマンド内 Signal.Ch 設定エラー⇒" + _Signal.Ch + "\n" + "Ch 設定値範囲は 0 以上 " + PublicConfig.PwmChNum + " 未満。" ); } break; case "SpioutSineWave": { if (_Signal.Ch >= PublicConfig.SpioutChNum) { throw new Exception( "Set コマンド内 Signal.Ch 設定エラー⇒" + _Signal.Ch + "\n" + "Ch 設定値範囲は 0 以上 " + PublicConfig.SpioutChNum + " 未満。" ); } PublicApis.SpioutSineWave signal = (PublicApis.SpioutSineWave)_Signal; if (signal.Id >= PublicConfig.SignalBaseNum) { throw new Exception( "Set コマンド内 Signal.Id 設定エラー⇒" + signal.Id + "\n" + "Id 設定値範囲は 0 以上 " + PublicConfig.SignalBaseNum + " 未満。" ); } } break; case "SpioutWhiteNoise": if (_Signal.Ch >= PublicConfig.SpioutChNum) { throw new Exception( "Set コマンド内 Signal.Ch 設定エラー⇒" + _Signal.Ch + "\n" + "Ch 設定値範囲は 0 以上 " + PublicConfig.SpioutChNum + " 未満。" ); } break; default: throw new Exception( "不明な信号タイプ⇒" + _Signal.GetType().Name + "\n" + "使用可能なクラスは、PwmSineWave/PwmWhiteNoise/SpioutSineWave/SpioutWhiteNoise。" ); } } }