예제 #1
0
        private void WriteDataRecieved(bool DataOk, ushort[] ParamRTU, object param)
        {
            if (InvokeRequired)
            {
                Invoke(new AsynchSerialPort.DataRecievedRTU(WriteDataRecieved), DataOk, ParamRTU, null);
            }
            else
            {
                if (DataOk)
                {
                    toolStripStatusLabel1.Visible = true;
                    toolStripStatusLabel1.Text    = appTexts.ParameterName(50);

                    if (checkBox1.Checked)
                    {
                        serialPort.SetDataRTU(0x1106, null, RequestPriority.Normal, 1);
                    }
                }
                else
                {
                    toolStripStatusLabel1.Visible = true;
                    toolStripStatusLabel1.Text    = appTexts.ParameterName(51);
                }
                //portBusy = false;
            }
        }
        private void button1_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show(appTexts.ParameterName(88), "", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                DialogResult = System.Windows.Forms.DialogResult.No;
                short[] us = new short[7];
                try
                {
                    us[0] = ConvertFuncs.StrToShort(textBox1.Text);
                    us[1] = ConvertFuncs.StrToShort(textBox2.Text);
                    us[2] = ConvertFuncs.StrToShort(textBox3.Text);
                    us[3] = ConvertFuncs.StrToShort(textBox4.Text);
                    us[4] = ConvertFuncs.StrToShort(textBox5.Text);
                    us[5] = ConvertFuncs.StrToShort(textBox6.Text);
                    us[6] = ConvertFuncs.StrToShort(textBox7.Text);
                }
                catch
                {
                    MessageBox.Show(appTexts.ParameterName(89), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                systemConfiguration.StartMeasureAddr  = (ushort)us[0];
                systemConfiguration.EventCodeAddr     = (ushort)us[1];
                systemConfiguration.EventTimeAddr     = (ushort)us[2];
                systemConfiguration.EventBlockCount   = (ushort)us[3];
                systemConfiguration.LoadEventAddr     = (ushort)us[4];
                systemConfiguration.LoadEventDataAddr = (ushort)us[5];
                systemConfiguration.EventCount        = (ushort)us[6];
            }
        }
예제 #3
0
        private void warnsButton_ButtonClick(object sender, EventArgs e)
        {
            WarningConfigForm wcf = new WarningConfigForm(Texts.ParameterName(90), notifyIcon1.Icon, Texts, "WarningStrings");

            wcf.SetWarningParams(systemConfiguration.WarningParams);
            wcf.ShowDialog();
            systemConfiguration.WarningParams = wcf.GetWarningParams();
        }
예제 #4
0
 public LoadScopeForm(AppTexts AppTexts, AsynchSerialPort AsynchSerialPort)
 {
     InitializeComponent();
     serialPort = AsynchSerialPort;
     Texts      = AppTexts;
     Text       = AppTexts.ParameterName(39);
     setupButton.ToolTipText  = AppTexts.ParameterName(43);
     recordButton.ToolTipText = AppTexts.ParameterName(44);
 }
 public AskScopeForm(AppTexts AppTexts, string OscTitl, ushort OscStatus)
 {
     InitializeComponent();
     label1.Text     = OscTitl;
     button1.Text    = AppTexts.ParameterName(40);
     button1.Enabled = (OscStatus >= 4);
     button2.Text    = AppTexts.ParameterName(41);
     button3.Text    = AppTexts.ParameterName(42);
 }
        public OtherParamsForms(AppTexts AppTexts, SystemConfiguration SystemConfiguration)
        {
            InitializeComponent();
            appTexts            = AppTexts;
            this.Text           = AppTexts.ParameterName(81);
            systemConfiguration = SystemConfiguration;

            label1.Text = AppTexts.ParameterName(82);
            label2.Text = AppTexts.ParameterName(83);
            label3.Text = AppTexts.ParameterName(84);
            label4.Text = AppTexts.ParameterName(85);
            label5.Text = AppTexts.ParameterName(86);
            label6.Text = AppTexts.ParameterName(87);
            label7.Text = AppTexts.ParameterName(91);

            textBox1.Text = "0x" + systemConfiguration.StartMeasureAddr.ToString("X4");
            textBox2.Text = "0x" + systemConfiguration.EventCodeAddr.ToString("X4");
            textBox3.Text = "0x" + systemConfiguration.EventTimeAddr.ToString("X4");
            textBox4.Text = "0x" + systemConfiguration.EventBlockCount.ToString("X4");
            textBox5.Text = "0x" + systemConfiguration.LoadEventAddr.ToString("X4");
            textBox6.Text = "0x" + systemConfiguration.LoadEventDataAddr.ToString("X4");
            textBox7.Text = systemConfiguration.EventCount.ToString();

            digInBtn.Text       = appTexts.ParameterName(108);        SetButtonColor(digInBtn, systemConfiguration.EnaDigits);
            directAccBtn.Text   = appTexts.ParameterName(45);     SetButtonColor(directAccBtn, systemConfiguration.EnaDirectAccess);
            floatDirAccBtn.Text = appTexts.ParameterName(4);    SetButtonColor(floatDirAccBtn, systemConfiguration.EnaFloatDirectAccess);
            scopeBtn.Text       = appTexts.ParameterName(39);         SetButtonColor(scopeBtn, systemConfiguration.EnaScope);
            symsBtn.Text        = appTexts.ParameterName(17);          SetButtonColor(symsBtn, systemConfiguration.EnaLoadSyms);
            eventLogBtn.Text    = appTexts.ParameterName(99);      SetButtonColor(eventLogBtn, systemConfiguration.EnaEventLog);
            jogBtn.Text         = appTexts.ParameterName(111);           SetButtonColor(jogBtn, systemConfiguration.EnaJog);
            angleBtn.Text       = appTexts.ParameterName(120);         SetButtonColor(angleBtn, systemConfiguration.EnaAngle);
            forceDigBtn.Text    = appTexts.ParameterName(122);      SetButtonColor(forceDigBtn, systemConfiguration.EnaForceDig);
        }
예제 #7
0
 public EventLogForm(AppTexts AppTexts, AsynchSerialPort AsynchSerialPort, SystemConfiguration SystemConfiguration)
 {
     InitializeComponent();
     this.Text                      = AppTexts.ParameterName(99);
     loadEventButton.Text           = AppTexts.ParameterName(100);
     openFileButton.ToolTipText     = AppTexts.ParameterName(105);
     loadSensorPanelBtn.ToolTipText = AppTexts.ParameterName(109);
     appTexts            = AppTexts;
     serialPort          = AsynchSerialPort;
     systemConfiguration = SystemConfiguration;
 }
 public AngleForm(AsynchSerialPort AsynchSerialPort, AppTexts AppTexts)
 {
     //toolStripStatusLabel1.Text = "";
     InitializeComponent();
     appTexts         = AppTexts;
     serialPort       = AsynchSerialPort;
     Text             = appTexts.ParameterName(120);
     writeBtn1.Text   = appTexts.ParameterName(117);
     curLabel.Text    = appTexts.ParameterName(115);
     newLabel.Text    = appTexts.ParameterName(116);
     paramLabel1.Text = appTexts.ParameterName(121);
 }
예제 #9
0
        //************************ЗАГРУЗКА НОВОГО ТИПА СИСТЕМ*********************************************//
        //************************************************************************************************//
        private void loadSysTypeBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = AppTexts.ParameterName(102);
            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                systemConfiguration = new SystemConfiguration();
                systemConfiguration.LoadFromFile(ofd.FileName);
                InitSystemConfig();
            }
        }
