Ejemplo n.º 1
0
        public object Clone()
        {
            SampleData ret = new SampleData();
            List<ChannelData> tmpChList = new List<ChannelData>();

            ret.SampleTime = this.SampleTime;

            foreach( ChannelData ch in ChannelDatas)
            {
                if (ch != null)
                    tmpChList.Add((ChannelData)ch.Clone());
                else
                    tmpChList.Add(null);
            }

            ret.ChannelDatas = tmpChList.ToArray();

            return ret;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 測定データをセットする
        /// </summary>
        /// <param name="dataList">測定データ</param>
        public void SetMeasureData(SampleData[] dataList)
        {
            try
            {
                //var time = DateTime.Now - RealTimeData.GetStartTime();
                //this.controllerForm.SetMeasureTime(time.ToString("hh\\:mm\\:ss\\.fff"));

                //総サンプル数の取得
                this.controllerForm.SetMeasureCount(RealTimeData.receiveCount.ToString());
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 3
0
        /// <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;
                }
            }
        }
Ejemplo n.º 4
0
        /// <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;
                }
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// 受信データを各データクラスに変換し現在値として格納。
        /// </summary>
        /// <param name="reserveData"></param>
        public void ReserveData(List<DataRecord_Base> reserveDatas)
        {
            System.Threading.Thread Endth = null;

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();

            sw.Reset();
            sw.Start();

            foreach (DataRecord_Base reserveData in reserveDatas)
            {
                try
                {
                    SampleData sampleData = new SampleData();
                    switch (reserveData.GetType().Name)
                    {
                        case "Mode1Record":
                            this.SetMode1Data((Mode1Record)reserveData, ref sampleData);
                            break;

                        case "Mode2Record":
                            this.SetMode2Data((Mode2Record)reserveData, ref sampleData);
                            break;

                        case "Mode3Record":
                            this.SetMode3Data((Mode3Record)reserveData, ref sampleData);
                            break;
                    }

                    if (SystemSetting.SystemConfig.IsDebugMode)
                    {
                        System.IO.File.AppendAllText(System.Windows.Forms.Application.StartupPath + "\\communicationLog.log"
                            , DateTime.Now.ToString() + " " + reserveData.ToString() + System.Environment.NewLine);
                    }

                    bool bLimit = false;

                    if (measureSetting.Mode == (int)ModeType.Mode1){
                        if( measureSetting.SamplingCountLimit != 0 &&
                            measureSetting.SamplingCountLimit < RealTimeData.receiveCount + 1)
                                bLimit = true;
                    }
                    else if(measureSetting.Mode == (int)ModeType.Mode3) {
                        
                         if(measureSetting.MeasureTime_Mode3 != 0 &&
                            measureSetting.MeasureTime_Mode3 <= ((RealTimeData.receiveCount + 1) * measureSetting.SamplingTiming_Mode3) / 1000000)
                             bLimit = true;
                    }
                    else if (measureSetting.Mode == (int)ModeType.Mode2) 
                    {
                            if(measureSetting.MeasureTime_Mode2 != 0 &&
                            RealTimeData.GetStartTime().AddSeconds(measureSetting.MeasureTime_Mode2) < sampleData.SampleTime)
                                bLimit = true;
                    }
                    
                    if(bLimit)
                    {
                        // モード1で受信カウント分をオーバー
                        // またはモード3で経過時間オーバーならば
                        // またはモード2で
                        // 測定停止
                        if (TestStatus != TestStatusType.Stop && TestStatus != TestStatusType.RuntoStop && Endth == null)
                        {
                            //測定停止時はモード1以外は追加
                            //モード1は別途条件があるため、この受信にて測定数が+されるとは限らない。
                            //よって、予定測定数を超えた時点での判定とするため、本受信を含めないこととする。
                            if (measureSetting.Mode != (int)ModeType.Mode1)
                                RealTimeData.AddRealData(sampleData);

                            Endth = new System.Threading.Thread(new System.Threading.ThreadStart(EndMethod));
                            Endth.Start();
                        }
                    }
                    else
                    {
                        //それ以外は追加
                        RealTimeData.AddRealData(sampleData);
                    }

                }
                catch { }
                //finally { System.Threading.Thread.Sleep(1); }
            }

            sw.Stop();

            System.Diagnostics.Debug.Print(sw.ElapsedMilliseconds + "ms" + " Count:" + reserveDatas.Count);

        }
