/// <summary> /// 对变量类型的选择 /// </summary> /// <param Name="sender"></param> /// <param Name="e"></param> void varTypeCombox_SelectedIndexChanged(object sender, EventArgs e) { var index = this.varTypeCombox.SelectedIndex; var instance = SVVaribleType.instance(); DataTable dataTable = new DataTable(); switch (index) { case 0: { dataTable = instance.loadRecvDataTable(); break; } case 1: { dataTable = instance.loadSendDataTable(); break; } case 2: { dataTable = instance.loadSystemDataTable(); break; } } if (_filters != null) { dataTable.DefaultView.RowFilter = _filters; } dataGridView.DataSource = dataTable.DefaultView; }
public void make(ref PageArrayBin pageArrayBin, ref SVSerialize serialize) { UInt32 pageCount = pageArrayBin.pageCount; UInt32 curveCount = pageArrayBin.pageArray[pageCount].trendChartNum++; if (pageArrayBin.pageArray[pageCount].m_trendChart == null) { pageArrayBin.pageArray[pageCount].m_trendChart = new TrendChartBin[SVLimit.PAGE_TCHART_MAXNUM]; } TrendChartBin curveBin = pageArrayBin.pageArray[pageCount].m_trendChart[curveCount]; curveBin.lineClr = new UInt32[4]; curveBin.lineWidth = new Byte[4]; curveBin.addrOffset = new UInt32[4]; curveBin.varType = new Byte[4]; curveBin.keyOffset = new UInt32[3]; curveBin.id = ID; curveBin.rect.sX = (UInt16)Rect.X; curveBin.rect.sY = (UInt16)Rect.Y; curveBin.rect.eX = (UInt16)(Rect.Width + curveBin.rect.sX); curveBin.rect.eY = (UInt16)(Rect.Height + curveBin.rect.sY); //字体颜色 curveBin.scaleClr = (UInt32)FrontColor.ToArgb(); //背景颜色 curveBin.bgClr = (UInt32)BackgdColor.ToArgb(); curveBin.yMin = Min; curveBin.yMax = Max; curveBin.maxTime = Interval; curveBin.font = (Byte)_font.Size; curveBin.stepTime = Step; var varInstance = SVVaribleType.instance(); curveBin.keyOffset[0] = varInstance.strToAddress(ForwardControl.VarName, ForwardControl.VarBlockType); curveBin.keyOffset[1] = varInstance.strToAddress(CurControl.VarName, CurControl.VarBlockType); curveBin.keyOffset[2] = varInstance.strToAddress(BackwardControl.VarName, BackwardControl.VarBlockType); ///编译变量、颜色及使能标志 Int32 nCount = _variable.Count; for (Int32 i = 0; i < nCount; i++) { String name = _variable[i].Var.VarName; Byte type = _variable[i].Var.VarBlockType; curveBin.addrOffset[i] = varInstance.strToAddress(name, type); curveBin.varType[i] = (Byte)varInstance.strToType(name, type); curveBin.lineClr[i] = (UInt32)_variable[i].Color.ToArgb(); curveBin.lineWidth[i] = _variable[i].Enabled ? (Byte)1 : (Byte)0; } ///"SHORT_INT", "SHORTINT_VAR", "INT", "INT_VAR", "REAL", "REAL_VAR" pageArrayBin.pageArray[pageCount].m_trendChart[curveCount] = curveBin; }
public void make(ref PageArrayBin pageArrayBin, ref SVSerialize serialize) { UInt32 pageCount = pageArrayBin.pageCount; UInt32 gifCount = pageArrayBin.pageArray[pageCount].gif_num++; if (pageArrayBin.pageArray[pageCount].m_gif == null) { pageArrayBin.pageArray[pageCount].m_gif = new GifBin[SVLimit.PAGE_GIF_MAXNUM]; } GifBin gifBin = pageArrayBin.pageArray[pageCount].m_gif[gifCount]; gifBin.addOffset = new UInt32[8]; gifBin.varType = new Byte[8]; gifBin.id = ID; gifBin.rect.sX = (UInt16)Rect.X; gifBin.rect.sY = (UInt16)Rect.Y; gifBin.rect.eX = (UInt16)(Rect.Width + gifBin.rect.sX); gifBin.rect.eY = (UInt16)(Rect.Height + gifBin.rect.sY); ///图片数组地址 gifBin.imageOffset = new UInt32[8]; ///保存所有图片数据 List <SVBitmap> list = _pic.imageArray(); for (int i = 0; i < list.Count; i++) { var address = list[i]; gifBin.imageOffset[i] = (UInt32)serialize.ToArray().Length; serialize.pack(address.bitmap8Data(Rect.Width, Rect.Height)); } ///写入当前错误图片数据 var errorAddress = PicError.bitmap8Data(Rect.Width, Rect.Height); if (errorAddress != null) { gifBin.iamgeOffsetErr = (UInt32)serialize.ToArray().Length; serialize.pack(errorAddress); } ///根据名称来获取地址 var varInstance = SVVaribleType.instance(); for (int i = 0; i < _var.Count; i++) { gifBin.addOffset[i] = varInstance.strToAddress(_var[i], _varType[i]); gifBin.varType[i] = (Byte)varInstance.strToType(_var[i], _varType[i]); } ///变量个数 gifBin.type = Convert.ToByte(_var.Count); pageArrayBin.pageArray[pageCount].m_gif[gifCount] = gifBin; }
private DataTable _sendTable = new DataTable(); //发送地址表格 public SVWPFVariableDialog() { InitializeComponent(); var instance = SVVaribleType.instance(); _recvTable = instance.loadRecvDataTable(); _sendTable = instance.loadSendDataTable(); _systemDataTable = instance.loadSystemDataTable(); this.inputDataGrid.ItemsSource = _recvTable.DefaultView; this.outputDataGrid.ItemsSource = _sendTable.DefaultView; this.systemDataGrid.ItemsSource = _systemDataTable.DefaultView; }
void originVarCombobox_SelectedIndexChanged(object sender, EventArgs e) { resultCombobox.Items.Clear(); int index = originVarCombobox.SelectedIndex; if (String.IsNullOrWhiteSpace(_list[index].VarName)) { return; } var varInstance = SVVaribleType.instance(); String type = varInstance.strToTypeString(_list[index].VarName, _list[index].VarBlockType); var nameList = varInstance.varFromStringType(type); resultCombobox.Items.AddRange(nameList.ToArray()); }
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; }
public override void checkValid() { SVPageWidget pageWidget = this.Parent as SVPageWidget; String pageName = pageWidget.PageName; SVUniqueID uniqueObj = SVUniqueID.instance(); if (Attrib.ID <= 0 || Attrib.ID >= uniqueObj.MaxID) { String msg = String.Format("页面 {0} 中,模拟量ID为:{1}, ID值已经超出最大范围[{2} - {3}]", pageName, Attrib.ID, 0, uniqueObj.MaxID); throw new SVCheckValidException(msg); } if (Attrib.Min >= Attrib.Max) { String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 最小值 >= 最大值", pageName, Attrib.ID); throw new SVCheckValidException(msg); } if (!this.Parent.ClientRectangle.Contains(this.Bounds)) { String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 已经超出页面显示范围", pageName, Attrib.ID); throw new SVCheckValidException(msg); } var varInstance = SVVaribleType.instance(); var address = varInstance.strToAddress(Attrib.Variable.VarName, Attrib.Variable.VarBlockType); if ((address & 0x00ffffff) > 48 * 1024) { String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 未正确设置变量", pageName, Attrib.ID); throw new SVCheckValidException(msg); } //var type = (Byte)varInstance.strToType(Attrib.Variable.VarName, Attrib.Variable.VarBlockType); //if (type == 0) //{ // String msg = String.Format("页面 {0} 中, 模拟量ID为:{1}, 变量类型不满足条件", pageName, Attrib.ID); // throw new SVCheckValidException(msg); //} }
public void make(ref PageArrayBin pageArrayBin, ref SVSerialize serialize) { UInt32 pageNum = pageArrayBin.pageCount; UInt32 btnNum = pageArrayBin.pageArray[pageNum].btnNum++; if (pageArrayBin.pageArray[pageNum].m_btn == null) { pageArrayBin.pageArray[pageNum].m_btn = new ButtonBin[SVLimit.PAGE_BTN_MAXNUM]; } ButtonBin btnBin = pageArrayBin.pageArray[pageNum].m_btn[btnNum]; btnBin.id = ID; btnBin.rect.sX = (UInt16)Rect.X; btnBin.rect.sY = (UInt16)Rect.Y; btnBin.rect.eX = (UInt16)(Rect.Width + btnBin.rect.sX); btnBin.rect.eY = (UInt16)(Rect.Height + btnBin.rect.sY); btnBin.fontClr = (UInt32)FrontColorground.ToArgb(); ///为真的文本 btnBin.text = new Byte[SVLimit.BTN_MAX_LEN]; copyDestByteArray(Encoding.Unicode.GetBytes(Text), btnBin.text); ///为假的文本 btnBin.fText = new Byte[SVLimit.BTN_MAX_LEN]; copyDestByteArray(Encoding.Unicode.GetBytes(FText), btnBin.fText); ///备注信息 btnBin.fMemo = new Byte[SVLimit.BTN_MAX_LEN]; copyDestByteArray(Encoding.Unicode.GetBytes(FMemo), btnBin.fMemo); btnBin.font = (Byte)_font.Size; //是否有确认窗口 btnBin.confirm = Comfirm ? (byte)1 : (byte)0; //按钮的类型 if (_buttonType == 0) { btnBin.type = 0; btnBin.param.pageId = _btnType.PageID; } else { var varInstance = SVVaribleType.instance(); btnBin.param.addrOffset = varInstance.strToAddress(_btnVarText.VarName, _btnVarText.VarBlockType); btnBin.varTypeBtn = (Byte)varInstance.strToType(_btnVarText.VarName, _btnVarText.VarBlockType); btnBin.type = _buttonType; btnBin.enable = Convert.ToByte(_btnEnable); btnBin.enableAddrOffset = varInstance.strToAddress(_enVarText.VarName, _enVarText.VarBlockType); btnBin.varTypeEn = (Byte)varInstance.strToType(_enVarText.VarName, _enVarText.VarBlockType); } ///显示背景图片或者显示背景颜色 if (!IsShowPic) { btnBin.bgUpFlag = 0; btnBin.bgDownFlag = 0; btnBin.bgUpColor = (UInt32)BackColorground.ToArgb(); btnBin.bgDownColor = (UInt32)BackColorgroundDown.ToArgb(); } else { btnBin.bgUpFlag = 1; btnBin.bgDownFlag = 1; //设置弹起图片 var upAddress = BtnUpPic.bitmap8Data(Rect.Width, Rect.Height); if (upAddress != null) { btnBin.bgUpColor = (UInt32)serialize.ToArray().Length; serialize.pack(upAddress); } //设置按下图片 var downAddress = BtnDownPic.bitmap8Data(Rect.Width, Rect.Height); if (downAddress != null) { btnBin.bgDownColor = (UInt32)serialize.ToArray().Length; serialize.pack(downAddress); } } pageArrayBin.pageArray[pageNum].m_btn[btnNum] = btnBin; }
/// <summary> /// 生成下装文件 /// </summary> /// <param oldName="pageArrayBin">下装配置文件</param> /// <param oldName="serialize">序列化对象</param> public void make(ref PageArrayBin pageArrayBin, ref SVSerialize serialize) { UInt32 pageCount = pageArrayBin.pageCount; UInt32 binaryCount = pageArrayBin.pageArray[pageCount].binaryNum++; if (pageArrayBin.pageArray[pageCount].m_binary == null) { pageArrayBin.pageArray[pageCount].m_binary = new BinaryBin[SVLimit.PAGE_BOOL_MAXNUM]; } BinaryBin binaryBin = pageArrayBin.pageArray[pageCount].m_binary[binaryCount]; binaryBin.id = ID; binaryBin.rect.sX = (UInt16)Rect.X; binaryBin.rect.sY = (UInt16)Rect.Y; binaryBin.rect.eX = (UInt16)(Rect.Width + binaryBin.rect.sX); binaryBin.rect.eY = (UInt16)(Rect.Height + binaryBin.rect.sY); binaryBin.font = (Byte)_font.Size; binaryBin.type = _type; ///存放字符串相关的属性和文本信息 if (_type == 0) { binaryBin.trueClr = (UInt32)TrueColor.ToArgb(); binaryBin.trueBgClr = (UInt32)TrueBgColor.ToArgb(); binaryBin.falseClr = (UInt32)FalseColor.ToArgb(); binaryBin.falseBgClr = (UInt32)FalseBgColor.ToArgb(); binaryBin.vinfoInvalid = (UInt32)ExceptionColor.ToArgb(); binaryBin.vinfoInvalidBg = (UInt32)ExceptionBgColor.ToArgb(); binaryBin.trueText = new Byte[SVLimit.BINARY_MAX_LEN]; if (CustomTrueText != null) { copyDestByteArray(Encoding.Unicode.GetBytes(CustomTrueText), binaryBin.trueText); } binaryBin.falseText = new Byte[SVLimit.BINARY_MAX_LEN]; if (CustomFlaseText != null) { copyDestByteArray(Encoding.Unicode.GetBytes(CustomFlaseText), binaryBin.falseText); } } else ///存放与背景图片有关的信息 { ///为真的图片地址 var trueAddress = this.TruePicture.bitmap8Data(Rect.Width, Rect.Height); if (trueAddress != null) { binaryBin.trueClr = (UInt32)serialize.ToArray().Length; serialize.pack(trueAddress); } ///为假的图片地址 var falseAddress = this.FlasePicture.bitmap8Data(Rect.Width, Rect.Height); if (falseAddress != null) { binaryBin.falseClr = (UInt32)serialize.ToArray().Length; serialize.pack(falseAddress); } ///异常的图片地址 var exAddress = this.ExPicture.bitmap8Data(Rect.Width, Rect.Height); if (exAddress != null) { binaryBin.vinfoInvalid = (UInt32)serialize.ToArray().Length; serialize.pack(exAddress); } } ///根据名称来获取地址 var varInstance = SVVaribleType.instance(); binaryBin.addrOffset = varInstance.strToAddress(_var.VarName, _var.VarBlockType); binaryBin.varType = (Byte)varInstance.strToType(_var.VarName, _var.VarBlockType); pageArrayBin.pageArray[pageCount].m_binary[binaryCount] = binaryBin; }