예제 #10
0
        public EventCodesForm(AppTexts AppTexts, Hashtable EventCodes)
        {
            InitializeComponent();
            appTexts  = AppTexts;
            this.Text = AppTexts.ParameterName(76);
            dataGridView1.Columns[0].HeaderText = AppTexts.ParameterName(77);
            dataGridView1.Columns[1].HeaderText = AppTexts.ParameterName(78);

            string[] keys = EventCodes.Keys.Cast <string>().ToArray();
            Array.Sort(keys);

            foreach (string s in keys)
            {
                object[] values = { s, EventCodes[s].ToString() };
                dataGridView1.Rows.Add(values);
            }
        }
예제 #11
0
 public LoadOscDataForm(AsynchSerialPort AsynchSerialPort, string Titl, ScopeConfig ScopeConfig, int LoadOscNum, AppTexts AppTexts)
 {
     InitializeComponent();
     serialPort       = AsynchSerialPort;
     this.Text        = Titl;
     this.scopeConfig = ScopeConfig;
     loadOscNum       = LoadOscNum;
     InitLoadOscillAsynch();
     button1.Text = AppTexts.ParameterName(27);
 }
예제 #12
0
 public SystemConfiguratorForm(AppTexts AppTexts, SystemConfiguration SystemConfiguration)
 {
     InitializeComponent();
     systemConfiguration = SystemConfiguration;
     NewSystemConfigFlag = false;
     Texts = AppTexts;
     digitLabelButton.Title    = Texts.ParameterName(71);
     timeLabelButton.Title     = Texts.ParameterName(72);
     measureButton.Title       = Texts.ParameterName(75);
     eventsBtn.Title           = Texts.ParameterName(76);
     warnsButton.Title         = Texts.ParameterName(79);
     alarmsButton.Title        = Texts.ParameterName(80);
     addrsButton.Title         = Texts.ParameterName(81);
     defaultButton.ToolTipText = Texts.ParameterName(104);
     readyButton.Title         = Texts.ParameterName(110);
 }
 public DigitPlateForm(AsynchSerialPort AsynchSerialPort, AppTexts AppTexts, DigitPlate DigitPlate, bool EnableForce = true)
 {
     InitializeComponent();
     CreateLampLabels();
     CreateNameLabels(DigitPlate);
     if (true)
     {
         CreateCheckBoxs();
     }
     this.Text      = DigitPlate.Titl;
     startAddr      = DigitPlate.StartAddr;
     serialPort     = AsynchSerialPort;
     invert         = DigitPlate.Invert;
     label1.Text    = label3.Text = AppTexts.ParameterName(73);
     label2.Text    = label4.Text = AppTexts.ParameterName(74);
     label1.Visible = label2.Visible = label3.Visible = label4.Visible = (orCheckBoxs[0] != null);
     if (DigitPlate.DigitType == DigitType.DigOutput)
     {
         this.BackColor = Color.White;
     }
 }
 private void WriteDataRecieved(bool DataOk, ushort[] ParamRTU, object param)
 {
     if (InvokeRequired)
     {
         Invoke(new AsynchSerialPort.DataRecievedRTU(WriteDataRecieved), DataOk, ParamRTU, null);
     }
     else
     {
         if (DataOk)
         {
             toolStripStatusLabel1.Visible = true;
             toolStripStatusLabel1.Text    = appTexts.ParameterName(50);
         }
         else
         {
             toolStripStatusLabel1.Visible = true;
             toolStripStatusLabel1.Text    = appTexts.ParameterName(51);
         }
         //portBusy = false;
     }
 }
 public DownloadSYMForm(AsynchSerialPort AsynchSerialPort, AppTexts AppTexts)
 {
     InitializeComponent();
     serialPort   = AsynchSerialPort;
     appTexts     = AppTexts;
     Text         = appTexts.ParameterName(17);
     label1.Text  = appTexts.ParameterName(54);
     label2.Text  = appTexts.ParameterName(55);
     button1.Text = appTexts.ParameterName(56);
     button2.Text = appTexts.ParameterName(57);
     button3.Text = appTexts.ParameterName(58);
 }
        public DirectAccessForm(AsynchSerialPort AsynchSerialPort, AppTexts AppTexts)
        {
            InitializeComponent();
            appTexts            = AppTexts;
            serialPort          = AsynchSerialPort;
            Text                = appTexts.ParameterName(45);
            writeBtn.Text       = appTexts.ParameterName(9);
            readBtn.Text        = appTexts.ParameterName(8);
            addrLabel.Text      = appTexts.ParameterName(5);
            valueHexLabel.Text  = appTexts.ParameterName(46);
            i160ValueLabel.Text = appTexts.ParameterName(48);
            u160ValueLabel.Text = appTexts.ParameterName(47);

            formatComboBox.Items.Clear();

            for (int i = 0; i < (int)ConvertFormats.FormatCount; i++)
            {
                formatComboBox.Items.Add(((ConvertFormats)i).ToString());
            }

            formatComboBox.SelectedIndex = 0;
        }
        //***************************ЗАПИСЬ ДАННЫХ****************************************************************//
        //********************************************************************************************************//
        private void writeBtn_Click(object sender, EventArgs e)
        {
            if (portBusy)
            {
                return;
            }


            if (!CheckAddr())
            {
                MessageBox.Show(appTexts.ParameterName(10), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!CheckValue())
            {
                MessageBox.Show(appTexts.ParameterName(49), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            portBusy = true;
            serialPort.SetDataRTU(addr, WriteDataRecieved, RequestPriority.Normal, value);
        }
예제 #18
0
        private void loadEventButton_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog();

            sfd.DefaultExt = "*.xml";
            sfd.Filter     = appTexts.ParameterName(102);
            sfd.FileName   = DateTime.Now.Day.ToString("D2") + "." + DateTime.Now.Month.ToString("D2") + "." + DateTime.Now.Year.ToString("D4") + " " +
                             DateTime.Now.Hour.ToString("D2") + "." + DateTime.Now.Minute.ToString("D2") + "." + DateTime.Now.Second.ToString("D2") +
                             " (" + appTexts.ParameterName(99) + ")";

            if (sfd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                loadEventButton.Enabled = false;
                fileName = sfd.FileName;

                progressBar1.Value              = 0;
                progressBar1.Minimum            = 0;
                progressBar1.Maximum            = systemConfiguration.EventCount;
                eventLogLoader                  = new EventLogLoader(serialPort, systemConfiguration.EventBlockCount, systemConfiguration.LoadEventDataAddr, systemConfiguration.LoadEventAddr, systemConfiguration.EventCount);
                eventLogLoader.LoadindComplete += LoadingComplete;
                eventLogLoader.ProcessUpdate   += LoadingProcess;
                eventLogLoader.StartLoading();
            }
        }
        public EventlogViewerForm(string FileName, AppTexts AppTexts)
        {
            InitializeComponent();
            this.Text = AppTexts.ParameterName(99) + " - " + FileName;
            XDocument document;
            XElement  element;

            try
            {
                document = XDocument.Load(FileName);
            }
            catch
            {
                throw new Exception("Error open xml file!");
            }

            try
            {
                element = document.Root.Element("EventLogSetup");
            }
            catch
            {
                throw new Exception("Errors in xml file!");
            }

            int eventCount = 0;

            try
            {
                eventCount = Convert.ToInt16(element.Attribute("EventCount").Value.ToString(), 10);
            }
            catch
            {
                eventCount = 0;
                throw new Exception("Invalid event count in xml file!");
            }

            tableLayoutPanel1.RowCount = eventCount + 1;
            for (int i = 0; i < tableLayoutPanel1.RowCount; i++)
            {
                tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
            }

            foreach (RowStyle style in tableLayoutPanel1.RowStyles)
            {
                style.SizeType = SizeType.AutoSize;
            }


            tableLayoutPanel1.RowStyles[eventCount].SizeType = SizeType.Absolute;
            tableLayoutPanel1.RowStyles[eventCount].Height   = 0;
            //  MessageBox.Show(tableLayoutPanel1.RowCount.ToString());

            for (int i = 0; i < eventCount; i++)
            {
                // tableLayoutPanel1.RowStyles.Add(new RowStyle(SizeType.AutoSize));
                eventViewer        = new EventViewer(i, FileName, AppTexts);
                eventViewer.Dock   = DockStyle.Fill;
                eventViewer.Margin = new System.Windows.Forms.Padding(0, 4, 0, 4);
                tableLayoutPanel1.Controls.Add(eventViewer);
                tableLayoutPanel1.SetRow(eventViewer, i);
            }
        }
예제 #20
0
        //******************ЗАГРУЗКА ИЗ ФАЙЛА СТАРОГО ФОРМАТА**********************************//
        //*************************************************************************************//
        //*************************************************************************************//
        private void openOldStyleButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter     = appTexts.ParameterName(102);
            ofd.DefaultExt = "*.xml";

            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            XDocument document;
            XElement  element;
            int       eventCount;

            try
            {
                document = XDocument.Load(ofd.FileName);
            }

            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                element    = document.Root.Element("EventLogSetup");
                eventCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            Hashtable loadEventTypes = new Hashtable();

            for (int i = 0; i < eventCount; i++)
            {
                try
                {
                    element = document.Root.Element("EventType" + (i + 1).ToString());
                    string str1 = element.Attribute("Code").Value.ToString();
                    string str2 = element.Attribute("Name").Value.ToString();

                    loadEventTypes.Add(str1, str2);
                }
                catch
                {
                    MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            dataGridView1.Rows.Clear();
            string[] keys = loadEventTypes.Keys.Cast <string>().ToArray();
            Array.Sort(keys);

            foreach (string s in keys)
            {
                object[] values = { s, loadEventTypes[s].ToString() };
                dataGridView1.Rows.Add(values);
            }
        }
        public EventViewer(int EventNum, string XmlFileName, AppTexts AppTexts)
        {
            InitializeComponent();
            this.Height   = button1.Top + button1.Height + 2;
            button1.Image = imageList1.Images[0];
            XDocument document;
            XElement  element;

            dataGridView1.Columns.Add("Col 1", AppTexts.ParameterName(75)); dataGridView1.Columns[0].Width = 200;
            dataGridView1.Columns.Add("Col 2", AppTexts.ParameterName(94)); dataGridView1.Columns[1].Width = 70;
            dataGridView1.Columns.Add("Col 3", AppTexts.ParameterName(95)); dataGridView1.Columns[2].Width = 200;
            dataGridView1.Columns.Add("Col 4", AppTexts.ParameterName(96)); dataGridView1.Columns[3].Width = 200;
            dataGridView1.Columns.Add("Col 5", AppTexts.ParameterName(97)); dataGridView1.Columns[4].Width = 200;
            dataGridView1.Columns.Add("Col 6", AppTexts.ParameterName(98)); dataGridView1.Columns[5].Width = 200;

            #region ОТкрытие файла
            try
            {
                document = XDocument.Load(XmlFileName);
            }
            catch
            {
                throw new Exception("Error open xml file!");
            }

            try
            {
                element = document.Root.Element("Event" + (EventNum).ToString());
            }
            catch
            {
                throw new Exception("Errors in xml file!");
            }
            #endregion

            #region Тип события и время
            try
            {
                titlLabel.Text = AppTexts.ParameterName(93) + (EventNum + 1).ToString() + ". " +
                                 element.Attribute("Type").Value.ToString();
                timeLabel.Text = element.Attribute("Time").Value.ToString();
            }
            catch
            {
                throw new Exception("Errors in xml file!");
            }
            #endregion

            #region Измеряемые параметры
            int measureCount = 0;
            try
            {
                measureCount = Convert.ToInt16(element.Attribute("MeasureCount").Value.ToString(), 10);
            }
            catch
            {
                measureCount = 0;
            }

            for (int i = 0; i < measureCount; i++)
            {
                string str1 = element.Attribute("MeasureName" + i.ToString()).Value.ToString();
                string str2 = element.Attribute("Measure" + i.ToString()).Value.ToString();
                SetCell(0, i, str1);
                SetCell(1, i, str2);
            }
            #endregion

            #region Дискретные входы
            int digInCount = 0;
            try
            {
                digInCount = Convert.ToInt16(element.Attribute("DigInCount").Value.ToString(), 10);
            }
            catch
            {
                digInCount = 0;
            }

            for (int i = 0; i < digInCount; i++)
            {
                string str1 = element.Attribute("DigInName" + i.ToString()).Value.ToString();
                string str2 = element.Attribute("DigInValue" + i.ToString()).Value.ToString();
                SetCell(2, i, str1);
                if (str2.ToUpper() == "TRUE")
                {
                    dataGridView1.Rows[i].Cells[2].Style.BackColor = Color.LightGreen;
                }
            }

            #endregion

            #region Дискретные выходы
            int digOutCount = 0;
            try
            {
                digOutCount = Convert.ToInt16(element.Attribute("DigOutCount").Value.ToString(), 10);
            }
            catch
            {
                digOutCount = 0;
            }

            for (int i = 0; i < digOutCount; i++)
            {
                string str1 = element.Attribute("DigOutName" + i.ToString()).Value.ToString();
                string str2 = element.Attribute("DigOutValue" + i.ToString()).Value.ToString();
                SetCell(3, i, str1);
                if (str2.ToUpper() == "TRUE")
                {
                    dataGridView1.Rows[i].Cells[3].Style.BackColor = Color.LightGreen;
                }
            }

            #endregion

            #region Предупреждения
            int warnsCount = 0;
            try
            {
                warnsCount = Convert.ToInt16(element.Attribute("WarningsCount").Value.ToString(), 10);
            }
            catch
            {
                warnsCount = 0;
            }


            for (int i = 0; i < warnsCount; i++)
            {
                string str1 = element.Attribute("WarningName" + i.ToString()).Value.ToString();
                SetCell(4, i, str1);
                dataGridView1.Rows[i].Cells[4].Style.BackColor = Color.Yellow;
            }

            #endregion

            #region Защиты
            int alarmsCount = 0;
            try
            {
                alarmsCount = Convert.ToInt16(element.Attribute("AlarmsCount").Value.ToString(), 10);
            }
            catch
            {
                alarmsCount = 0;
            }


            for (int i = 0; i < alarmsCount; i++)
            {
                string str1 = element.Attribute("AlarmName" + i.ToString()).Value.ToString();
                SetCell(5, i, str1);
                dataGridView1.Rows[i].Cells[5].Style.BackColor = Color.Red;
            }

            #endregion
        }
        //********************************************************************************************************//
        //********************************************************************************************************//
        bool CheckParams()
        {
            try
            {
                startAddr = (ushort)ConvertFuncs.StrToShort(textBox1.Text);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(60), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (startAddr > 0x3FFF)
            {
                MessageBox.Show(appTexts.ParameterName(60), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            try
            {
                endAddr = (ushort)ConvertFuncs.StrToShort(textBox2.Text);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(61), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }


            if (endAddr > 0x3FFF)
            {
                MessageBox.Show(appTexts.ParameterName(60), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            blockCount = endAddr - startAddr + 1;
            if (blockCount < 16)
            {
                MessageBox.Show(appTexts.ParameterName(62), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }


            if ((blockCount % 16) != 0)
            {
                MessageBox.Show(appTexts.ParameterName(62), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            blockCount = blockCount / 16;

            return(true);
        }
        public void CreateEventlogXMLFile(string FileName)
        {
            XmlDocument  document;
            XmlNode      element;
            XmlAttribute attribute;
            string       str;

            if (!CheckSystemConfiguration())
            {
                throw new Exception("Invalid Format!");
            }

            #region CreateFile
            try
            {
                XmlTextWriter textWritter = new XmlTextWriter(FileName, Encoding.UTF8);
                textWritter.WriteStartDocument();
                textWritter.WriteStartElement("Eventlog");
                textWritter.WriteEndElement();
                textWritter.Close();
            }
            catch
            {
                throw new Exception(appTexts.ParameterName(92));
            }

            document = new XmlDocument();
            try
            {
                document.Load(FileName);
            }
            catch
            {
                throw new Exception(appTexts.ParameterName(92));
            }

            #endregion

            #region EventLogSetup
            element = document.CreateElement("EventLogSetup");
            document.DocumentElement.AppendChild(element);            // указываем родителя

            attribute       = document.CreateAttribute("EventCount"); // создаём атрибут
            attribute.Value = systemConfiguration.EventCount.ToString();
            element.Attributes.Append(attribute);                     // добавляем атрибут
            #endregion

            for (int eventIndex = 0; eventIndex < systemConfiguration.EventCount; eventIndex++)
            {
                element = document.CreateElement("Event" + eventIndex.ToString());
                document.DocumentElement.AppendChild(element);
                ushort[] eventLine = eventLogData[eventIndex];

                #region EventType
                str       = "0x" + eventLine[systemConfiguration.EventCodeAddr].ToString("X4");
                attribute = document.CreateAttribute("Type");     // создаём атрибут
                try
                {
                    str = systemConfiguration.EventCodes[str].ToString();
                }
                catch
                {
                    str = "Нет данных";
                }
                attribute.Value = str;
                element.Attributes.Append(attribute);     // добавляем атрибут
                #endregion

                #region Time

                string strtt = "";
                int    ii    = systemConfiguration.EventTimeAddr;
                strtt = TimeConfig.ExtractTimeFromArray(eventLine, systemConfiguration.TimeConfig, ii);
//                    strtt = strtt + (eventLine[ii+2] & 0x00FF).ToString("X2") + ":";
//                    strtt = strtt + (eventLine[ii + 1] & 0x00FF).ToString("X2") + ":" + (eventLine[ii + 0] & 0x00FF).ToString("X2") + " ";

//                    strtt = strtt + (eventLine[ii + 4] & 0x00FF).ToString("X2") + "/" + (eventLine[ii + 5] & 0x001F).ToString("X2") + "/";
//                   strtt = strtt + "20" + (eventLine[ii + 6] & 0x00FF).ToString("X2");

                attribute       = document.CreateAttribute("Time"); // создаём атрибут
                attribute.Value = strtt;
                element.Attributes.Append(attribute);               // добавляем атрибут

                #endregion

                #region MeasureParams
                attribute       = document.CreateAttribute("MeasureCount"); // создаём атрибут
                attribute.Value = systemConfiguration.MeasureParams.Count.ToString();
                element.Attributes.Append(attribute);                       // добавляем атрибут

                for (int i = 0; i < systemConfiguration.MeasureParams.Count; i++)
                {
                    attribute       = document.CreateAttribute("MeasureName" + i.ToString()); // создаём атрибут
                    attribute.Value = systemConfiguration.MeasureParams[i].ParameterName;
                    element.Attributes.Append(attribute);                                     // добавляем атрибут

                    ushort u = eventLine[systemConfiguration.MeasureParams[i].Addr];
                    string d = u.ToFormatStr(systemConfiguration.MeasureParams[i].Format);
                    attribute       = document.CreateAttribute("Measure" + i.ToString()); // создаём атрибут
                    attribute.Value = d;
                    element.Attributes.Append(attribute);                                 // добавляем атрибут
                }

                #endregion

                #region digInputs
                int digInCount = 0;
                foreach (DigitPlate digitPlate in systemConfiguration.DigitPlates)
                {
                    if (digitPlate.DigitType == DigitType.DigInput)
                    {
                        ushort u    = eventLine[digitPlate.EventStructAddr];
                        ushort mask = digitPlate.UseMask;

                        for (int i = 0; i < 16; i++)
                        {
                            if (ConvertFuncs.GetBit(mask, i))
                            {
                                attribute       = document.CreateAttribute("DigInName" + digInCount.ToString());  // создаём атрибут
                                attribute.Value = digitPlate.DigitNames[i];
                                element.Attributes.Append(attribute);                                             // добавляем атрибут

                                attribute       = document.CreateAttribute("DigInValue" + digInCount.ToString()); // создаём атрибут
                                attribute.Value = ConvertFuncs.GetBit(u, i).ToString();
                                element.Attributes.Append(attribute);                                             // добавляем атрибут
                                digInCount++;
                            }
                        }
                    }
                }

                attribute       = document.CreateAttribute("DigInCount"); // создаём атрибут
                attribute.Value = digInCount.ToString();
                element.Attributes.Append(attribute);                     // добавляем атрибут


                #endregion

                #region digOutputs
                int digOutCount = 0;
                foreach (DigitPlate digitPlate in systemConfiguration.DigitPlates)
                {
                    if (digitPlate.DigitType == DigitType.DigOutput)
                    {
                        ushort u    = eventLine[digitPlate.EventStructAddr];
                        ushort mask = digitPlate.UseMask;

                        for (int i = 0; i < 16; i++)
                        {
                            if (ConvertFuncs.GetBit(mask, i))
                            {
                                attribute       = document.CreateAttribute("DigOutName" + digOutCount.ToString());  // создаём атрибут
                                attribute.Value = digitPlate.DigitNames[i];
                                element.Attributes.Append(attribute);                                               // добавляем атрибут

                                attribute       = document.CreateAttribute("DigOutValue" + digOutCount.ToString()); // создаём атрибут
                                attribute.Value = ConvertFuncs.GetBit(u, i).ToString();
                                element.Attributes.Append(attribute);                                               // добавляем атрибут
                                digOutCount++;
                            }
                        }
                    }
                }

                attribute       = document.CreateAttribute("DigOutCount"); // создаём атрибут
                attribute.Value = digOutCount.ToString();
                element.Attributes.Append(attribute);                      // добавляем атрибут


                #endregion

                #region Warnings
                int warnsCount = 0;
                foreach (WarningParam wp in systemConfiguration.WarningParams)
                {
                    ushort u = eventLine[wp.EventPosAddr];
                    // System.Windows.Forms.MessageBox.Show(wp.Titl+":  0x"+u.ToString("X4"));
                    for (int i = 0; i < 16; i++)
                    {
                        if (ConvertFuncs.GetBit(u, i))
                        {
                            attribute       = document.CreateAttribute("WarningName" + warnsCount.ToString()); // создаём атрибут
                            attribute.Value = wp.Names[i];
                            element.Attributes.Append(attribute);                                              // добавляем атрибут
                            warnsCount++;
                        }
                    }
                }

                attribute       = document.CreateAttribute("WarningsCount"); // создаём атрибут
                attribute.Value = warnsCount.ToString();
                element.Attributes.Append(attribute);                        // добавляем атрибут

                #endregion

                #region Alarms
                int alarmsCount = 0;
                foreach (WarningParam wp in systemConfiguration.AlarmParams)
                {
                    ushort u = eventLine[wp.EventPosAddr];
                    for (int i = 0; i < 16; i++)
                    {
                        if (ConvertFuncs.GetBit(u, i))
                        {
                            attribute       = document.CreateAttribute("AlarmName" + alarmsCount.ToString()); // создаём атрибут
                            attribute.Value = wp.Names[i];
                            element.Attributes.Append(attribute);                                             // добавляем атрибут
                            alarmsCount++;
                        }
                    }
                }

                attribute       = document.CreateAttribute("AlarmsCount"); // создаём атрибут
                attribute.Value = alarmsCount.ToString();
                element.Attributes.Append(attribute);                      // добавляем атрибут

                #endregion
            }

            try
            {
                document.Save(FileName);
            }
            catch
            {
                throw new Exception(appTexts.ParameterName(92));
            }
        }
        public CompareReportForm(ushort[] startAddrs, ushort[] endAddrs, List <ushort[]> profiles, string[] fileNames, AppTexts AppTexts)
        {
            InitializeComponent();
            this.Text = AppTexts.ParameterName(58);

            label1.Text = fileNames[0];
            label2.Text = fileNames[1];

            label7.Text = "0x" + startAddrs[0].ToString("X4");
            label8.Text = "0x" + startAddrs[1].ToString("X4");

            label9.Text  = "0x" + endAddrs[0].ToString("X4");
            label10.Text = "0x" + endAddrs[1].ToString("X4");

            minStart = startAddrs[0];
            if (startAddrs[1] < minStart)
            {
                minStart = startAddrs[1];
            }

            maxEnd = endAddrs[0];
            if (endAddrs[1] > maxEnd)
            {
                maxEnd = startAddrs[1];
            }

            modifyProfiles = new ushort[2, maxEnd - minStart + 1];

            for (ushort i = minStart; i <= maxEnd; i++)
            {
                for (int i2 = 0; i2 < 2; i2++)
                {
                    if ((i >= startAddrs[i2]) && (i <= endAddrs[i2]))
                    {
                        modifyProfiles[i2, i - minStart] = profiles[i2][i - startAddrs[i2]];
                    }
                    else
                    {
                        modifyProfiles[i2, i - minStart] = 0;
                    }
                }
            }

            dataGridView1.Columns.Add("adrrCol", AppTexts.ParameterName(23));
            dataGridView1.Columns.Add("value1Col", AppTexts.ParameterName(46) + " 1");
            dataGridView1.Columns.Add("value1Col", AppTexts.ParameterName(46) + " 2");

            for (int i = 0; i < (maxEnd - minStart + 1); i++)
            {
                object[] values = { "0x" + (i + minStart).ToString("X4"), "0x" + modifyProfiles[0, i].ToString("X4"), "0x" + modifyProfiles[1, i].ToString("X4") };
                if (!(((i + minStart) >= startAddrs[0]) && ((i + minStart) <= endAddrs[0])))
                {
                    values[1] = null;
                }
                if (!(((i + minStart) >= startAddrs[1]) && ((i + minStart) <= endAddrs[1])))
                {
                    values[2] = null;
                }


                if (modifyProfiles[0, i] != modifyProfiles[1, i])
                {
                    dataGridView1.Rows.Add(values);
                }
            }
        }
예제 #25
0
        private void openOldStyleButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter     = appTexts.ParameterName(102);
            ofd.DefaultExt = "*.xml";

            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            XDocument document;
            XElement  element;
            int       measureCounts;

            try
            {
                document = XDocument.Load(ofd.FileName);
            }

            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                element       = document.Root.Element("MeasureParams");
                measureCounts = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            List <MeasureParam> loadMeasureParams = new List <MeasureParam>();

            for (int i = 0; i < measureCounts; i++)
            {
                try
                {
                    element = document.Root.Element("MeasureParam" + (i + 1).ToString());
                    string       str1 = element.Attribute("Name").Value.ToString() + ", " + element.Attribute("UnitName").Value.ToString();
                    string       str2 = element.Attribute("Addr").Value.ToString();
                    short        i2   = ConvertFuncs.StrToShort(str2);
                    string       str3 = element.Attribute("Format").Value.ToString();
                    short        i3   = ConvertFuncs.StrToShort(str3);
                    MeasureParam mp   = new MeasureParam(str1, (ushort)i2, (ConvertFormats)i3);
                    loadMeasureParams.Add(mp);
                }
                catch
                {
                    MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            flowLayoutPanel2.Controls.Clear();
            measureParams.Clear();

            foreach (MeasureParam mp in loadMeasureParams)
            {
                measureParams.Add(new MeasureParamPanel());
                flowLayoutPanel2.Controls.Add(measureParams[measureParams.Count - 1]);
                measureParams[measureParams.Count - 1].RemoveClick  += new EventHandler(RemoveClick);
                measureParams[measureParams.Count - 1].ParameterName = mp.ParameterName;
                measureParams[measureParams.Count - 1].Addr          = mp.Addr;
                measureParams[measureParams.Count - 1].Format        = mp.Format;
            }
        }
예제 #26
0
        //***********************************************************************************************//
        //***********************************************************************************************//
        //***********************************************************************************************//
        private void loadOldStyleButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter     = appTexts.ParameterName(102);
            ofd.DefaultExt = "*.xml";

            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            XDocument           document;
            XElement            element;
            int                 warnigsCount;
            List <WarningParam> loadWarningParams = new List <WarningParam>();

            try
            {
                document = XDocument.Load(ofd.FileName);
            }

            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            try
            {
                element      = document.Root.Element(loadFromOldFileString);
                warnigsCount = Convert.ToInt16(element.Attribute("CountWord").Value.ToString(), 10);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            for (int i = 0; i < warnigsCount; i++)
            {
                try
                {
                    WarningParam wp   = new WarningParam("");
                    string       str1 = element.Attribute("EventPos" + (i).ToString()).Value.ToString();
                    wp.EventPosAddr = (ushort)ConvertFuncs.StrToShort(str1);
                    for (int i2 = 0; i2 < 16; i2++)
                    {
                        wp.Names[i2] = element.Attribute("Line" + (i * 16 + i2).ToString()).Value.ToString();
                    }
                    loadWarningParams.Add(wp);
                }
                catch
                {
                    MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            warningSelect21.SetWarningParams(loadWarningParams);
        }
        private void loadOldStyleButton_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter     = appTexts.ParameterName(102);
            ofd.DefaultExt = "*.xml";

            if (ofd.ShowDialog() != System.Windows.Forms.DialogResult.OK)
            {
                return;
            }

            XDocument document;
            XElement  element;
            int       digitCount;

            try
            {
                document = XDocument.Load(ofd.FileName);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            try
            {
                element    = document.Root.Element("Digits");
                digitCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }


            List <DigitPlate> loadDigitPlates = new List <DigitPlate>();

            for (int i = 0; i < digitCount; i++)
            {
                try
                {
                    element = document.Root.Element("Digit" + (i + 1).ToString());
                    string str1 = element.Attribute("Title").Value.ToString();
                    string str2 = element.Attribute("EventPos").Value.ToString();
                    string str3 = element.Attribute("Addr1").Value.ToString();
                    string str4 = element.Attribute("Type").Value.ToString();
                    string str5 = element.Attribute("Invert").Value.ToString();
                    string str6 = element.Attribute("UseMask").Value.ToString();

                    DigitPlate dp = new DigitPlate(str1);
                    dp.EventStructAddr = (ushort)ConvertFuncs.StrToShort(str2);
                    dp.StartAddr       = (ushort)(ConvertFuncs.StrToShort(str3) - 1);
                    if (str4 == "0")
                    {
                        dp.DigitType = DigitType.DigInput;
                    }
                    else
                    {
                        dp.DigitType = DigitType.DigOutput;
                    }
                    dp.Invert = (str5 != "0");

                    dp.UseMask = (ushort)ConvertFuncs.StrToShort(str6);
                    for (int i2 = 0; i2 < 16; i2++)
                    {
                        dp.DigitNames[i2] = element.Attribute("Line" + i2.ToString()).Value.ToString();
                    }

                    loadDigitPlates.Add(dp);
                }
                catch
                {
                    MessageBox.Show(appTexts.ParameterName(103), "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
            }

            DigitPlates = loadDigitPlates;
        }