Ejemplo n.º 6
0
        /// <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;
                }
            }
        }
Ejemplo n.º 7
0
        /// <summary>
        /// 測定データをセットする
        /// </summary>
        /// <param name="dataList">測定データ</param>
        public void SetMeasureData(SampleData[] dataList)
        {
            SetMeasureData(dataList, this.dataCounter);
            if (this.measSetting.Mode != 2)
                this.dataCounter += dataList.Length;
            else
            {
                if (dataList != null)
                {
                    var count = 0;

                    foreach (ChannelData ch in dataList[0].ChannelDatas)
                    {
                        if (ch != null && ch.Position != 0 && ch.DataValues != null)
                        {
                            count = ((Value_Mode2)ch.DataValues).Values.Length;
                            break;
                        }
                    }
                    dataCounter += count;
                }
            }

            Application.DoEvents();
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 測定データをセットする(測定時用)
        /// </summary>
        /// <param name="dataList">測定データ</param>
        /// <param name="minValueX">X軸最小値</param>
        /// <remarks>Called from Measurement</remarks>
        public void SetMeasureData(SampleData[] dataList, decimal minValueX)
        {
            //if (this.InvokeRequired)
            //{
            //    this.BeginInvoke((MethodInvoker)delegate() { SetMeasureData(dataList, minValueX); });
            //    return;
            //}

            try
            {
                if (dataList == null)
                {
                    throw new ArgumentNullException("dataList");
                }

                // グラフ未設定の場合は設定する
                if (this.measSetting == null)
                {
                    SetGraphSetting();
                }

                var graphData = new List<double[]>();
                var count = 0;

                if (this.measSetting.Mode == 2)
                {
                    var data = dataList.Last();

                    foreach (ChannelData ch in data.ChannelDatas)
                    {
                        if (ch != null && ch.Position != 0 && ch.DataValues != null)
                        {
                            count = ((Value_Mode2)ch.DataValues).Values.Length;
                            break;
                        }
                    }

                    SetMode2GraphInfo(count, 1);
                    var inc = this.GraphInfo.IncrementX;

                    var chSetting = (this.IsMeasure) ? SystemSetting.ChannelsSetting : this.AnalyzeData.ChannelsSetting;

                    if (chSetting != null && chSetting.ChannelMeasSetting != null)
                    {
                        minValueX = chSetting.ChannelMeasSetting.Degree1;
                    }

                    ////間引きステップ
                    ////500サンプルよりも多い場合は間引きし、500サンプルとなるようにする。
                    //double maxdatasize = 500d;
                    //double stepoffset = (double)count / maxdatasize;
                    //double stepcount = 0d;
                    //if (stepoffset < 1)
                    //    stepoffset = 1;

                    ///set maxdata size and shotcount (in this case maxdatasize 500 same as stepoffset)
                    //SetMode2GraphInfo((int)maxdatasize, 1);
                    //var inc = this.GraphInfo.IncrementX;
                    //var counter = 0;
                    //var chSetting = (this.IsMeasure) ? SystemSetting.ChannelsSetting : this.AnalyzeData.ChannelsSetting;

                    //if (chSetting != null && chSetting.ChannelMeasSetting != null)
                    //{
                    //    minValueX = chSetting.ChannelMeasSetting.Degree1;
                    //}

                    //for (int i = 0; i < count; i += (int)stepcount)
                    for (int i = 0; i < count; i++)
                    {
                        var chData = new double[11];
                        //chData[0] = minValueX + (counter * inc);
                        chData[0] = (double)minValueX + (i * inc);

                        if (this.chIndexList != null)
                        {
                            for (int j = 0; j < 10; j++)
                            {
                                if (this.chIndexList[j] != null)
                                {
                                    if (this.chIndexList[j].Index >= 0)
                                    {
                                        var t = data.ChannelDatas[this.chIndexList[j].Index].DataValues.GetType();
                                        if (t == typeof(Value_Standard))
                                        {
                                            // 回転数
                                            chData[j + 1] = (double)((Value_Standard)data.ChannelDatas[this.chIndexList[j].Index].DataValues).Value;
                                        }
                                        else if (t == typeof(Value_Mode2))
                                        {
                                            chData[j + 1] = (double)((Value_Mode2)data.ChannelDatas[this.chIndexList[j].Index].DataValues).Values[i];
                                        }
                                    }
                                }
                            }
                            graphData.Add(chData);
                        }

                        ////次回ステップ数を算出
                        //stepcount = (stepcount - Math.Floor(stepcount)) + stepoffset;
                        //counter++;

                    }
                }
                else
                {
                    ////間引きステップ
                    ////1000サンプルよりも多い場合は間引きし、500サンプルとなるようにする。
                    //double stepoffset = (double)count / 500d;
                    //double stepcount = 0d;
                    //if (stepoffset < 1)
                    //    stepoffset = 1;

                    count = dataList.Length;
                    //for (int i = 0; i < count; i += (int)stepcount)
                    for (int i = 0; i < count; i++)
                    {
                        var chData = new double[11];

                        if (this.measSetting.Mode == 1)
                        {
                            chData[0] = (double)(minValueX + i + 1);
                        }
                        else if (this.measSetting.Mode == 3)
                        {
                            // Mode3は時間をmsで算出する。[us]の場合もあるので,小数点以下も有効とする。
                            chData[0] = (double)((double)(minValueX + i) * (this.measSetting.SamplingTiming_Mode3 / 1000.0));
                        }

                        for (int j = 0; j < chIndexList.Length; j++)
                        {
                            if (this.chIndexList[j].Index >= 0)
                            {
                                var t = dataList[i].ChannelDatas[this.chIndexList[j].Index].DataValues.GetType();
                                if (t == typeof(Value_Standard))
                                {
                                    chData[j + 1] = (double)((Value_Standard)dataList[i].ChannelDatas[this.chIndexList[j].Index].DataValues).Value;
                                }
                                else if (t == typeof(Value_MaxMin))
                                {
                                    if (this.chIndexList[j].IsMaxCh)
                                    {
                                        chData[j + 1] = (double)((Value_MaxMin)dataList[i].ChannelDatas[this.chIndexList[j].Index].DataValues).MaxValue;
                                    }
                                    else
                                    {
                                        chData[j + 1] = (double)((Value_MaxMin)dataList[i].ChannelDatas[this.chIndexList[j].Index].DataValues).MinValue;
                                    }
                                }
                            }
                        }
                        graphData.Add(chData);

                        //次回ステップ数を算出
                        //stepcount = (stepcount - Math.Floor(stepcount)) + stepoffset;

                    }
                }

                if (graphData.Count > 0)
                {
                    if (this.InvokeRequired)
                    {
                        this.BeginInvoke((MethodInvoker)delegate() { this.graphViewer.ReadData(graphData); });
                        this.BeginInvoke((MethodInvoker)delegate() { this.graphViewer.CreateGraph(); });
                    }
                    else
                    {
                        this.graphViewer.ReadData(graphData);
                        this.graphViewer.CreateGraph();
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// データをセットする
        /// </summary>
        /// <param name="dataList">データ</param>
        public void SetData(SampleData[] dataList)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke((MethodInvoker)delegate() { SetData(dataList); });
                return;
            }

            try
            {
                if (dataList == null)
                {
                    throw new ArgumentNullException("dataList");
                }

                var graphData = new List<double[]>();

                var data = dataList.Last();

                var count = 0;

                foreach (ChannelData ch in data.ChannelDatas)
                    if (ch != null && ch.Position != 0 && ch.DataValues != null)
                    {
                        count = ((Value_Mode2)ch.DataValues).Values.Length;
                        break;
                    }

                for (int i = 0; i < count; i++)
                {
                    var chData = new double[11];
                    chData[0] = i;
                    for (int j = 1; j < 11; j++)
                    {
                        if (data.ChannelDatas[j] != null)
                        {
            #if TEST_INCLINE_3D
                            if (j == 3)
                                chData[j] = (double)((Value_Mode2)data.ChannelDatas[j].DataValues).Values[i];
                            else if (j == 1)
                                chData[j] = (double)((Value_Mode2)data.ChannelDatas[j].DataValues).Values[i] + 500;
                            else if (j == 2)
                                chData[j] = (double)((Value_Mode2)data.ChannelDatas[j].DataValues).Values[i] - 100;
                            else
                                chData[j] = (double)((Value_Mode2)data.ChannelDatas[j].DataValues).Values[i];
            #else
                            chData[j] = (double)((Value_Mode2)data.ChannelDatas[j].DataValues).Values[i];
                            //if (j == 2)
                            //    chData[j] += 700;
                            //else if (j == 1)
                            //    chData[j] += 100;

            #endif
                            //if (j != 11 && this.analyzeData.ChannelsSetting.ChannelSettingList[j - 1].ChKind == ChannelKindType.R)
                            //    chData[j] *= (double)SystemSetting.SystemConfig.ValueRate_3D_R;
                        }
                    }
                    graphData.Add(chData);
                }

                if (graphData.Count > 0)
                {
                    this.graph3DViewer.ReadData(graphData);
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 測定データをセットする
        /// </summary>
        /// <param name="dataList">測定データ</param>
        public void SetMeasureData(SampleData[] dataList)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke((MethodInvoker)delegate() { SetMeasureData(dataList); });
                return;
            }

            try
            {
                if (dataList == null)
                {
                    throw new ArgumentNullException("dataList");
                }

                var data = dataList.Last();
                SetData(data, 0);
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 現在値をセットする
        /// </summary>
        /// <param name="data">現在値データ</param>
        /// <param name="position">表示データ位置(Mode2で使用)</param>
        //public void SetData(SampleData data, int position)
        public void SetData(SampleData data, int position)
        {
            if (this.InvokeRequired)
            {
                this.BeginInvoke((MethodInvoker)delegate() { SetData(data, position); });
                return;
            }

            try
            {
                if (data == null)
                {
                    for (int i = 0; i < this.dataValueLabels.Length; i++)
                    {
                        this.dataValueLabels[i].Text = string.Empty;
                    }
                    return;
                }

                foreach (var chData in data.ChannelDatas)
                {
                    if (chData == null)
                    {
                        continue;
                    }

                    if (chData.DataValues == null) continue;

                    var index = -1;
                    for (int i = 0; i < this.dataValueLabels.Length; i++)
                    {
                        if (this.dataValueLabels[i].Name.Equals("lblDataValue" + chData.Position))
                        {
                            index = i;
                            break;
                        }
                        else if (this.dataValueLabels[i].Name.Equals("lblAnlDataMeas" + chData.Position))
                        {
                            index = i;
                            break;
                        }
                    }
                    if (index < 0)
                    {
                        continue;
                    }

                    var t = chData.DataValues.GetType();
                    if (t == typeof(Value_Standard))
                    {
                        this.dataValueLabels[index].Text = ((Value_Standard)chData.DataValues).Value.ToString(tagPoint[chData.Position]);

                        //Mode1の場合、ゼロ点を表示
                        if (this.measSetting.Mode == (int)ModeType.MODE1)
                        {
                            if(relationSetting.RelationList[chData.Position].TagNo_1 != -1)
                                this.dataValueLabels_Zero[index].Text =
                                    tagSetting.GetTag(relationSetting.RelationList[chData.Position].TagNo_1).StaticZero.ToString(tagPoint[chData.Position]);
                        }
                    }
                    else if (t == typeof(Value_MaxMin))
                    {
                        this.dataValueLabels[index].Text = ((Value_MaxMin)chData.DataValues).MaxValue.ToString(tagPoint[chData.Position]);

                        //TagNo_2があるとき
                        if (relationSetting.RelationList[chData.Position].TagNo_2 != -1)
                        {
                            if (isMeasure)
                            {
                                if (pnlMain.Controls.ContainsKey(this.dataValueLabels[index].Name + "-2"))
                                {
                                    Label val2_Lable = (Label)pnlMain.Controls.Find(this.dataValueLabels[index].Name + "-2", false)[0];

                                    val2_Lable.Text = ((Value_MaxMin)chData.DataValues).MinValue.ToString(tagPoint[chData.Position]);
                                }

                                //Mode1の場合、ゼロ点を表示
                                if (this.measSetting.Mode == (int)ModeType.MODE1)
                                {
                                     Label val2_Lable_Zero = (Label)pnlMain.Controls.Find(this.dataValueLabels_Zero[index].Name + "-2", false)[0];

                                     val2_Lable_Zero.Text =
                                        tagSetting.GetTag(relationSetting.RelationList[chData.Position].TagNo_2).StaticZero.ToString(tagPoint[chData.Position]);
                                }

                            }
                            else
                            {
                                if (tabPage1.Controls.ContainsKey(this.dataValueLabels[index].Name + "-2"))
                                {
                                    Label val2_Lable = (Label)tabPage1.Controls.Find(this.dataValueLabels[index].Name + "-2", false)[0];

                                    val2_Lable.Text = ((Value_MaxMin)chData.DataValues).MinValue.ToString(tagPoint[chData.Position]);
                                }

                                //Mode1の場合、ゼロ点を表示
                                if (this.measSetting.Mode == (int)ModeType.MODE1)
                                {
                                    Label val2_Lable_Zero = (Label)tabPage1.Controls.Find(this.dataValueLabels_Zero[index].Name + "-2", false)[0];

                                    val2_Lable_Zero.Text =
                                       tagSetting.GetTag(relationSetting.RelationList[chData.Position].TagNo_2).StaticZero.ToString(tagPoint[chData.Position]);
                                }
                            }
                        }
                    }
                    else if (t == typeof(Value_Mode2))
                    {
                        // Mode2は解析中のみ表示
                        var d = (Value_Mode2)chData.DataValues;
                        this.dataValueLabels[index].Text = d.Values[position].ToString(tagPoint[chData.Position]);
                    }
                }
            }
            catch (Exception ex)
            {
                ShowErrorMessage(ex);
            }
        }
Ejemplo n.º 12
0
        /// <summary>
        /// ���[�h�P�̏���ɂ��A����͈͓�ł��邩�𔻒�
        /// </summary>
        /// <param name="realdata"></param>
        /// <returns></returns>
        private static bool Judge_Mode1_Condition(SampleData realdata)
        {
            bool ret = bMode1_Now_Record;

            //�Վ��Ή��@PC���ԂŔ��肷��B
            DateTime realdata_time = realdata.SampleTime;
            //DateTime realdata_time = DateTime.Now;

            Mode1_MeasCondition cond = SystemSetting.MeasureSetting.Mode1_MeasCondition;

            switch (cond.MeasConditionType)
            {
                case Mode1_MeasCondition.EnumMeasConditionType.MEAS_ALL_SHOTS:
                    ret = true;
                    break;

                case Mode1_MeasCondition.EnumMeasConditionType.MEAS_INT_SHOTS:

                    //���Ԋu�擾���̓V���b�g����f�N�������g���A0�ȉ��ɂȂ�����ۑ��Ƃ���B
                    if (Cond_ShotCount_Mode1 <= 0)
                    {
                        Cond_ShotCount_Mode1 = cond.Interval_count;
                        ret = true;
                    }
                    else
                    {
                        ret = false;
                    }

                    Cond_ShotCount_Mode1--;

                    break;

                case Mode1_MeasCondition.EnumMeasConditionType.MEAS_AVG_SHOTS:

                    //���ώ擾���̓V���b�g����C���N�������g���A�ۑ�ON���ɖ{�֐��̊O���ʼn��Z�B
                    Cond_ShotCount_Mode1++;

                    if (Cond_ShotCount_Mode1 >= cond.Average_count)
                    {
                        ret = true;
                        Cond_ShotCount_Mode1 = 0;
                    }
                    else
                    {
                        ret = false;
                    }

                    break;

                case Mode1_MeasCondition.EnumMeasConditionType.MEAS_INT_TIME2SHOTS:

                    //����擾���̏ꍇ
                    if (Cond_StartTime_Mode1 == RealMeasureData.StartTime &&
                        Cond_StopTime_Mode1 == RealMeasureData.StartTime)
                    {
                        //����J�n���Ԃ𐶐��B
                        Cond_StartTime_Mode1 = realdata_time.AddMinutes(cond.Inverval_time2shot_time);
                        //��~���Ԃ͏���Ȃ��ׁ̈A�ݒ肵�Ȃ��B
                    }

                    //if (realdata_time.Hour != Cond_StartTime_Mode1.Hour && realdata_time.Hour == 0)
                    //    realdata_time.AddDays(1);

                    //���莞
                    if (bMode1_Now_Record)
                    {

                        if (Cond_ShotCount_Mode1 >= cond.Inverval_time2shot_shots)
                        {
                            Cond_ShotCount_Mode1 = 0;
                            //Cond_StopTime_Mode1 = realdata.SampleTime;
                            Cond_StopTime_Mode1 = realdata_time;
                            ret = false;
                        }
                        //����V���b�g��������񑪒�Ԋu����ɗ��Ă��܂��Ă���ꍇ
                        //else if ((realdata_time - Cond_StartTime_Mode1).TotalMinutes >= cond.Inverval_time2shot_time)
                        if (realdata_time >= Cond_StartTime_Mode1)
                        {

                            //����J�n���Ԃ�쐬
                            Cond_StartTime_Mode1 = Cond_StartTime_Mode1.AddMinutes(cond.Inverval_time2shot_time);

                            //����V���b�g����N���A������̂܂܂Ƃ���B
                            Cond_ShotCount_Mode1 = 0;
                            //Cond_StartTime_Mode1 = realdata.SampleTime;
                            Cond_ShotCount_Mode1++;
                        }
                        else
                        {
                            Cond_ShotCount_Mode1++;
                        }

                    }
                    //�����莞
                    else
                    {
                        //���Ԍo�߂���Ă����
                        if (realdata_time >= Cond_StartTime_Mode1)
                        {
                            //Cond_StartTime_Mode1 = realdata.SampleTime;

                            //����J�n���Ԃ�쐬
                            Cond_StartTime_Mode1 = Cond_StartTime_Mode1.AddMinutes(cond.Inverval_time2shot_time);

                            Cond_ShotCount_Mode1 = 1;

                            ret = true;
                        }
                    }
                    break;

                case Mode1_MeasCondition.EnumMeasConditionType.MEAS_INT_TIME2TIME:
                    //����擾���̏ꍇ
                    if (Cond_StartTime_Mode1 == RealMeasureData.StartTime &&
                        Cond_StopTime_Mode1 == RealMeasureData.StartTime)
                    {
                        //�����~���Ԃ𐶐��B
                        Cond_StopTime_Mode1 = realdata_time.AddMinutes(cond.Inverval_time2time_meastime);
                        //����J�n���Ԃ𐶐��B
                        Cond_StartTime_Mode1 = Cond_StopTime_Mode1.AddMinutes(cond.Inverval_time2time_stoptime);
                    }

                    //���莞
                    if (bMode1_Now_Record)
                    {

                        //if (realdata_time.Hour != Cond_StartTime_Mode1.Hour && realdata_time.Hour == 0)
                        //    realdata_time.AddDays(1);

                        //���Ԍo�߂���Ă����
                        if (realdata_time >= Cond_StopTime_Mode1)
                        {
                            Cond_ShotCount_Mode1 = 0;
                            //Cond_StopTime_Mode1 = realdata.SampleTime;
                            //���̒�~���Ԃ�ݒ�
                            Cond_StopTime_Mode1 = Cond_StartTime_Mode1.AddMinutes(cond.Inverval_time2time_meastime);

                            ret = false;
                        }
                        else
                        {
                            Cond_ShotCount_Mode1++;
                        }

                    }
                    //�����莞
                    else
                    {
                        //if (realdata_time.Hour != Cond_StopTime_Mode1.Hour && realdata_time.Hour == 0)
                        //    realdata_time.AddDays(1);

                        //���Ԍo�߂���Ă����
                        if (realdata_time >= Cond_StartTime_Mode1)
                        {
                            //Cond_StartTime_Mode1 = realdata.SampleTime;
                            //Cond_StartTime_Mode1 = realdata_time;
                            //���̊J�n���Ԃ�ݒ�
                            Cond_StartTime_Mode1 = Cond_StopTime_Mode1.AddMinutes(cond.Inverval_time2time_stoptime);

                            Cond_ShotCount_Mode1++;
                            ret = true;
                        }
                    }

                    break;
            }

            return ret;
        }
Ejemplo n.º 13
0
        /// <summary>
        /// AddRealData
        /// </summary>
        /// <param name="realdata">NowRegistData</param>
        public static void AddRealData(SampleData realdata)
        {
            lock (lockobj_samples)
            {
                //�ŏI��M���Ԃ�X�V
                LastDataReceiveTime = realdata.SampleTime;

                //���[�h1�̏ꍇ
                if (RM_3000.Sequences.TestSequence.GetInstance().Mode == Sequences.TestSequence.ModeType.Mode1)
                {
                    //���[�h�P�̏���ɓ����Ă��邩�H
                    bMode1_Now_Record = Judge_Mode1_Condition(realdata);

                    //���ϑ���̏ꍇ
                    if (SystemSetting.MeasureSetting.Mode1_MeasCondition.MeasConditionType == Mode1_MeasCondition.EnumMeasConditionType.MEAS_AVG_SHOTS)
                    {
                        // �ۑ��^�C�~���O = ���ω��Z�����
                        if (bMode1_Now_Record)
                        {
                            for (int shotindex = 0 ; shotindex < TmpAverage_Samples.Count ; shotindex++)
                            {
                                SampleData tmp = TmpAverage_Samples[shotindex];

                                for (int i = 0; i < tmp.ChannelDatas.Length; i++)
                                {
                                    if (realdata.ChannelDatas[i] == null) continue;

                                    if (realdata.ChannelDatas[i].DataValues is Value_Standard)
                                    {
                                        //����͂܂���������ς��Ă���
                                        if (shotindex == 0)
                                        {
                                            ((Value_Standard)realdata.ChannelDatas[i].DataValues).Value /= TmpAverage_Samples.Count + 1;
                                        }

                                        ((Value_Standard)realdata.ChannelDatas[i].DataValues).Value += ((Value_Standard)tmp.ChannelDatas[i].DataValues).Value / (TmpAverage_Samples.Count + 1);

                                        ////�S�đ������񂾂Ȃ�A���ω��Z
                                        //if (shotindex + 1 == TmpAverage_Samples.Count)
                                        //    ((Value_Standard)realdata.ChannelDatas[i].DataValues).Value /= TmpAverage_Samples.Count + 1;
                                    }
                                    else if (realdata.ChannelDatas[i].DataValues is Value_MaxMin)
                                    {
                                        //����͂܂���������ς��Ă���
                                        if (shotindex == 0)
                                        {
                                            ((Value_MaxMin)realdata.ChannelDatas[i].DataValues).MaxValue /= TmpAverage_Samples.Count + 1;
                                            ((Value_MaxMin)realdata.ChannelDatas[i].DataValues).MinValue /= TmpAverage_Samples.Count + 1;
                                        }

                                        ((Value_MaxMin)realdata.ChannelDatas[i].DataValues).MaxValue += ((Value_MaxMin)tmp.ChannelDatas[i].DataValues).MaxValue / (TmpAverage_Samples.Count + 1);
                                        ((Value_MaxMin)realdata.ChannelDatas[i].DataValues).MinValue += ((Value_MaxMin)tmp.ChannelDatas[i].DataValues).MinValue / (TmpAverage_Samples.Count + 1);

                                        ////�S�đ������񂾂Ȃ�A���ω��Z
                                        //if (shotindex + 1 == TmpAverage_Samples.Count)
                                        //{
                                        //    ((Value_MaxMin)realdata.ChannelDatas[i].DataValues).MaxValue /= TmpAverage_Samples.Count + 1;
                                        //    ((Value_MaxMin)realdata.ChannelDatas[i].DataValues).MinValue /= TmpAverage_Samples.Count + 1;
                                        //}
                                    }
                                }
                            }

                            //���ߍ��ݗp��N���A
                            TmpAverage_Samples.Clear();
                            GC.Collect();
                        }
                        // �ۑ��^�C�~���O�ł͂Ȃ�
                        else
                        {
                            //���Ϗ����p�ɗ��ߍ���
                            TmpAverage_Samples.Add(realdata);
                        }
                    }
                }

                //�ۑ��w�����肩�AMode1�Ȃ�΃��[�h�P����OK���𔻕�
                if (bRecord && (bMode1_Now_Record || RM_3000.Sequences.TestSequence.GetInstance().Mode != Sequences.TestSequence.ModeType.Mode1))
                {
                    //�e�X�g�f�[�^�Ƃ��ċL��
                    RealMeasureData.SampleDatas.Add(realdata);
                }

                //���[�h1�ŕۑ��^�C�~���O�ł͂Ȃ����́A�`��ɂ���߂Ȃ��B
                if (bCond_MeasurePause)
                    return;

                SampleData realdata_sample = (SampleData)realdata.Clone();

                //���[�h�P����擾�Ȃ�΃I�t�Z�b�g�p���I�[����ݒ�
                if (SystemSetting.MeasureSetting.Mode == (int)ModeType.MODE1 && receiveCount == 0)
                {
                    //�`�����l�������[�v
                    for (int i = 1; i < realdata_sample.ChannelDatas.Length; i++)
                    {
                        if (realdata_sample.ChannelDatas[i] == null) continue;
                        if (realdata_sample.ChannelDatas[i].DataValues == null) continue;

                        //�`�����l����B��R�Ȃ��
                        if (SystemSetting.ChannelsSetting.ChannelSettingList[i - 1].ChKind == ChannelKindType.B
                            || SystemSetting.ChannelsSetting.ChannelSettingList[i - 1].ChKind == ChannelKindType.R)
                        {
                            //TagNo1�Ń`�F�b�N
                            if (SystemSetting.RelationSetting.RelationList[i].TagNo_1 != -1 &&
                                RealTimeData.DataTagSetting.GetTag(SystemSetting.RelationSetting.RelationList[i].TagNo_1).StaticZero == 0)
                            {
                                //�m�[�}���f�[�^
                                if (realdata_sample.ChannelDatas[i].DataValues is Value_Standard)
                                {
                                    RealTimeData.DataTagSetting.GetTag(SystemSetting.RelationSetting.RelationList[i].TagNo_1).StaticZero =
                                        ((Value_Standard)realdata_sample.ChannelDatas[i].DataValues).Value;
                                }
                                //MaxMin�f�[�^
                                else
                                {
                                    RealTimeData.DataTagSetting.GetTag(SystemSetting.RelationSetting.RelationList[i].TagNo_1).StaticZero =
                                        (((Value_MaxMin)realdata_sample.ChannelDatas[i].DataValues).MinValue + ((Value_MaxMin)realdata_sample.ChannelDatas[i].DataValues).MaxValue) / 2;
                                }
                            }

                            //TagNo2 �Ń`�F�b�N
                            if (SystemSetting.RelationSetting.RelationList[i].TagNo_2 != -1 &&
                                RealTimeData.DataTagSetting.GetTag(SystemSetting.RelationSetting.RelationList[i].TagNo_2).StaticZero == 0)
                            {
                                //�m�[�}���Ȃ�Ύg��Ȃ�
                                if (realdata_sample.ChannelDatas[i].DataValues is Value_Standard)
                                {
                                }
                                //MaxMin�Ńf�[�^��g��
                                else
                                {
                                    RealTimeData.DataTagSetting.GetTag(SystemSetting.RelationSetting.RelationList[i].TagNo_2).StaticZero =
                                        (((Value_MaxMin)realdata_sample.ChannelDatas[i].DataValues).MinValue + ((Value_MaxMin)realdata_sample.ChannelDatas[i].DataValues).MaxValue) / 2;
                                }
                            }
                        }
                    }
                }

                Samples.Add(realdata_sample);
                receiveCount++;

            }
        }