/// <summary> /// Will blend two noise source together with a LERP alpha from the controlerRange /// </summary> /// <param name="lowSource">lowSource, MUST be a double or a INoise fct, otherwhile it will raised an error at run time !</param> /// <param name="highSource">HighSource, MUST be a double or a INoise fct, otherwhile it will raised an error at run time !</param> /// <param name="controler">LERP alpha value source, MUST be a double or a INoise fct, otherwhile it will raised an error at run time !</param> /// <param name="controlerRange">The range of the Alpha controler value</param> public Blend(object lowSource, object highSource, object controler, RangeD controlerRange) { _lowSource = new NoiseParam(lowSource); _highSource = new NoiseParam(highSource); _controler = new NoiseParam(controler); _controlerRange = controlerRange; }
public Select(object lowSource, object highSource, object control, object threshold, object falloff) { _lowSource = new NoiseParam(lowSource); _highSource = new NoiseParam(highSource); _control = new NoiseParam(control); _threshold = new NoiseParam(threshold); _falloff = new NoiseParam(falloff); }
public Turbulence(object source, object xOffset, object yOffset, object zOffset, object wOffset) { _source = new NoiseParam(source); _xOffset = new NoiseParam(xOffset); _yOffset = new NoiseParam(yOffset); _zOffset = new NoiseParam(zOffset); _wOffset = new NoiseParam(wOffset); }
public Lerp(object source, double targetFrom, double targetTo, double sourceFrom, double sourceTo) { _source = new NoiseParam(source); _targetMin = targetFrom; _targetMax = targetTo; _sourceMin = sourceFrom; _sourceMax = sourceTo; }
public ScaleDomain(object source, object XScale, object YScale, object ZScale, object WScale) { _source = new NoiseParam(source); _xScale = new NoiseParam(XScale); _yScale = new NoiseParam(YScale); _zScale = new NoiseParam(ZScale); _wScale = new NoiseParam(WScale); }
public ScaleOffset(object source, object scale, object offset) { _source = new NoiseParam(source); _scale = new NoiseParam(scale); _offset = new NoiseParam(offset); }
/// <summary> /// 返回记录数据 /// </summary> /// <param name="lstDataDomain">数据域数组</param> /// <returns></returns> //public object GetDataValue(List<byte> lstDataDomain) public object GetDataValue(List <byte> lstReciveByte) { //如果返回不是正常应答帧 返回空 //if (!serialPortHelper.IsNormalFrame) //{ // return null; //} //lstClone.AddRange(lstDataDomain); //isNormalFrame = false; returnType = 0; lstDataDomain.Clear(); lstRead.Clear(); int revLength = lstReciveByte.Count; if (revLength >= 8) { if (lstReciveByte[0] == 0x10 && lstReciveByte[1] == 0xFF && lstReciveByte[2] == 0xFE) //识别帧 { int dataLength = lstReciveByte[4] * 256 + lstReciveByte[3]; int frameLen = dataLength + 5; if (revLength >= frameLen) { List <byte> checkList = lstReciveByte.GetRange(3, dataLength); byte[] bytCheck = GetDataCheck(checkList); if (bytCheck[1] == lstReciveByte[frameLen - 1] && bytCheck[0] == lstReciveByte[frameLen - 2]) //校验和 { lstRead.AddRange(lstReciveByte.GetRange(0, frameLen)); lstDataDomain.AddRange(lstReciveByte.GetRange(5, dataLength - 2)); returnType = lstDataDomain[0]; isNormalFrame = true; Application.DoEvents(); //System.Threading.Thread.Sleep(50); //lstReciveByte.Clear(); } //else //{ // byte a = lstReciveByte[frameLen - 1]; // byte b = lstReciveByte[frameLen - 2]; // isNormalFrame = true; // returnType = 0x20; // lstDataDomain.AddRange(lstReciveByte.GetRange(5, dataLength - 2)); // lstRead.AddRange(lstReciveByte.GetRange(0, frameLen)); //} lstReciveByte.RemoveRange(0, frameLen); } } } if (!isNormalFrame) { return(null); } //创建一个新集合 克隆数据域数据 List <byte> lstClone = new List <byte>(); lstClone.AddRange(lstDataDomain); object obj = null; if (lstClone.Count > 1) { switch (lstClone[0]) { case 0x01: //设置单板时间 case 0x04: //系统参数设置 case 0x06: //设置CH1参数 case 0x08: //设置CH2参数 case 0x0A: //设置CH3参数 case 0x0C: //保存参数 case 0x11: //关闭信号强度显示 case 0x14: //退出上传通道信号 case 0x15: //设置调试相位 case 0x60: case 0x61: case 0x62: case 0x63: case 0x64: case 0x65: case 0x0D: if (lstClone[1] == 0) { obj = "操作成功"; // MessageBox.Show("操作成功"); } else if (lstClone[1] == 1) { obj = "参数错误"; //MessageBox.Show("参数错误"); } else { obj = "无效"; //MessageBox.Show("无效"); } break; case 0x68: if (lstClone.Count == 5) { CheckCode checkCode = new CheckCode(); checkCode.Data1 = lstClone[1]; checkCode.Data2 = lstClone[2]; checkCode.Data3 = lstClone[3]; checkCode.Data4 = lstClone[4]; obj = checkCode; } break; case 0x6E: if (lstClone.Count == 2) { RandomModel randomModel = new RandomModel(); randomModel.ModelType = lstClone[1]; obj = randomModel; } break; case 0x69: if (lstClone.Count == 2) { MiduParam param = new MiduParam(); param.Data = lstClone[1]; obj = param; } break; case 0x6A: if (lstClone.Count == 2) { TongbuParam param = new TongbuParam(); param.Data = lstClone[1]; obj = param; } break; case 0x6B: if (lstClone.Count == 2) { NoiseParam param = new NoiseParam(); param.Data = lstClone[1]; obj = param; } break; case 0x6C: if (lstClone.Count == 2) { XinhaoParam param = new XinhaoParam(); param.Data = lstClone[1]; obj = param; } break; case 0x6D: if (lstClone.Count == 2) { InterverParam param = new InterverParam(); param.Data = lstClone[1]; obj = param; } break; case 0x0E: if (lstClone.Count == 2) { GongpinParam param = new GongpinParam(); param.Data = lstClone[1]; obj = param; } break; case 0x02: //查询单板时间 if (lstClone.Count == 8) { SystemDT systemDT = new SystemDT(); systemDT.Year = lstClone[2] * 256 + lstClone[1]; systemDT.Month = lstClone[3]; systemDT.Day = lstClone[4]; systemDT.Hour = lstClone[5]; systemDT.Minute = lstClone[6]; systemDT.Second = lstClone[7]; obj = systemDT; } break; case 0x03: //查询单板版本信息 if (lstClone.Count == 12) { VersionInfo versionInfo = new VersionInfo(); versionInfo.SoftVersion = lstClone[1] + "." + lstClone[2] + "." + lstClone[3] + "." + lstClone[4]; versionInfo.CompileDT = new SystemDT(); versionInfo.CompileDT.Year = lstClone[6] * 256 + lstClone[5]; versionInfo.CompileDT.Month = lstClone[7]; versionInfo.CompileDT.Day = lstClone[8]; versionInfo.CompileDT.Hour = lstClone[9]; versionInfo.CompileDT.Minute = lstClone[10]; versionInfo.CompileDT.Second = lstClone[11]; obj = versionInfo; } break; case 0x05: //查询系统参数 if (lstClone.Count == 14) { SystemParam systemParam = new SystemParam(); //byte[] phase = lstClone.GetRange(1, 4).ToArray(); //phase = phase.Reverse().ToArray(); systemParam.Phase = lstClone[2] * 256 + lstClone[1]; systemParam.Frequency = lstClone[3]; systemParam.SendInterval = lstClone[4]; systemParam.SendStrength = lstClone[5]; systemParam.RevDelay = lstClone[6]; systemParam.ChannelMode = lstClone[7]; systemParam.InterferenceDetection = lstClone[8]; systemParam.SignDetection = lstClone[9]; systemParam.DecodingFilterA = lstClone[10]; systemParam.DecodingFilterB = lstClone[11]; systemParam.DecodingFilterC = lstClone[12]; systemParam.DecodingFilterD = lstClone[13]; obj = systemParam; } break; case 0x07: //查询CH1参数 case 0x09: //查询CH2参数 case 0x0B: //查询CH3参数 if (lstClone.Count == 5) { ChannelParam channelParam = new ChannelParam(); channelParam.AlarmThreshold = lstClone[1]; //channelParam.Sign1 = lstClone[2] & 0x01; //channelParam.Sign2 = (lstClone[2] >> 1) & 0x01; //channelParam.Sign3 = (lstClone[2] >> 2) & 0x01; channelParam.TX = lstClone[2] & 0x01; channelParam.RX = (lstClone[2] >> 1) & 0x01; channelParam.Buzzer = lstClone[3]; channelParam.ChannelGain = lstClone[4]; obj = channelParam; } break; case 0x10: //显示通道信号强度 if (lstClone.Count == 7) { ChannelSignStrength channelSignStrength = new ChannelSignStrength(); channelSignStrength.Ch1Noise = lstClone[1]; channelSignStrength.Ch1Sign = lstClone[2]; channelSignStrength.Ch2Noise = lstClone[3]; channelSignStrength.Ch2Sign = lstClone[4]; channelSignStrength.Ch3Noise = lstClone[5]; channelSignStrength.Ch3Sign = lstClone[6]; obj = channelSignStrength; } break; case 0x12: //检测周围相位 if (lstClone.Count == 33) { List <string> phaseList = new List <string>(); for (int i = 0; i < 16; i++) { int temp = lstClone[i * 2 + 2] * 256 + lstClone[i * 2 + 1]; if (temp == 65535) { phaseList.Add("无"); } else { double fTemp = temp * 0.1; phaseList.Add(fTemp.ToString("0.0")); } } obj = phaseList; } break; case 0x13: //上传通道信号 //if (lstClone.Count == 601) { int number = (lstClone.Count - 1) / 2; UploadChannelSign ucs = new UploadChannelSign(); ucs.Bit15List = new List <int>(); ucs.Bit0_14List = new List <int>(); for (int i = 0; i < number; i++) { if ((lstClone[i * 2 + 2] >> 7) == 1) { ucs.Bit15List.Add(1600); } else { ucs.Bit15List.Add(0); } // ucs.Bit15List.Add((lstClone[i * 2 + 2] >> 15) & 0x80); ucs.Bit0_14List.Add((lstClone[i * 2 + 2] & 0x7F) * 256 + lstClone[i * 2 + 1]); } obj = ucs; } break; case 0x20: //上传单板报警记录 List <AlarmRecord> arList = new List <AlarmRecord>(); int count = (lstClone.Count - 1) / 16; for (int i = 0; i < count; i++) { AlarmRecord ar = new AlarmRecord(); ar.index = i + 1; ar.Number = lstClone[i * 16 + 1]; ar.Code = lstClone[i * 16 + 2]; ar.RecordDT = new SystemDT(); ar.RecordDT.Year = 2000 + lstClone[i * 16 + 3]; ar.RecordDT.Month = lstClone[i * 16 + 4]; ar.RecordDT.Day = lstClone[i * 16 + 5]; ar.RecordDT.Hour = lstClone[i * 16 + 6]; ar.RecordDT.Minute = lstClone[i * 16 + 7]; ar.RecordDT.Second = lstClone[i * 16 + 8]; StringBuilder sb = new StringBuilder(); for (int j = 9; j <= 16; j++) { if (sb.Length > 0) { sb.Append(" "); } sb.Append(lstClone[i * 16 + j].ToString("X2")); } ar.Data = sb.ToString(); arList.Add(ar); } obj = arList; break; } } return(obj); }
/// <summary> /// Will "biases" the function toward one end of the noise range or the other. /// </summary> /// <param name="source">Noise source, prefered to be in 0 to 1 range</param> /// <param name="bias">Bias value, below 0.5 to push toward the end of the noise range, and above 0.5 to push toward the beggining of the noise range</param> public Bias(INoise source, INoise bias) { _source = source; _bias = new NoiseParam(bias); }
/// <summary> /// Has the effect of pushing the values of the input either toward the ends and away from the middle (if bias is >0.5) or pushing values toward the middle and away from the ends (if bias is < 0.5) /// </summary> /// <param name="source">Noise source, prefered to be in 0 to 1 range</param> /// <param name="gain">Bias value, below 0.5 to push toward the end of the noise range, and above 0.5 to push toward the beggining of the noise range</param> public Gain(INoise source, INoise gain) { _source = source; _gain = new NoiseParam(gain); }
public Pow(object source, object power) { _source = new NoiseParam(source); _power = new NoiseParam(power); }