/// <summary> /// グラフ詳細グリッドに表示する /// </summary> /// <param name="detailIndex"></param> private void SetGraphDetail(int detailIndex, int tagNo, GraphSetting graph) { if (graph.GraphTagList[detailIndex].GraphTagNo != tagNo) { graph.GraphTagList[detailIndex].GraphTagNo = tagNo; this.dirty = true; if (string.IsNullOrEmpty(graph.GraphTagList[detailIndex].Color)) { graph.GraphTagList[detailIndex].Color = "Red"; } this.dgvGraphDetail[1, detailIndex].Value = this.tagSetting.GetTagNameFromTagNo(tagNo); this.dgvGraphDetail[2, detailIndex].Value = this.tagSetting.GetUnitFromTagNo(tagNo); this.dgvGraphDetail[3, detailIndex].Value = graph.GraphTagList[detailIndex].Color; } }
/// <summary> /// set graph detail from measuretag /// </summary> /// <param name="detailIndex"></param> private void SetGraphDetail(int detailIndex, int tagNo, GraphSetting graph) { var graphTagIndex = 0; for (int k = 0; k < this.dgvGraphDetail.RowCount; k++) { if ((int)this.dgvGraphDetail.Rows[k].Cells[0].Value == detailIndex + 1) { graphTagIndex = k; } } if (graph.GraphTagList[graphTagIndex].GraphTagNo != tagNo) { graph.GraphTagList[graphTagIndex].GraphTagNo = tagNo; //this.dirty = true; this.measSetting.IsUpdated = true; if (string.IsNullOrEmpty(graph.GraphTagList[graphTagIndex].Color)) { graph.GraphTagList[graphTagIndex].Color = "Red"; } this.dgvGraphDetail[1, detailIndex].Value = this.tagSetting.GetTagNameFromTagNo(tagNo); this.dgvGraphDetail[2, detailIndex].Value = this.tagSetting.GetUnitFromTagNo(tagNo); this.dgvGraphDetail[3, detailIndex].Value = graph.GraphTagList[graphTagIndex].Color; } }
/// <summary> /// BとRボードのみであるかチェックする /// </summary> /// <param name="graphSetting">グラフ設定</param> /// <returns></returns> private bool CheckBoardBR(GraphSetting graphSetting) { if (this.relationSetting != null && this.relationSetting.RelationList != null && this.chSetting != null && this.chSetting.ChannelSettingList != null && chSetting.ChannelSettingList.Length > 0) { for (int i = 0; i < graphSetting.GraphTagList.Length; i++) { var tagNo = graphSetting.GraphTagList[i].GraphTagNo; if (tagNo < 0) { continue; } // 回転数タグか if (tagNo == this.relationSetting.RelationList[0].TagNo_1) { return false; } // ボード種別がBかRであることをチェック for (int j = 1; j < this.relationSetting.RelationList.Length; j++) { if (tagNo == this.relationSetting.RelationList[j].TagNo_1 || tagNo == this.relationSetting.RelationList[j].TagNo_2) { var chKind = this.chSetting.ChannelSettingList[this.relationSetting.RelationList[j].ChannelNo - 1].ChKind; if (chKind != ChannelKindType.B && chKind != ChannelKindType.R) { return false; } break; } } } } else { return false; } return true; // B or R board only }
/// <summary> /// 現在のインスタンスのコピーである新しいオブジェクトを作成します /// </summary> /// <returns>このインスタンスのコピーである新しいオブジェクト</returns> public object Clone() { var ret = new GraphSetting(); ret.Title = this.Title; ret.CenterScale = this.CenterScale; ret.Scale = this.Scale; ret.MinimumX_Mode1 = this.MinimumX_Mode1; ret.MinimumX_Mode2 = this.MinimumX_Mode2; ret.MinimumX_Mode3 = this.MinimumX_Mode3; ret.MaxX_Mode1 = this.MaxX_Mode1; ret.MaxX_Mode2 = this.MaxX_Mode2; ret.MaxX_Mode3 = this.MaxX_Mode3; ret.DistanceX_Mode1 = this.DistanceX_Mode1; ret.DistanceX_Mode2 = this.DistanceX_Mode2; ret.DistanceX_Mode3 = this.DistanceX_Mode3; ret.MinimumY_Mode1 = this.minimumY_Mode1; ret.MinimumY_Mode2 = this.minimumY_Mode2; ret.MinimumY_Mode3 = this.minimumY_Mode3; ret.MaxY_Mode1 = this.MaxY_Mode1; ret.MaxY_Mode2 = this.MaxY_Mode2; ret.MaxY_Mode3 = this.MaxY_Mode3; ret.DistanceY_CenterScale_Mode1 = this.DistanceY_CenterScale_Mode1; ret.DistanceY_Mode1 = this.DistanceY_Mode1; ret.DistanceY_Mode2 = this.DistanceY_Mode2; ret.DistanceY_Mode3 = this.DistanceY_Mode3; ret.NumbeOfShotMode2 = this.NumbeOfShotMode2; ret.GraphTagList = new GraphTag[this.GraphTagList.Length]; for (int i = 0; i < ret.GraphTagList.Length; i++) { ret.GraphTagList[i] = (GraphTag)this.GraphTagList[i].Clone(); } return ret; }
/// <summary> /// 小数点桁数設定を取得する /// グラフに割り当てられているタグの中から最も大きい設定を採用する /// </summary> /// <param name="graphSetting">グラフ設定</param> /// <returns>小数点桁数設定</returns> private int GetDecimalPoint(GraphSetting graphSetting) { var ret = 0; for (int i = 0; i < graphSetting.GraphTagList.Length; i++) { var tagNo = graphSetting.GraphTagList[i].GraphTagNo; if (tagNo < 0) { continue; } var tag = this.tagSetting.GetTag(tagNo); if (tag.Point > ret) { ret = tag.Point; } } return ret; }
/// <summary> /// Mode3のグラフを設定する /// </summary> /// <param name="graphSetting">グラフ設定</param> private void CreateGraphInfo3(GraphSetting graphSetting) { var dt = DateTime.Now; var graphinfo = this.GraphInfo; graphinfo.GraphNo = 1; graphinfo.GraphName = graphSetting.Title; graphinfo.IsEnabled = true; graphinfo.AxisNameX = "[ms]"; graphinfo.AxisNameY = this.tagSetting.GetUnitFromTagNo(graphSetting.GraphTagList[0].GraphTagNo); graphinfo.MinValueX = (double)graphSetting.MinimumX_Mode3; //graphinfo.MaxValueX = (double)graphSetting.MaxX * ((double)this.measSetting.SamplingTiming / 1000); graphinfo.MaxValueX = (double)graphSetting.MaxX_Mode3; graphinfo.DistanceX = graphSetting.DistanceX_Mode3; graphinfo.MinValueY = (double)graphSetting.MinimumY_Mode3; graphinfo.MaxValueY = (double)graphSetting.MaxY_Mode3; graphinfo.DistanceY = graphSetting.DistanceY_Mode3; graphinfo.AxisPositionX = null; graphinfo.AxisPositionY = null; if (graphinfo.DistanceX < 1) graphinfo.DecimalPointX = 2; else graphinfo.DecimalPointX = 0; //graphinfo.DecimalPointY = 2; if (graphinfo.DistanceY < 1) graphinfo.DecimalPointY = 2; else graphinfo.DecimalPointY = GetDecimalPoint(graphSetting); graphinfo.ShotCount = 1; if (this.IsMeasure) graphinfo.GraphMode = GraphLib.GraphMode.Moving; else graphinfo.GraphMode = GraphLib.GraphMode.Normal; graphinfo.StartDateTime = dt; graphinfo.DateTimeFormat = "ss.ffff"; graphinfo.IsLineGraph = (this.IsMeasure) ? true : false; graphinfo.ShowDateTimeAxisX = false; graphinfo.ShowValueLabelX = !this.IsMeasure || SystemSetting.SystemConfig.IsDebugMode; graphinfo.ShowValueLabelY = true; graphinfo.MeasureButtonShow = !this.IsMeasure; graphinfo.IncrementX = ((double)this.measSetting.SamplingTiming_Mode3 / 1000); if (graphinfo.MaxValueX < graphinfo.IncrementX) { graphinfo.MaxValueX = graphinfo.IncrementX; graphinfo.DistanceX = Convert.ToDecimal(graphinfo.IncrementX); } graphinfo.MinMaxRangeX = graphinfo.MaxValueX - graphinfo.MinValueX; graphinfo.MaxDataSizeX = Convert.ToInt32((graphinfo.MaxValueX - graphinfo.MinValueX) / graphinfo.IncrementX) + 1; graphinfo.PlotCountX = graphinfo.MaxDataSizeX - 1; graphinfo.AddIndex = 0; graphinfo.ChannelInfos = new List<GraphLib.ChannelInfo>(); graphinfo.ChannelInfos.Clear(); var d = new System.Windows.Media.ColorConverter(); for (int ch = 0; ch < graphSetting.GraphTagList.Length; ch++) { if (graphSetting.GraphTagList[ch].GraphTagNo != -1 && (this.chIndexList[ch].Index >= 0 || this.calcTagList[ch].Index >= 0)) { GraphLib.ChannelInfo chinfo = new GraphLib.ChannelInfo(); chinfo.CHColor = (System.Windows.Media.Color)d.ConvertFromInvariantString(graphSetting.GraphTagList[ch].Color); //chinfo.CHLineSize = 1.25; chinfo.CHNo = ch + 1; chinfo.CHName = this.tagSetting.GetTagNameFromTagNo(graphSetting.GraphTagList[ch].GraphTagNo); chinfo.IsEnabled = true; graphinfo.ChannelInfos.Add(chinfo); } } graphinfo.MaxChannel = graphinfo.ChannelInfos.Count; this.GraphInfo = graphinfo; }
/// <summary> /// Mode2のグラフを設定する /// </summary> /// <param name="graphSetting">グラフ設定</param> private void CreateGraphInfo2(GraphSetting graphSetting) { GraphLib.GraphInfo graphinfo = this.GraphInfo; graphinfo.GraphNo = 1; graphinfo.GraphName = graphSetting.Title; graphinfo.IsEnabled = true; graphinfo.AxisNameX = AppResource.GetString("TXT_UNIT_DEGREE"); graphinfo.AxisNameY = this.tagSetting.GetUnitFromTagNo(graphSetting.GraphTagList[0].GraphTagNo); var chSetting = (this.IsMeasure) ? SystemSetting.ChannelsSetting : this.AnalyzeData.ChannelsSetting; graphinfo.MinValueX = (double)chSetting.ChannelMeasSetting.Degree1; graphinfo.MaxValueX = (double)chSetting.ChannelMeasSetting.Degree2; graphinfo.DistanceX = graphSetting.DistanceX_Mode2; graphinfo.MinValueY = (double)graphSetting.MinimumY_Mode2; graphinfo.MaxValueY = (double)graphSetting.MaxY_Mode2; graphinfo.DistanceY = graphSetting.DistanceY_Mode2; graphinfo.AxisPositionX = null; graphinfo.AxisPositionY = null; graphinfo.MinMaxRangeX = graphinfo.MaxValueX - graphinfo.MinValueX; if (graphinfo.MaxDataSizeX == 0) { graphinfo.MaxDataSizeX = Convert.ToInt32(graphinfo.MaxValueX - graphinfo.MinValueX); graphinfo.PlotCountX = graphinfo.MaxDataSizeX; } if (graphinfo.IncrementX == 0) graphinfo.IncrementX = 1; graphinfo.DecimalPointY = GetDecimalPoint(graphSetting); graphinfo.ShotCount = (this.IsMeasure) ? 1 : graphSetting.NumbeOfShotMode2; graphinfo.GraphMode = GraphLib.GraphMode.Normal; graphinfo.IsLineGraph = true; graphinfo.ShowDateTimeAxisX = false; graphinfo.ShowValueLabelX = !this.IsMeasure || SystemSetting.SystemConfig.IsDebugMode; graphinfo.ShowValueLabelY = true; graphinfo.MeasureButtonShow = !this.IsMeasure; graphinfo.DecimalPointX = 1; graphinfo.AddIndex = 0; graphinfo.ChannelInfos = new List<GraphLib.ChannelInfo>(); graphinfo.ChannelInfos.Clear(); var d = new System.Windows.Media.ColorConverter(); for (int ch = 0; ch < graphSetting.GraphTagList.Length; ch++) { if (graphSetting.GraphTagList[ch].GraphTagNo != -1 && (this.chIndexList[ch].Index >= 0 || this.calcTagList[ch].Index >= 0)) { GraphLib.ChannelInfo chinfo = new GraphLib.ChannelInfo(); chinfo.CHColor = (System.Windows.Media.Color)d.ConvertFromInvariantString(graphSetting.GraphTagList[ch].Color); //chinfo.CHLineSize = 1.25; chinfo.CHNo = ch + 1; chinfo.CHName = this.tagSetting.GetTagNameFromTagNo(graphSetting.GraphTagList[ch].GraphTagNo); chinfo.IsEnabled = true; graphinfo.ChannelInfos.Add(chinfo); } } graphinfo.MaxChannel = graphinfo.ChannelInfos.Count; this.GraphInfo = graphinfo; if (this.log != null) this.log.PutLog("CreateGraphInfo2" + graphinfo.ToString()); }
/// <summary> /// Mode1のグラフを設定する /// </summary> /// <param name="graphSetting">グラフ設定</param> private void CreateGraphInfo1(GraphSetting graphSetting) { DateTime dt = DateTime.Now; GraphLib.GraphInfo graphinfo = this.GraphInfo; // Check this graph includes B and R type board only. var boardBR = CheckBoardBR(graphSetting); graphinfo.GraphNo = 1; graphinfo.GraphName = graphSetting.Title; graphinfo.IsEnabled = true; graphinfo.AxisNameX = "Shot"; graphinfo.AxisNameY = this.tagSetting.GetUnitFromTagNo(graphSetting.GraphTagList[0].GraphTagNo); graphinfo.MinValueX = (double)graphSetting.MinimumX_Mode1 + 1; graphinfo.MaxValueX = (double)graphSetting.MaxX_Mode1; graphinfo.DistanceX = graphSetting.DistanceX_Mode1; if (boardBR) { graphinfo.MinValueY = (double)(graphSetting.CenterScale - graphSetting.Scale); graphinfo.MaxValueY = (double)(graphSetting.CenterScale + graphSetting.Scale); graphinfo.AxisPositionY = (double)graphSetting.CenterScale; graphinfo.DistanceY = graphSetting.DistanceY_CenterScale_Mode1; } else { graphinfo.MinValueY = (double)graphSetting.MinimumY_Mode1; graphinfo.MaxValueY = (double)graphSetting.MaxY_Mode1; graphinfo.AxisPositionY = null; graphinfo.DistanceY = graphSetting.DistanceY_Mode1; } graphinfo.AxisPositionX = null; graphinfo.MinMaxRangeX = graphinfo.MaxValueX - graphinfo.MinValueX; if (this.IsMeasure) graphinfo.MaxDataSizeX = Convert.ToInt32(graphinfo.MaxValueX - graphinfo.MinValueX) + 1; else graphinfo.MaxDataSizeX = Convert.ToInt32(graphinfo.MaxValueX - graphinfo.MinValueX); graphinfo.PlotCountX = graphinfo.MaxDataSizeX; graphinfo.ShotCount = 1; if (this.IsMeasure) graphinfo.GraphMode = GraphLib.GraphMode.Moving; else graphinfo.GraphMode = GraphLib.GraphMode.Normal; graphinfo.StartDateTime = dt; graphinfo.DateTimeFormat = "mm:ss.ff"; graphinfo.IsLineGraph = (this.IsMeasure) ? true : false; graphinfo.ShowDateTimeAxisX = false; graphinfo.ShowValueLabelX = !this.IsMeasure || SystemSetting.SystemConfig.IsDebugMode; graphinfo.ShowValueLabelY = true; graphinfo.MeasureButtonShow = !this.IsMeasure; graphinfo.IncrementX = 1; graphinfo.AddIndex = 1; graphinfo.DecimalPointY = GetDecimalPoint(graphSetting); graphinfo.ChannelInfos = new List<GraphLib.ChannelInfo>(); graphinfo.ChannelInfos.Clear(); var d = new System.Windows.Media.ColorConverter(); for (int ch = 0; ch < graphSetting.GraphTagList.Length; ch++) { if (graphSetting.GraphTagList[ch].GraphTagNo != -1 && (this.chIndexList[ch].Index >= 0 || this.calcTagList[ch].Index >= 0)) { GraphLib.ChannelInfo chinfo = new GraphLib.ChannelInfo(); chinfo.CHColor = (System.Windows.Media.Color)d.ConvertFromInvariantString(graphSetting.GraphTagList[ch].Color); //chinfo.CHLineSize = 1.5; chinfo.CHNo = ch + 1; chinfo.CHName = this.tagSetting.GetTagNameFromTagNo(graphSetting.GraphTagList[ch].GraphTagNo); chinfo.IsEnabled = true; graphinfo.ChannelInfos.Add(chinfo); } } graphinfo.MaxChannel = graphinfo.ChannelInfos.Count; this.GraphInfo = graphinfo; }
/// <summary> /// フォームロードイベント /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void frmGraphAxisSetting_Load(object sender, EventArgs e) { if (this.log != null) this.log.PutLog("frmGraphAxisSetting.frmGraphAxisSetting_Load() - グラフ軸設定画面のロードを開始しました。"); try { AppResource.SetControlsText(this); config.LoadXmlFile(); IsModXAxis = false; if (this.MeasSetting == null) { ShowErrorMessage(AppResource.GetString("ERROR_MEASURE_SETTING_FILE_NOT_FOUND")); this.Close(); } if (this.IsMeasure) { // 測定中 this.relationSetting = SystemSetting.RelationSetting; this.chSetting = SystemSetting.ChannelsSetting; } else { // 解析中 this.relationSetting = this.AnalyzeData.TagChannelRelationSetting; this.chSetting = this.AnalyzeData.ChannelsSetting; } // Check this graph includes B and R type board only. (Mode1) this.boardBR = (this.MeasSetting.Mode == 1) ? CheckBoardBR(this.Graph) : false; this.binding = true; if (Graph != null) { this.currentGraphSetting = (GraphSetting)Graph.Clone(); if (this.MeasSetting.Mode == 1) { this.ntbMinX.Text = Graph.MinimumX_Mode1.ToString(); this.ntbMaxX.Text = Graph.MaxX_Mode1.ToString(); this.ntbDistanceX.Text = Graph.DistanceX_Mode1.ToString(); if (this.boardBR) { this.lblSign.Visible = true; this.ntbMinY.Text = Graph.CenterScale.ToString(); this.ntbMaxY.Text = Graph.Scale.ToString(); this.ntbMinY.MaxLength = 9; this.ntbMaxY.AllowMinus = false; this.ntbDistanceY.Text = Graph.DistanceY_CenterScale_Mode1.ToString(); } else { this.ntbMinY.Text = Graph.MinimumY_Mode1.ToString(); this.ntbMaxY.Text = Graph.MaxY_Mode1.ToString(); this.ntbMaxY.AllowMinus = true; this.ntbDistanceY.Text = Graph.DistanceY_Mode1.ToString(); } this.ntbMinY.AllowMinus = true; } else if (this.MeasSetting.Mode == 2) { this.ntbMinX.Text = SystemSetting.ChannelsSetting.ChannelMeasSetting.Degree1.ToString(); this.ntbMaxX.Text = SystemSetting.ChannelsSetting.ChannelMeasSetting.Degree2.ToString(); this.ntbDistanceX.Text = Graph.DistanceX_Mode2.ToString(); this.ntbMinY.Text = Graph.MinimumY_Mode2.ToString(); this.ntbMaxY.Text = Graph.MaxY_Mode2.ToString(); this.ntbDistanceY.Text = Graph.DistanceY_Mode2.ToString(); } else if (this.MeasSetting.Mode == 3) { this.ntbMinX.Text = Graph.MinimumX_Mode3.ToString(); this.ntbMaxX.Text = Graph.MaxX_Mode3.ToString(); this.ntbDistanceX.Text = Graph.DistanceX_Mode3.ToString(); this.ntbMinY.Text = Graph.MinimumY_Mode3.ToString(); this.ntbMaxY.Text = Graph.MaxY_Mode3.ToString(); this.ntbDistanceY.Text = Graph.DistanceY_Mode3.ToString(); } //if (this.MeasSetting.Mode == 1) //{ // this.ntbMinY.Text = Graph.CenterScale.ToString(); // this.ntbMaxY.Text = Graph.Scale.ToString(); // this.ntbMinY.AllowMinus = true; // this.ntbMaxY.AllowMinus = true; // this.ntbMinY.MaxLength = 9; // this.ntbDistanceY.Text = Graph.DistanceY_Mode1.ToString(); //} //else //{ // if (this.MeasSetting.Mode == 2) // { // this.ntbMinY.Text = Graph.MinimumY_Mode2.ToString(); // this.ntbMaxY.Text = Graph.MaxY_Mode2.ToString(); // this.ntbDistanceY.Text = Graph.DistanceY_Mode2.ToString(); // } // else // { // this.ntbMinY.Text = Graph.MinimumY_Mode3.ToString(); // this.ntbMaxY.Text = Graph.MaxY_Mode3.ToString(); // this.ntbDistanceY.Text = Graph.DistanceY_Mode3.ToString(); // } //} if (this.MeasSetting.Mode != 2) { ntbMinX.Enabled = false; ntbMinX.Text = "0"; } // this.ntbDistanceY.Text = Graph.DistanceY.ToString(); this.ntbShotNumber.Text = Graph.NumbeOfShotMode2.ToString(); } this.binding = false; string unit = string.Empty; if (this.MeasSetting.Mode == 3) { // To Net // Enable below after you fix #.... #if false if (this.MeasSetting.SamplingTiming_Mode3 > 999999) { unit = AppResource.GetString("TXT_UNIT_SECOND"); } else if (this.MeasSetting.SamplingTiming_Mode3 > 999) { unit = AppResource.GetString("TXT_UNIT_MILLISECOND"); } else if (this.MeasSetting.SamplingTiming_Mode3 <= 999) { unit = AppResource.GetString("TXT_UNIT_MICROSECOND"); ; } #else unit = AppResource.GetString("TXT_UNIT_MILLISECOND"); #endif } if (this.MeasSetting.Mode == 1) { this.lblUnit1.Text = "TXT_SHOT_NUMBER"; this.lblUnit2.Text = string.Empty; } else if (this.MeasSetting.Mode == 2) { if (!IsMeasure) { this.lblShotNumber.Visible = true; this.ntbShotNumber.Visible = true; this.lblShot.Visible = true; } this.lblUnit1.Text = "TXT_DEGREE_UNIT"; this.lblUnit2.Text = string.Empty; ntbMinX.Enabled = false; ntbMaxX.Enabled = false; } else if (this.MeasSetting.Mode == 3) { this.lblUnit1.Text = unit; this.lblUnit2.Text = string.Empty; } if (this.currentGraphSetting != null && this.currentGraphSetting.GraphTagList != null) { for (int i = 0; i < this.currentGraphSetting.GraphTagList.Length; i++) { if (this.currentGraphSetting.GraphTagList[i].GraphTagNo > 0) { if (!IsMeasure && this.MeasSetting.Mode == 2) { this.lblShotNumber.Visible = true; this.ntbShotNumber.Visible = true; this.lblShot.Visible = true; } DataTagSetting tagSetting = (IsMeasure) ? SystemSetting.DataTagSetting : this.AnalyzeData.DataTagSetting; this.lblUnit2.Text = tagSetting.GetUnitFromTagNo(this.currentGraphSetting.GraphTagList[i].GraphTagNo); break; } } } // 言語切替 AppResource.SetControlsText(this); } catch (Exception ex) { ShowErrorMessage(ex); } if (this.log != null) this.log.PutLog("frmGraphAxisSetting.frmGraphAxisSetting_Load() - グラフ軸設定画面のロードを終了しました。"); }