/// <summary> /// 解析模拟量数据并显示 /// </summary> /// <param Name="bin">模拟量内存结构</param> public void fromBin(AnalogBin bin) { ///设置正常的背景和前景颜色 normalBg = Color.FromArgb((Int32)bin.normalBgClr); normal = Color.FromArgb((Int32)bin.normalClr); overMinClr = Color.FromArgb((Int32)bin.overMinClr); overMinBgClr = Color.FromArgb((Int32)bin.overMinBgClr); overMaxClr = Color.FromArgb((Int32)bin.overMaxClr); overMaxBgClr = Color.FromArgb((Int32)bin.overMaxBgClr); ///设置位置 this.Location = new Point(bin.rect.sX, bin.rect.sY); this.Width = bin.rect.eX - bin.rect.sX; this.Height = bin.rect.eY - bin.rect.sY; this._enExploer = bin.enExponent; _nDecimalNum = bin.nDecimalNum; _min = (Int32)bin.vMin; _max = (Int32)bin.vMax; _dataControl.LabelInfo.Text = String.Format("范围: {0}-{1}", _min, _max); _dataControl.Num.Minimum = _min - 20; _dataControl.Num.Maximum = _max + 20; if (bin.enExponent == 1) { double num = 0.0; this.Text = num.ToString(String.Format("e{0}", bin.nDecimalNum), CultureInfo.InvariantCulture); } else { double num = 0.0; this.Text = num.ToString(String.Format("f{0}", bin.nDecimalNum)); } Dictionary <Byte, Font> FontConfig = new Dictionary <Byte, Font>(); FontConfig.Add(8, new Font("华文细黑", 8)); FontConfig.Add(12, new Font("华文细黑", 12)); FontConfig.Add(16, new Font("华文细黑", 16)); if (FontConfig.ContainsKey(bin.font)) { this.Font = FontConfig[bin.font]; } }
public void make(ref PageArrayBin pageArrayBin, ref SVSerialize serialize) { UInt32 pageCount = pageArrayBin.pageCount; UInt32 analogCount = pageArrayBin.pageArray[pageCount].analog_num++; if (pageArrayBin.pageArray[pageCount].m_analog == null) { pageArrayBin.pageArray[pageCount].m_analog = new AnalogBin[SVLimit.PAGE_ANA_MAXNUM]; } AnalogBin analogBin = pageArrayBin.pageArray[pageCount].m_analog[analogCount]; analogBin.id = ID; analogBin.rect.sX = (UInt16)Rect.X; analogBin.rect.sY = (UInt16)Rect.Y; analogBin.rect.eX = (UInt16)(Rect.Width + analogBin.rect.sX); analogBin.rect.eY = (UInt16)(Rect.Height + analogBin.rect.sY); analogBin.normalClr = (UInt32)NormalColor.ToArgb(); analogBin.normalBgClr = (UInt32)NormalBgColor.ToArgb(); analogBin.overMaxClr = (UInt32)OverMaxColor.ToArgb(); analogBin.overMinClr = (UInt32)OverMinColor.ToArgb(); analogBin.overMaxBgClr = (UInt32)OverMaxBgColor.ToArgb(); analogBin.overMinBgClr = (UInt32)OverMinBgColor.ToArgb(); analogBin.vinfoInvalid = (UInt32)ExceptionColor.ToArgb(); analogBin.vinfoInvalidBg = (UInt32)ExceptionBgColor.ToArgb(); analogBin.vMax = Max; analogBin.vMin = Min; analogBin.font = (Byte)_font.Size; analogBin.nDecimalNum = DecNum; analogBin.enExponent = _isExponent ? (Byte)1 : (Byte)0; ///根据名称来获取地址 var varInstance = SVVaribleType.instance(); analogBin.addrOffset = varInstance.strToAddress(Variable.VarName, Variable.VarBlockType); analogBin.varType = (Byte)varInstance.strToType(Variable.VarName, Variable.VarBlockType); pageArrayBin.pageArray[pageCount].m_analog[analogCount] = analogBin; }