Example #1
0
        public SetCommand(
            PublicApis.Signal inSignal,
            PublicApis.VirtualPath inVirtualPath,
            PublicApis.SquareWave inSquareWave,
            PublicApis.SetVar inSetVar,
            string inPortOut,
            string inNext
            )
        {
            _NextState = inNext;
            _Signal    = inSignal;
            if (inVirtualPath != null)
            {
                _VirtualPath = new VirtualPath(inVirtualPath);
            }
            else
            {
                _VirtualPath = null;
            }
            _SquareWave = inSquareWave;
            _SetVar     = inSetVar;
            if (inSetVar != null)
            {
                _IsNumeric = _NumericRegex.IsMatch(_SetVar.Value);
                if (_IsNumeric)
                {
                    _Value = Convert.ToDecimal(_SetVar.Value);
                }
            }
            _PortOut = inPortOut;

            CheckSignalParam();
            // CheckVirtualPathParam(); VirtualPathクラスのコンストラクタで実施済み。
            // CheckSquareWave(); チェックするパラメータ無し。
        }
Example #2
0
            public VirtualPath(PublicApis.VirtualPath inVirtualPath)
            {
                var adToPwmRegex     = new Regex(_AdToPwmRegexPattern);
                var adToSpioutRegex  = new Regex(_AdToSpioutRegexPattern);
                var spioutToPwmRegex = new Regex(_SpioutToPwmRegexPattern);
                var adToPwmMatch     = adToPwmRegex.Match(inVirtualPath.Path);
                var adToSpioutMatch  = adToSpioutRegex.Match(inVirtualPath.Path);
                var spioutToPwmMatch = spioutToPwmRegex.Match(inVirtualPath.Path);

                Gain  = inVirtualPath.Gain;
                Delay = inVirtualPath.Delay;
                if (adToPwmMatch.Success)
                {
                    Type = PathType.AdToPwm;
                    if ((string)adToPwmMatch.Groups["SrcId"].Value == @"*")
                    {
                        SourceStartId = 0;
                        SourceEndId   = PublicConfig.AdChNum - 1;
                    }
                    else
                    {
                        var id = Convert.ToInt32(adToPwmMatch.Groups["SrcId"].Value);

                        if (id < PublicConfig.AdChNum)
                        {
                            SourceStartId = id;
                            SourceEndId   = id;
                        }
                        else
                        {
                            throw new Exception(
                                      "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                                      "Ad の設定範囲は、0 以上 " + PublicConfig.AdChNum.ToString() + " 未満。"
                                      );
                        }
                    }
                    if ((string)adToPwmMatch.Groups["DstId"].Value == @"*")
                    {
                        DstStartId = 0;
                        DstEndId   = PublicConfig.PwmChNum - 1;
                    }
                    else
                    {
                        var id = Convert.ToInt32(adToPwmMatch.Groups["DstId"].Value);

                        if (id < PublicConfig.PwmChNum)
                        {
                            DstStartId = id;
                            DstEndId   = id;
                        }
                        else
                        {
                            throw new Exception(
                                      "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                                      "Pwm の設定範囲は、0 以上 " + PublicConfig.PwmChNum.ToString() + " 未満。"
                                      );
                        }
                    }
                }
                else if (adToSpioutMatch.Success)
                {
                    Type = PathType.AdToSpiout;
                    if ((string)adToSpioutMatch.Groups["SrcId"].Value == @"*")
                    {
                        SourceStartId = 0;
                        SourceEndId   = PublicConfig.AdChNum - 1;
                    }
                    else
                    {
                        var id = Convert.ToInt32(adToSpioutMatch.Groups["SrcId"].Value);

                        if (id < PublicConfig.AdChNum)
                        {
                            SourceStartId = id;
                            SourceEndId   = id;
                        }
                        else
                        {
                            throw new Exception(
                                      "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                                      "Ad の設定範囲は、0 以上 " + PublicConfig.AdChNum.ToString() + " 未満。"
                                      );
                        }
                    }
                    if ((string)adToSpioutMatch.Groups["DstId"].Value == @"*")
                    {
                        DstStartId = 0;
                        DstEndId   = PublicConfig.SpioutChNum - 1;
                    }
                    else
                    {
                        var id = Convert.ToInt32(adToSpioutMatch.Groups["DstId"].Value);

                        if (id < PublicConfig.SpioutChNum)
                        {
                            DstStartId = id;
                            DstEndId   = id;
                        }
                        else
                        {
                            throw new Exception(
                                      "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                                      "Spiout の設定範囲は、0 以上 " + PublicConfig.SpioutChNum.ToString() + " 未満。"
                                      );
                        }
                    }
                }
                else if (spioutToPwmMatch.Success)
                {
                    Type = PathType.SpioutToPwm;
                    if ((string)spioutToPwmMatch.Groups["SrcId"].Value == @"*")
                    {
                        SourceStartId = 0;
                        SourceEndId   = PublicConfig.SpioutChNum - 1;
                    }
                    else
                    {
                        var id = Convert.ToInt32(spioutToPwmMatch.Groups["SrcId"].Value);

                        if (id < PublicConfig.SpioutChNum)
                        {
                            SourceStartId = id;
                            SourceEndId   = id;
                        }
                        else
                        {
                            throw new Exception(
                                      "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                                      "Spiout の設定範囲は、0 以上 " + PublicConfig.SpioutChNum.ToString() + " 未満。"
                                      );
                        }
                    }
                    if ((string)spioutToPwmMatch.Groups["DstId"].Value == @"*")
                    {
                        DstStartId = 0;
                        DstEndId   = PublicConfig.PwmChNum - 1;
                    }
                    else
                    {
                        var id = Convert.ToInt32(spioutToPwmMatch.Groups["DstId"].Value);

                        if (id < PublicConfig.PwmChNum)
                        {
                            DstStartId = id;
                            DstEndId   = id;
                        }
                        else
                        {
                            throw new Exception(
                                      "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                                      "Pwm の設定範囲は、0 以上 " + PublicConfig.PwmChNum.ToString() + " 未満。"
                                      );
                        }
                    }
                }
                else
                {
                    throw new Exception(
                              "Set コマンド内 VirtualPath 設定エラー⇒" + inVirtualPath.Path + "\n" +
                              "Ad0_Pwm0、Spiout*_Pwm2、Ad1_Spiout* というように記述する。"
                              );
                }
            }