Example #1
0
        private void button3_Click(object sender, EventArgs e)
        {
            this.Enabled = false;
            try
            {
                mdbTreeNet1.serverList[0] = ServerName;
                mdbTreeNet1.resetTree();
                mdbTreeNet1.setRootModules(new string[] { @"\\" + ServerName + @"\" + ModuleRoot });
                //mdbTreeNet1.sel

                if (false)
                {
                    ServerManagerClass srvMgr = new ServerManagerClass();

                    PIModuleDB ModuleDb = srvMgr.PISDK.Servers[ServerName].PIModuleDB;

                    //treeView1.Nodes.Clear();
                    PIModule module = ModuleDb.PIModules[ModuleRoot];
                    connect.treeNode = new TreeNode(module.Name);
                    //int i = treeView1.Nodes.Add(connect.treeNode);
                    TreeNode tNode = new TreeNode();
                    //tNode = treeView1.Nodes[i];
                    AddNode(module, tNode);
                }
            }
            catch { this.Enabled = true; }
            this.Enabled = true;
        }
Example #2
0
        private void textBox3_KeyPress_1(object sender, KeyPressEventArgs e)
        {
            if ((int)e.KeyChar == 13)
            {
                button2_Click(null, null);
            }
            if ((int)e.KeyChar == 22)
            {
                // ������� ��� � ������)
                IDataObject d = Clipboard.GetDataObject();

                if (d.GetDataPresent(DataFormats.Text))
                {
                    string s = (String)d.GetData(DataFormats.UnicodeText);

                    /*
                     * //����� :(
                     * ServerManagerClass srvMgr = new ServerManagerClass();
                     * PI3PIPointClass point = srvMgr.PISDK.Servers[ServerName].GetPointsSQL(string.Format("PIpoint.SourceTag = '{0}'", s));
                     */
                    string[] b = s.Split(new char[] { ':' });
                    s = "";
                    for (int i = b.Length - 1, count = 0; i >= 0; i--)
                    {
                        count++;
                        if (i == 0)
                        {
                            s = b[i] + s;
                        }
                        else
                        {
                            s = (count == 6) ? ".ALARM:" + b[i] + s : ":" + b[i] + s;
                        }
                    }
                    // ��������� ���� �� ���
                    ServerManagerClass srvMgr = new ServerManagerClass();
                    try
                    {
                        PIPoint point = srvMgr.PISDK.Servers[ServerName].PIPoints[s];
                        Clipboard.SetDataObject(s);
                        textBox3.Text = s;
                        button2_Click(null, null);
                        textBox3.Text = "";
                    }
                    catch
                    {
                        MessageBox.Show(string.Format("tag not found '{0}'", s));
                    }
                }
            }
        }
Example #3
0
        private void updateAlarms()
        {
            ServerManagerClass srvMgr   = new ServerManagerClass();
            PIModuleDB         ModuleDb = srvMgr.PISDK.Servers[ServerName].PIModuleDB;
            PIModule           module   = ModuleDb.PIModules[ModuleRoot];
            PIProperty         property;

            string[] arrayModule = textBox1.Text.Split('\\');
            for (int i = 0; i < arrayModule.Length; i++)
            {
                module = module.PIModules[arrayModule[i]];
            }
            try {
                property = module.PIProperties["%meta"];
            }
            catch {
                property = module.PIProperties.Add("%meta", null);
                property.PIProperties.Add("Class", "������������� ������");
                property.PIProperties.Add("ModeVisualization", null);
                property.PIProperties.Add("Position", "Position");
                property.PIProperties.Add("ShowInAlarmList", "True");
                property.PIProperties.Add("StateSource", "Manual");
                property.PIProperties.Add("Tags", null);
                property.PIProperties.Add("��������", "��������");
            }
            try
            {
                AlarmsNode = property.PIProperties["Alarms"];
            }
            catch
            {
                AlarmsNode = property.PIProperties.Add("Alarms", null);
            }
            listBox1.Items.Clear();
            for (int i = 1; i <= AlarmsNode.PIProperties.Count; i++)
            {
                listBox1.Items.Add(new gPIProperty(AlarmsNode.PIProperties[i]));
            }
        }
Example #4
0
        private void MainExecuteEx(PBObjLib.Symbol SymbolValue)
        {
            string tagName;

            tagName = SymbolValue.GetTagName(1);

            double fMin = 0, fMax = 0;

            if (textBox1.Text != "")
            {
                fMin = Convert.ToDouble(textBox1.Text
                                        .Replace(".", ",")
                                        .Replace("/", ",")
                                        .Replace("?", ",")
                                        .Replace(">", ",")
                                        .Replace("�", ","));
            }
            if (textBox2.Text != "")
            {
                fMax = Convert.ToDouble(textBox2.Text
                                        .Replace(".", ",")
                                        .Replace("/", ",")
                                        .Replace("?", ",")
                                        .Replace(">", ",")
                                        .Replace("�", ","));
            }

            double tagZero = 0, tagSpan = 0;

            SymbolValue.BackgroundColor = -1;
            ServerManagerClass srvMgr = new ServerManagerClass();
            Server             server = srvMgr.PISDK.Servers[(tagName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries))[0]];
            PIPoint            pt     = server.PIPoints[(tagName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries))[1]];

            if (fMin > 0)
            {
                tagZero = 0;
                tagSpan = fMax + 100;
            }
            else
            {
                tagZero = fMin - 100;
                tagSpan = fMax + (fMin * -1) + 200;// Math.Floor(((fMax - fMin) * 1.5));
            }
            pt.PointAttributes.ReadOnly      = false;
            pt.PointAttributes["Zero"].Value = tagZero;
            pt.PointAttributes["Span"].Value = tagSpan;
            pt.PointAttributes.ReadOnly      = true;

            //pt.s

            Symbol tmpRect;

            tmpRect = SymbolValue.Application.ActiveDisplay.Symbols.Add(PBObjLib.pbSYMBOLTYPE.pbSymbolRectangle, "");

            tmpRect.Width     = SymbolValue.Width;
            tmpRect.Height    = SymbolValue.Height;
            tmpRect.Top       = SymbolValue.Top;
            tmpRect.Left      = SymbolValue.Left;
            tmpRect.LineColor = -1;

            tmpRect.CreateMultiState(tagName);
            PBObjLib.MultiState tMState = tmpRect.GetMultiState();



            int stateCount = 1;// As Integer

            if (fMax != 0)
            {
                stateCount = stateCount + 1;
            }

            if (fMin != 0)
            {
                stateCount = stateCount + 1;
            }

            tMState.StateCount = stateCount;
            //double tagSpan = 100; // � ����� ������� �� ����))
            MSState MyState;// As MSState

            if (stateCount == 2)
            {
                if (textBox1.Text == "")
                {
                    tMState.DefineState(1, tagZero, fMax);
                    tMState.DefineState(2, fMax, tagZero + tagSpan);    //'������������ �������� ���� (span)
                    MyState = tMState.GetState(1);
                    MyState.DefineState(tagZero, fMax, 32768);          //'�������
                    MyState = tMState.GetState(2);
                    MyState.DefineState(fMax, MyState.UpperValue, 255); //'������
                }
                else
                {
                    tMState.DefineState(1, tagZero, fMin);
                    tMState.DefineState(2, fMin, tagSpan);                //'������������ �������� ���� (span)
                    MyState = tMState.GetState(1);
                    MyState.DefineState(tagZero, fMin, 255);              //'�������
                    MyState = tMState.GetState(2);
                    MyState.DefineState(fMin, MyState.UpperValue, 32768); // '������
                }
            }

            if (stateCount == 3)
            {
                tMState.DefineState(1, 0, fMin);
                tMState.DefineState(2, fMin, fMax);
                tMState.DefineState(3, fMax, tagZero + tagSpan);
                MyState       = tMState.GetState(1);
                MyState.Color = 255;   //DefineState(tagZero, fMin, 255);//'�������
                MyState       = tMState.GetState(2);
                MyState.Color = 32768; //DefineState(fMin, fMax, 32768); //'������
                MyState       = tMState.GetState(3);
                MyState.Color = 255;
            }
            int lCnt = tmpRect.Layers.Count;

            if (lCnt > 0)
            {
                tmpRect.Layers.Item(lCnt).LayerSymbols.Remove(tmpRect.Name);
                SymbolValue.Layers.AddSymbol(SymbolValue.Name);
            }
            this.Close();
        }