public override object Clone() { Value_Standard ret = new Value_Standard(); ret.bCheckValue = this.bCheckValue; ret.FilePath = this.FilePath; ret.IsUpdated = this.IsUpdated; ret.TypeOfClass = this.TypeOfClass; ret.Value = this.Value; return ret; }
/// <summary> /// モード2データのセット /// </summary> /// <param name="reserveData"></param> /// <param name="sampleData"></param> private void SetMode2Data(Mode2Record reserveData, ref SampleData sampleData) { if (((Mode2Header)reserveData.HeaderData).Time.Hour == 23 && DateTime.Now.Hour == 0) sampleData.SampleTime = DateTime.Today.AddDays(-1).AddTicks(((Mode2Header)reserveData.HeaderData).Time.Ticks); else sampleData.SampleTime = DateTime.Today.AddTicks(((Mode2Header)reserveData.HeaderData).Time.Ticks); sampleData.ChannelDatas = new ChannelData[11]; Value_Standard valuedata = new Value_Standard(); Value_Mode2 value2data = new Value_Mode2(); List<List<decimal>> tempValueList = new List<List<decimal>>(); int channelCount = 0; int tmpIndex = 0; //有効チャンネル数取得 for (int i = 0; i < channelEnables.Length; i++) { if (channelEnables[i]) channelCount++; } //モード2データの空データを作成 for (int i = 0; i < reserveData.MeasData.chData.Length; i += channelCount) { for (int j = 0; j < channelCount; j++) { if (tempValueList.Count <= j) tempValueList.Add(new List<decimal>()); tempValueList[j].Add(((Mode2Record)reserveData).MeasData.chData[i + j]); } } //チャンネル分+回転数分ループ for (int channelIndex = 0; channelIndex < channelEnables.Length + 1; channelIndex++) { //回転数の場合 if (channelIndex == 0) { valuedata.Value = ((Mode2Header)reserveData.HeaderData).RevolutionSpeed; sampleData.ChannelDatas[channelIndex] = new ChannelData(); sampleData.ChannelDatas[channelIndex].DataValues = valuedata; } else { if (!ChannelEnables[channelIndex - 1]) continue; sampleData.ChannelDatas[channelIndex] = new ChannelData(); sampleData.ChannelDatas[channelIndex].Position = channelIndex; value2data = new Value_Mode2(); //最大振幅 ブロック1 decimal MaxValue = tempValueList[tmpIndex][0]; //温度データ ブロック2 int TempValue = (int)(tempValueList[tmpIndex][1] == 0xFFFF ? -1 : tempValueList[tmpIndex][1]); //サンプルデータ ブロック3以降 value2data.Values = tempValueList[tmpIndex].GetRange(2, tempValueList[tmpIndex].Count - 2).ToArray(); tmpIndex++; //センサ種により処理分け switch (channelsSetting.ChannelSettingList[channelIndex - 1].ChKind) { case ChannelKindType.B: case ChannelKindType.R: //B,Rセンサは温度と最大振幅ありで補償処理 for (int valueIndex = 0; valueIndex < value2data.Values.Length; valueIndex++) { value2data.Values[valueIndex] = CalcOperator.Calc(channelIndex-1, value2data.Values[valueIndex], MaxValue, TempValue); } //温度補償必要 //ブロック1 == 最大振幅 //ブロック2 == 温度データ //value2data.Values == AD値配列 break; default: //その他は演算 for (int valueIndex = 0; valueIndex < value2data.Values.Length; valueIndex++) { value2data.Values[valueIndex] = CalcOperator.Calc(channelIndex - 1, value2data.Values[valueIndex]); } break; } sampleData.ChannelDatas[channelIndex].DataValues = value2data; } } }
/// <summary> /// モード3データのセット /// </summary> /// <param name="reserveData"></param> /// <param name="sampleData"></param> private void SetMode3Data(Mode3Record reserveData, ref SampleData sampleData) { sampleData.SampleTime = DateTime.Now; sampleData.ChannelDatas = new ChannelData[11]; Value_Standard valuedata = null; //データ取得用オフセット int dataoffset = 0; //チャンネル分+回転数分ループ for (int channelIndex = 0; channelIndex < channelEnables.Length + 1; channelIndex++) { if (channelIndex != 0 && !ChannelEnables[channelIndex - 1]) continue; sampleData.ChannelDatas[channelIndex] = new ChannelData(); sampleData.ChannelDatas[channelIndex].Position = channelIndex; //回転数の場合 if (channelIndex == 0) { } else { //モード3データを生成 //センサ種により処理分け switch (channelsSetting.ChannelSettingList[channelIndex - 1].ChKind) { case ChannelKindType.B: valuedata = new Value_Standard(); //補償演算 valuedata.Value = CalcOperator.Calc(channelIndex - 1 , reserveData.MeasData.chData[dataoffset + 2] , reserveData.MeasData.chData[dataoffset] , (reserveData.MeasData.chData[dataoffset + 1] == 0xFFFF ? -1 : reserveData.MeasData.chData[dataoffset + 1])); //valuedata.Value = SystemSetting.CalibrationTables[channelIndex - 1].Calc( // reserveData.MeasData.chData[dataoffset + 2] // , reserveData.MeasData.chData[dataoffset] // , reserveData.MeasData.chData[dataoffset + 1]); //温度補償必要 //chData[dataoffset] == 最大振幅 //chData[dataoffset + 1] == 温度データ //chData[dataoffset + 2] == AD値 //臨時 //valuedata.Value = reserveData.MeasData.chData[dataoffset + 2]; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; break; case ChannelKindType.R: valuedata = new Value_Standard(); //補償演算 valuedata.Value = CalcOperator.Calc(channelIndex - 1 , reserveData.MeasData.chData[dataoffset + 1] , tempValue:(reserveData.MeasData.chData[dataoffset] == 0xFFFF ? -1 : reserveData.MeasData.chData[dataoffset])); ////温度補償 //valuedata.Value = SystemSetting.CalibrationTables[channelIndex - 1].Calc( // reserveData.MeasData.chData[dataoffset + 1] // , -1 // , reserveData.MeasData.chData[dataoffset]); //温度補償必要 //chData[dataoffset] == 温度データ //chData[dataoffset + 1] == AD値 //臨時 //valuedata.Value = reserveData.MeasData.chData[dataoffset + 1]; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; break; default: //B,Rセンサ以外は1つ目がデータ valuedata = new Value_Standard(); //LセンサでChannelの0要求があった場合 if (channelsSetting.ChannelSettingList[channelIndex - 1].ChKind == ChannelKindType.L && channelIndex == L_ZeroSettingRequestNo) { SystemSetting.DataTagSetting.GetTag(SystemSetting.RelationSetting.RelationList[channelIndex].TagNo_1).StaticZero = reserveData.MeasData.chData[dataoffset]; L_ZeroSettingRequestNo = 0; } //補償演算 valuedata.Value = CalcOperator.Calc(channelIndex - 1, reserveData.MeasData.chData[dataoffset]); //valuedata.Value = reserveData.MeasData.chData[dataoffset]; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; break; } //次チャンネルのデータに移動 dataoffset += 3; } } }
/// <summary> /// モード1データのセット /// </summary> /// <param name="reserveData"></param> /// <param name="sampleData"></param> private void SetMode1Data(Mode1Record reserveData, ref SampleData sampleData) { if(((Mode1Header)reserveData.HeaderData).Time.Hour == 23 && DateTime.Now.Hour == 0) sampleData.SampleTime = DateTime.Today.AddDays(-1).AddTicks(((Mode1Header)reserveData.HeaderData).Time.Ticks); else sampleData.SampleTime = DateTime.Today.AddTicks(((Mode1Header)reserveData.HeaderData).Time.Ticks); sampleData.ChannelDatas = new ChannelData[11]; Value_Standard valuedata = null; Value_MaxMin valueMaxMin = null; //データ取得用オフセット int dataoffset = 0; //チャンネル分+回転数分ループ for (int channelIndex = 0; channelIndex < channelEnables.Length + 1 ; channelIndex++) { if (channelIndex != 0 && !ChannelEnables[channelIndex - 1]) continue; sampleData.ChannelDatas[channelIndex] = new ChannelData(); sampleData.ChannelDatas[channelIndex].Position = channelIndex; //回転数の場合 if (channelIndex == 0) { valuedata = new Value_Standard(); valuedata.Value = ((Mode1Header)reserveData.HeaderData).RevolutionSpeed; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; } else { //モード1データを生成 //センサ種により処理分け switch (channelsSetting.ChannelSettingList[channelIndex - 1].ChKind) { case ChannelKindType.B: valuedata = new Value_Standard(); //温度補償 valuedata.Value = CalcOperator.Calc(channelIndex - 1, reserveData.MeasData.chData[dataoffset + 2], reserveData.MeasData.chData[dataoffset], (reserveData.MeasData.chData[dataoffset + 1] == 0xFFFF ? -1 : reserveData.MeasData.chData[dataoffset + 1])); //valuedata.Value = SystemSetting.CalibrationTables[channelIndex - 1].Calc( // reserveData.MeasData.chData[dataoffset + 2] // , reserveData.MeasData.chData[dataoffset] // , reserveData.MeasData.chData[dataoffset + 1]); //chData[dataoffset + 2] == AD値 //chData[dataoffset] == 最大振幅 //chData[dataoffset + 1] == 温度データ ////臨時 //valuedata.Value = reserveData.MeasData.chData[dataoffset + 2]; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; break; case ChannelKindType.R: //最終データが無効値ならば通常データ if (reserveData.MeasData.chData[dataoffset + 2] == 0xFFFF) { valuedata = new Value_Standard(); //温度補償 valuedata.Value = CalcOperator.Calc(channelIndex - 1 , reserveData.MeasData.chData[dataoffset + 1] , tempValue:(reserveData.MeasData.chData[dataoffset] == 0xFFFF ? -1 : reserveData.MeasData.chData[dataoffset])); //valuedata.Value = SystemSetting.CalibrationTables[channelIndex - 1].Calc( // reserveData.MeasData.chData[dataoffset + 1] // , -1 // , reserveData.MeasData.chData[dataoffset]); //温度補償必要 //chData[dataoffset] == 温度データ //chData[dataoffset + 1] == AD値 //臨時 //valuedata.Value = reserveData.MeasData.chData[dataoffset + 1]; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; } else { valueMaxMin = new Value_MaxMin(); //最大値温度補償 valueMaxMin.MaxValue = CalcOperator.Calc(channelIndex - 1 , reserveData.MeasData.chData[dataoffset + 1] , tempValue:(reserveData.MeasData.chData[dataoffset] == 0xFFFF ? -1 : reserveData.MeasData.chData[dataoffset])); //valueMaxMin.MaxValue = SystemSetting.CalibrationTables[channelIndex - 1].Calc( // reserveData.MeasData.chData[dataoffset + 1] // , -1 // , reserveData.MeasData.chData[dataoffset]); //最小値温度補償 valueMaxMin.MinValue = CalcOperator.Calc(channelIndex - 1 , reserveData.MeasData.chData[dataoffset + 2] , tempValue:(reserveData.MeasData.chData[dataoffset] == 0xFFFF ? -1 : reserveData.MeasData.chData[dataoffset])); //valueMaxMin.MinValue = SystemSetting.CalibrationTables[channelIndex - 1].Calc( // reserveData.MeasData.chData[dataoffset + 2] // , -1 // , reserveData.MeasData.chData[dataoffset]); //温度補償必要 //chData[dataoffset] == 温度データ //chData[dataoffset + 1] == MAX AD値 //chData[dataoffset + 2] == MIN AD値 //臨時 //valueMaxMin.MaxValue = reserveData.MeasData.chData[dataoffset + 1]; //valueMaxMin.MinValue = reserveData.MeasData.chData[dataoffset + 2]; sampleData.ChannelDatas[channelIndex].DataValues = valueMaxMin; } break; default: //B,Rセンサ以外は1つ目がデータ valuedata = new Value_Standard(); //補償演算 valuedata.Value = CalcOperator.Calc(channelIndex - 1, reserveData.MeasData.chData[dataoffset]); //valuedata.Value = reserveData.MeasData.chData[dataoffset]; sampleData.ChannelDatas[channelIndex].DataValues = valuedata; break; } dataoffset += 3; } } }
/// <summary> /// 実演算 /// </summary> /// <param name="sampleDatas"></param> /// <returns>与えられたSampleDataを用いて演算する</returns> public List<CalcData> GetCalcDatas(List<SampleData> sampleDatas) { List<CalcData> ret = new List<CalcData>(); if (calcinitFlag == false || calc == null || sampleDatas == null) { return ret; } int icount = 0; //if (sampleDatas == null) //{ // sampleDatas = new SampleDataManager(); // if (sampleDatas == null) // { // return bRet; // } // sampleDatas.FolderPath = this.CurFilePath; // //1万件分読み込んでおく // sampleDatas.DeserializeData(0, 10000); //} //int start = 0; int Calcstart = 0; List<TagData> tmpTagDatas = null; icount = sampleDatas.Count; try { for (int i = 0; i < icount; i++) { //SampleData x = (SampleData)sampleDatas.GetRange(start, 1)[0]; SampleData x = sampleDatas[i]; //演算データリスト ret.Add(new CalcData()); switch ((ModeType)measureSetting.Mode) { case ModeType.MODE1: case ModeType.MODE3: //モード1・3の場合。 //ショット毎に1データの為、単純ループ #region Mode1/3 //タグリストに埋め込み for (int j = 0; j < x.ChannelDatas.Length; j++) { ChannelData chdata = x.ChannelDatas[j]; if (chdata == null) continue; int tagNo1 = tagChannelRelationSetting.RelationList[chdata.Position].TagNo_1; int tagNo2 = tagChannelRelationSetting.RelationList[chdata.Position].TagNo_2; if (chdata.DataValues == null) continue; if (chdata.DataValues.GetType() == typeof(Value_Standard)) { if(tagNo1 != -1) valVariable[tagNo1 - 1] = (double)((Value_Standard)chdata.DataValues).Value; } else if (chdata.DataValues.GetType() == typeof(Value_MaxMin)) { if (tagNo1 != -1) valVariable[tagNo1 - 1] = (double)((Value_MaxMin)chdata.DataValues).MinValue; if (tagNo2 != -1) valVariable[tagNo2 - 1] = (double)((Value_MaxMin)chdata.DataValues).MaxValue; } } //演算実行 if (calc.Execute(ref strErrorMessage) < 0) { //error MessageBox.Show( CalcCommon.Calc.GetErrString(strErrorMessage) + "\n" , CommonResource.GetString("TITLE_CALC_OPERATE") , MessageBoxButtons.OKCancel , MessageBoxIcon.Information); } //演算結果埋め込み Calcstart = 0; tmpTagDatas = new List<TagData>(); for (int j = 0; j < iCalcIndex.Length; j++) { if (iCalcIndex[j] > 0) { Value_Standard val = new Value_Standard(false); val.Value = (decimal)valCalcResult[Calcstart]; tmpTagDatas.Add(new TagData() { DataValues = val, TagNo = iCalcIndex[j] + 1 }); //int idx = iCalcIndex[j]; //if (x.ChannelDatas[idx].DataValues.GetType() == typeof(Value_Standard)) //{ // ((Value_Standard)x.ChannelDatas[idx].DataValues).Value = (decimal)valCalcResult[Calcstart]; //} //else if (x.ChannelDatas[idx].DataValues.GetType() == typeof(Value_MaxMin)) //{ // ((Value_MaxMin)x.ChannelDatas[idx].DataValues).MinValue = (decimal)valCalcResult[Calcstart]; //} Calcstart++; } } //リターン値に格納 ret[i].TagDatas = tmpTagDatas.ToArray(); //start++; #endregion break; case ModeType.MODE2: #region Mode2 List<Value_Mode2> val_mode2List = new List<Value_Mode2>(); Value_Mode2 val_mode2 = new Value_Mode2(); //一時演算格納領域の初期化 tmpTagDatas = new List<TagData>(); //ショップ内サンプル数取得 int samplesCountofShot = 0; foreach(ChannelData ch_data in x.ChannelDatas) { if(ch_data != null && ch_data.Position != 0 && ch_data.DataValues !=null) { samplesCountofShot = ((Value_Mode2)ch_data.DataValues).Values.Length; break; } } //ショット内のサンプルごとにループ for (int sampleindex = 0; sampleindex < samplesCountofShot; sampleindex++) { //チャンネルループ //タグリストに埋め込み for (int j = 0; j < x.ChannelDatas.Length; j++) { ChannelData chdata = x.ChannelDatas[j]; if (chdata == null) continue; int tagNo1 = tagChannelRelationSetting.RelationList[chdata.Position].TagNo_1; if (chdata.DataValues == null) continue; //回転数の場合は値1つだが、ショット内はすべて反映する。 if (chdata.Position == 0) { if (tagNo1 != -1) valVariable[tagNo1 - 1] = (double)((Value_Standard)chdata.DataValues).Value; } //それ以外は対象サンプルの値を取得。 else { if (tagNo1 != -1) valVariable[tagNo1 - 1] = (double)((Value_Mode2)chdata.DataValues).Values[sampleindex]; } } //演算実行 if (calc.Execute(ref strErrorMessage) < 0) { //error MessageBox.Show( CalcCommon.Calc.GetErrString(strErrorMessage) + "\n" , CommonResource.GetString("TITLE_CALC_OPERATE") , MessageBoxButtons.OKCancel , MessageBoxIcon.Information); } //演算結果の格納 Calcstart = 0; for (int j = 0; j < iCalcIndex.Length; j++) { if (iCalcIndex[j] > 0) { //まだリスト内になければ作成 if (tmpTagDatas.Count <= Calcstart) tmpTagDatas.Add(new TagData() { DataValues = new Value_Mode2(false) { Values = new decimal[samplesCountofShot] }, TagNo = iCalcIndex[j] + 1 }); //対象を取得 val_mode2 = (Value_Mode2)tmpTagDatas[Calcstart].DataValues; val_mode2.Values[sampleindex] = (decimal)valCalcResult[Calcstart]; //int idx = iCalcIndex[j]; //if (x.ChannelDatas[idx].DataValues.GetType() == typeof(Value_Standard)) //{ // ((Value_Standard)x.ChannelDatas[idx].DataValues).Value = (decimal)valCalcResult[Calcstart]; //} //else if (x.ChannelDatas[idx].DataValues.GetType() == typeof(Value_MaxMin)) //{ // ((Value_MaxMin)x.ChannelDatas[idx].DataValues).MinValue = (decimal)valCalcResult[Calcstart]; //} Calcstart++; } } } //リターン値に格納 ret[i].TagDatas = tmpTagDatas.ToArray(); #endregion break; } } } catch (Exception ex) { ShowErrorMessage(ex); } return ret; //return null; }