public override void UpdateLinkedVariables() { try { foreach (tblFormalParameter tblformalparameter in tblfunction.m_tblFormalParameterCollection) { if ((tblformalparameter.Class == (int)VarClass.Output) || (tblformalparameter.Class == (int)VarClass.Internal) || (tblformalparameter.Class == (int)VarClass.Local)) { tblVariable temp = new tblVariable(); temp.VarName = tblvariable.VarName + "_" + tblformalparameter.PinName; temp.Class = (int)VarClass.Child; temp.Option = tblformalparameter.Option; temp.Type = tblformalparameter.Type; temp.ParentVarID = tblvariable.VarNameID; temp.ParentVarLinkName = tblformalparameter.PinName; temp.ParentVarLinkID = tblformalparameter.PinID; temp.pouID = this.pouID; //temp.oIndex = tblformalparameter.oIndex; temp.InitialVal = tblformalparameter.InitializeValue; temp.Update(); } } } catch (Exception ex) { MessageBox.Show(ex.Message); DCS.Forms.MainForm.Instance().WriteToOutputWindows("Output variable linked to function " + tblvariable.VarName + " cannot be inserted"); } }
public void SelectVariable() { int i = 0; int j; if (tblpou != null) { SqlConnection _SqlConnectionConnection = new SqlConnection(ConnectionString); SqlDataReader myReader = null; SqlCommand myCommand = new SqlCommand(); //SqlConnectionGlobalConnection = new SqlConnection(); if (_SqlConnectionConnection.State == System.Data.ConnectionState.Open) { _SqlConnectionConnection.Close(); } _SqlConnectionConnection.ConnectionString = ConnectionString; _SqlConnectionConnection.Open(); try { dataGridViewVar.Rows.Clear(); DataGridViewRow row; //dataGridViewVar.AutoGenerateColumns = true; //dataGridViewVar.DataSource = null; myReader = null; //myCommand.CommandText = "SELECT [VarName], [pouID], [Description], [InitialVal], [Type], [Class], [Option], [oIndex] FROM [dbo].[tblVariable] WHERE [pouID]=" + tblpou.pouID + " order by oIndex;"; myCommand.CommandText = "SELECT [VarName], [Description], [InitialVal], [Type], [Class], [Option] FROM [dbo].[tblVariable] WHERE [pouID]=" + tblpou.pouID + " order by oIndex;"; myCommand.Connection = _SqlConnectionConnection; myReader = myCommand.ExecuteReader(); while (myReader.Read()) { tblVariable tblvariable = new tblVariable(); row = (DataGridViewRow)dataGridViewVar.Rows[i++].Clone(); row.Cells[0].Value = (string)myReader["VarName"]; j = (int)myReader["Type"]; row.Cells[1].Value = (VarType)j; row.Cells[2].Value = (VarClass)myReader["Class"]; row.Cells[3].Value = (string)myReader["InitialVal"]; row.Cells[4].Value = (string)myReader["Description"]; row.Cells[5].Value = (VarOption)myReader["Option"]; dataGridViewVar.Rows.Add(row); } //dataGridViewVar.DataSource = myCommand.ExecuteReader(); //myReader.Close(); //myReader.Dispose(); //myCommand.Dispose(); // _SqlConnectionConnection.Close(); } catch (SqlException ae) { MessageBox.Show(ae.Message.ToString()); } } else { dataGridViewVar.Rows.Clear(); } }
public VariableGrid(tblVariable tocopy) { try { this.VarName = tocopy.VarName; this.VarNameID = tocopy.VarNameID; this.pouID = tocopy.pouID; this.Description = tocopy.Description; this.InitialVal = tocopy.InitialVal; this.Type = tocopy.Type; this.Option = (VarOption)tocopy.Option; this.PlantStructureID = tocopy.PlantStructureID; this.DispalyID = tocopy.DispalyID; this.AEB = tocopy.AEB; this.ALB = tocopy.ALB; this.SampleTime = tocopy.SampleTime; this.RTT = tocopy.RTT; this.Interval = tocopy.Interval; this.Archive = tocopy.Archive; this.ArchiveInterval = tocopy.ArchiveInterval; foreach (tblAlarm tblalarm in tocopy.m_tblAlarmCollection) { AlarmObject alarmobject = new AlarmObject(tblalarm); this.m_AlarmCollection.Add(alarmobject); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public CTokenFunction(string _str) { m_token = Token_Type.Token_Function; // _tblformalparameter = new tblFormalParameter(); _tblfunction = new tblFunction(); _tblvariable = new tblVariable(); }
public CTokenVariable(String _str) : base(_str) { m_token = Token_Type.Token_Variable; //m_Value = gcnew VarType(); //m_PropertyType =VarType.UNKNOWN; _tblformalparameter = new tblFormalParameter(); _tblvariable = new tblVariable(); }
private bool Filterd(tblVariable _tblvar) { bool ret = true; //if (_tblvar.Type == (int)comboBoxType.SelectedValue) //{ // return false; //} return(ret); }
//public DrawFunction(int x, int y, tblFunction _tblfunction/*, string _instanseName*/, int _noofextension, TemporayVariable _tempvar/*, long _selectedvarid, long _domainid, long _controllerid, long _pouid*/) public DrawFunction(PageList _parent, int x, int y, tblFunction _tblfunction, tblVariable _tblvariable) : base(_parent) { ShapeType = STATIC_OBJ_TYPE.ID_FBDBoxFunction; tblvariable = _tblvariable; tblfunction = _tblfunction; tblvariable.VarNameID = -1; tblfbdblock.FBDBlockID = -1; Initalize(x, y); GenerateGraphic(); }
public override void AddLinkedVariables() { try { string name; bool exist = false; tblvariable.LoadLinkedVariable(); if (!tblfunction.IsStandard) { foreach (tblFormalParameter tblformalparameter in tblfunction.m_tblFormalParameterCollection) { if ((tblformalparameter.Class == (int)VarClass.Output) || //(tblformalparameter.Class == (int)VarClass.Internal) || (tblformalparameter.Class == (int)VarClass.Local)) { name = tblvariable.VarName + "_" + tblformalparameter.PinName; exist = false; foreach (tblVariable tv in tblvariable.m_tblFInstanceVariableList) { if (tv.VarName == name) { exist = true; break; } } if (!exist) { tblVariable temp = new tblVariable(); temp.VarName = tblvariable.VarName + "_" + tblformalparameter.PinName; //temp.Class = (int)VarClass.Child; temp.Class = (int)tblformalparameter.Class | (int)VarClass.FunctionInstanse; temp.Option = tblformalparameter.Option; temp.Type = tblformalparameter.Type; temp.ParentVarID = tblvariable.VarNameID; temp.ParentVarLinkName = tblformalparameter.PinName; temp.ParentVarLinkID = tblformalparameter.PinID; temp.pouID = tblvariable.pouID; //temp.oIndex = tblformalparameter.oIndex; temp.InitialVal = tblformalparameter.InitializeValue; temp.PlantStructureID = tblSolution.m_tblSolution().AreaLongList[tblSolution.m_tblSolution().GetControllerobjectofPOUID(tblvariable.pouID).ControllerName]; temp.Insert(); tblSolution.m_tblSolution().GetPouFromID(tblvariable.pouID).VariablesByName.Add(temp.VarName.ToLower(), temp); } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); DCS.Forms.MainForm.Instance().WriteToOutputWindows("Output variable linked to function " + tblvariable.VarName + " cannot be inserted"); } }
public DrawVariable(PageList _parent, int x, int y, tblVariable _tblvariable, tblFormalParameter _tblformalparameter, string extendedproperystring /*,bool isextendedproperty,bool isobject*/) : base(_parent) { tblvariable = _tblvariable; tblformalparameter = _tblformalparameter; //this._isobject = isobject; this.ExtendedPropertyTXT = extendedproperystring; //this._isextendedproperty = isextendedproperty; ShapeType = STATIC_OBJ_TYPE.ID_FBDBoxVariable; Initalize(x, y); GenerateGraphic(); }
public BoolVariableGrid(tblVariable tocopy) : base(tocopy) { try { tblBOOL tblbool = new tblBOOL(); tblbool.VarNameID = this.VarNameID; tblbool.SelectVarID(); this.Text0 = tblbool.Text0; this.Text1 = tblbool.Text1; Loaded = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public override bool Load(object obj) { bool ret = false; Dirty = false; tblfbdblock = (tblFBDBlock)obj; SQLID = tblfbdblock.FBDBlockID; NewObject = false; tblvariable.VarNameID = tblfbdblock.VarNameID; tblvariable = tblSolution.m_tblSolution().GetPouFromID(tblfbdblock.VarpouID).GettblVariableVariable(tblfbdblock.VarNameID); if (tblvariable == null) { return(false); } if (tblfbdblock.FunctionID != -1) { tblfunction.FunctionID = tblfbdblock.FunctionID;// = tblSolution.m_tblSolution().m_tblFunctionCollection.GetFunctionbyType(tblvariable.Type); tblfunction.Select(); } FunctionWidth = tblfunction.Width; return(ret); }
public RealVariableGrid(tblVariable tocopy) : base(tocopy) { try { tblREAL tblreal = new tblREAL(); tblreal.VarNameID = this.VarNameID; tblreal.SelectVarID(); this.UNI = tblreal.UNI; this.FOR = tblreal.FOR; this.IRL = tblreal.IRL; this.IRH = tblreal.IRH; this.LL = tblreal.LL; this.HH = tblreal.HH; this.L = tblreal.L; this.H = tblreal.H; Loaded = true; } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public bool IsVariable(string _fcsname, string _pouname, string _variablename, string _propertyname, ref tblVariable _tblvariable, ref tblFormalParameter _tblformalparameter) { string tempstr = ""; int count = 0; foreach (tblController tblcontroller in m_tblControllerCollection) { if (tblcontroller.ControllerName.ToLower() == _fcsname) { if (tblcontroller.IsVariable(_pouname, _variablename, _propertyname, ref _tblvariable, ref _tblformalparameter)) { return(true); } else { return(false); } } } return(false); }
public void Fill(tblVariable _tblvariable, tblFormalParameter _tblformalparameter) { tblvariable = _tblvariable; tblformalparameter = _tblformalparameter; //Operand.Index = _tblvariable.VarNameID; }
public void AddREAL(string filename, string controllername, string pouname) { if (MainForm.Instance().CurrentUser.LogicExplorer != (int)EXPLORER_ACCESS.Full) { System.Windows.Forms.MessageBox.Show("current user cannot add any Contrller"); } if (!File.Exists(filename)) { DCS.Forms.MainForm.Instance().WriteToOutputWindows("File " + filename + " does not exist"); return; } int ControllerNameCol = -1; int pouNameCol = -1; int VarNameCol = -1; int ret = 0; string str; string _log = ""; bool headerline = true; tblREAL tblreal = new tblREAL(); tblController tblcontroller = tblSolution.m_tblSolution().GetControllerFromName(controllername); if (tblcontroller == null) { DCS.Forms.MainForm.Instance().WriteToOutputWindows("Import REAL Error: controller " + controllername + " does not exist in database"); return; } tblPou tblpou = tblcontroller.GetPouFromName(pouname); if (tblpou == null) { DCS.Forms.MainForm.Instance().WriteToOutputWindows("Import REAL Error: pou " + pouname + " does not exist in " + controllername); return; } //var transaction = Common.Conn.BeginTransaction(); using (StreamReader reader = new StreamReader(filename)) { while ((str = reader.ReadLine()) != null) { str.Replace(",,", ", ,"); if (str.StartsWith("!")) { continue; } if (headerline) { tblreal.headerString = str; headerline = false; ControllerNameCol = tblreal.ColumnExistInHeader("ControllerName"); if (ControllerNameCol == -1) { DCS.Forms.MainForm.Instance().WriteToOutputWindows("REAL add error: ControllerName column does not exist in " + filename); break; } pouNameCol = tblreal.ColumnExistInHeader("pouName"); if (pouNameCol == -1) { DCS.Forms.MainForm.Instance().WriteToOutputWindows("REAL add error: pouName column does not exist in " + filename); break; } VarNameCol = tblreal.ColumnExistInHeader("VarName"); if (VarNameCol == -1) { DCS.Forms.MainForm.Instance().WriteToOutputWindows("REAL add error: VarName column does not exist in " + filename); break; } } else { tblreal = new tblREAL(); string[] _strs = str.Split(new Char[] { ',' }); if ((_strs[ControllerNameCol].ToLower() == controllername) && (_strs[pouNameCol].ToLower() == pouname)) { if (tblpou.VariablesByName.ContainsKey(_strs[VarNameCol].ToLower())) { tblVariable tblvariable = tblpou.VariablesByName[_strs[VarNameCol].ToLower()]; tblreal.AddFromString(_strs, _strs[pouNameCol], ref _log); tblreal.VarNameID = tblvariable.VarNameID; if ((ret = tblreal.Insert()) != 0) { if (ret == 19) { DCS.Forms.MainForm.Instance().WriteToOutputWindows(_log + " Already exist in database"); } } } else { DCS.Forms.MainForm.Instance().WriteToOutputWindows("REAL add Error: Varaible " + _strs[VarNameCol] + " does not exist in database"); } } } } reader.Close(); } }
private void PrepareChildRows(tblVariable tblvariable, string _area) { try { string str; string str1; int mode; int state; int status; int bitno; tblFunction tblfunction = tblSolution.m_tblSolution().GetFunctionbyType(tblvariable.Type); mode = tblfunction.Mode; state = tblfunction.state; status = tblfunction.Status; for (int i = 0; i < tblfunction.m_tblFormalParameterCollection.Count; i++) { str = tblfunction.m_tblFormalParameterCollection[i].PinName; switch (str) { case "Mode": if (Common.Variable_ShowMode && (mode != 0)) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); for (int j = 0; j < tblSolution.m_tblSolution().m_tblBlockModeTextCollection.Count; j++) { bitno = tblSolution.m_tblSolution().m_tblBlockModeTextCollection[j].Bit; if (Common.IsBitSet(mode, bitno)) { subperoprty = new Node(str1 + "." + tblSolution.m_tblSolution().m_tblBlockModeTextCollection[j].Txt, tblSolution.m_tblSolution().m_tblBlockModeTextCollection[j].Decsription, "BOOL", _area); property.Children.Add(subperoprty); } } tag.Children.Add(property); } break; case "State": if (Common.Variable_ShowState && (state != 0)) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); for (int j = 0; j < tblSolution.m_tblSolution().m_tblBlockStateTextCollection.Count; j++) { bitno = tblSolution.m_tblSolution().m_tblBlockStateTextCollection[j].Bit; if (Common.IsBitSet(state, bitno)) { subperoprty = new Node(str1 + "." + tblSolution.m_tblSolution().m_tblBlockStateTextCollection[j].Txt, tblSolution.m_tblSolution().m_tblBlockStateTextCollection[j].Decsription, "BOOL", _area); property.Children.Add(subperoprty); } } tag.Children.Add(property); } break; case "ALS": if (Common.Variable_ShowALS && (status != 0)) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); for (int j = 0; j < tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection.Count; j++) { bitno = tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Bit; if (Common.IsBitSet(status, bitno)) { subperoprty = new Node(str1 + "." + tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Txt, tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Decsription, "BOOL", _area); property.Children.Add(subperoprty); } } tag.Children.Add(property); } break; case "ALA": if (Common.Variable_ShowALA && (status != 0)) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); for (int j = 0; j < tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection.Count; j++) { bitno = tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Bit; if (Common.IsBitSet(status, bitno)) { subperoprty = new Node(str1 + "." + tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Txt, tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Decsription, "BOOL", _area); property.Children.Add(subperoprty); } } tag.Children.Add(property); } break; case "ALB": if (Common.Variable_ShowALB && (status != 0)) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); for (int j = 0; j < tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection.Count; j++) { bitno = tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Bit; if (Common.IsBitSet(status, bitno)) { subperoprty = new Node(str1 + "." + tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Txt, tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Decsription, "BOOL", _area); property.Children.Add(subperoprty); } } tag.Children.Add(property); } break; case "AEB": if (Common.Variable_ShowAEB && (status != 0)) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); for (int j = 0; j < tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection.Count; j++) { bitno = tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Bit; if (Common.IsBitSet(status, bitno)) { subperoprty = new Node(str1 + "." + tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Txt, tblSolution.m_tblSolution().m_tblBlockAlarmStatusTextCollection[j].Decsription, "BOOL", _area); property.Children.Add(subperoprty); } } tag.Children.Add(property); } break; case "OPN": if (Common.Variable_ShowOPN) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); tag.Children.Add(property); } break; case "OPH": if (Common.Variable_ShowOPH) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); tag.Children.Add(property); } break; case "OPM": if (Common.Variable_ShowOPM) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); tag.Children.Add(property); } break; case "MNN": if (Common.Variable_ShowMNN) { str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); tag.Children.Add(property); } break; default: str1 = tblvariable.VarName + "." + str; property = new Node(str1, tblfunction.m_tblFormalParameterCollection[i].Description, tblSolution.m_tblSolution().VarTypeStringList[tblfunction.m_tblFormalParameterCollection[i].Type], _area); tag.Children.Add(property); break; } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public tblProgramBodyCollection(tblVariable parent) { m_VarNameID_tblVariable = parent; }
void RowExistIntblVariable(string pinname, string pindescription, string pintype, string pinclass, string pininitialvalue, ref int oIndex) { foreach (tblVariable tblvariable in _tblpou.m_tblVariableCollection) { if (tblvariable.VarName.ToUpper() == pinname.ToUpper()) { tblvariable.Description = pindescription; tblvariable.Type = (int)tblSolution.m_tblSolution().functionbyName[pintype.ToUpper()].Type; if (pinclass == "Input") { tblvariable.Class = (int)VarClass.Input; } if (pinclass == "InOut") { tblvariable.Class = (int)VarClass.InOut; } if (pinclass == "Reference") { tblvariable.Class = (int)VarClass.Input; } if (pinclass == "Output") { tblvariable.Class = (int)VarClass.Output; } if (pinclass == "Local") { tblvariable.Class = (int)VarClass.Local; } tblvariable.InitialVal = pininitialvalue; tblvariable.PlantStructureID = tblSolution.m_tblSolution().Dummytblcontroller.PlantStructureID; tblvariable.Update(); return; } } { tblVariable tblvariable = new tblVariable(); tblvariable.pouID = _tblpou.pouID; tblvariable.VarName = pinname.ToUpper(); tblvariable.Description = pindescription; tblvariable.Type = (int)tblSolution.m_tblSolution().functionbyName[pintype.ToUpper()].Type; if (pinclass == "Input") { tblvariable.Class = (int)VarClass.Input; } if (pinclass == "InOut") { tblvariable.Class = (int)VarClass.InOut; } if (pinclass == "Reference") { tblvariable.Class = (int)VarClass.Input; } if (pinclass == "Output") { tblvariable.Class = (int)VarClass.Output; } if (pinclass == "Local") { tblvariable.Class = (int)VarClass.Local; } tblvariable.InitialVal = pininitialvalue; tblvariable.PlantStructureID = tblSolution.m_tblSolution().Dummytblcontroller.PlantStructureID; tblvariable.Insert(); _tblpou.VariablesByName.Add(tblvariable.VarName.ToLower(), tblvariable); _tblpou.VariablesByName.Remove(tblvariable.VarName); } _tblpou.m_tblVariableCollection = null; }