コード例 #1
0
        public override void RotateParams(int Index1, int Index2)
        {
            WarningParam dp1 = (WarningParam)warningParams[Index1].Clone();

            warningParams[Index1] = warningParams[Index2];
            warningParams[Index2] = dp1;
        }
コード例 #2
0
        public object Clone()
        {
            WarningParam wp = new WarningParam(this.Titl);

            wp.names        = this.names;
            wp.eventPosAddr = this.eventPosAddr;
            return(wp);
        }
コード例 #3
0
        public void SetWarningParam(WarningParam WarningParam)
        {
            textBox1.Text = WarningParam.Titl;
            textBox2.Text = "0x" + WarningParam.EventPosAddr.ToString("X4");

            for (int i = 0; i < 16; i++)
            {
                textBoxs[i].Text = WarningParam.Names[i];
            }
        }
コード例 #4
0
        private void button1_Click(object sender, EventArgs e)
        {
            WarningParam newWarningParam;
            bool         b = warningSetup1.GetWarningParam(out newWarningParam);

            if (b)
            {
                NewWarningParam = newWarningParam;
                DialogResult    = System.Windows.Forms.DialogResult.OK;
            }
        }
コード例 #5
0
        public bool GetWarningParam(out WarningParam WarningParam)
        {
            WarningParam warningParam = new WarningParam(textBox1.Text);

            try
            {
                short u = ConvertFuncs.StrToShort(textBox2.Text);
                warningParam.EventPosAddr = (ushort)u;
            }
            catch
            {
                WarningParam = warningParam;
                return(false);
            }

            for (int i = 0; i < 16; i++)
            {
                warningParam.Names[i] = textBoxs[i].Text;
            }
            WarningParam = warningParam;
            return(true);
        }
コード例 #6
0
        void OpenFileBody(string FileName)
        {
            XDocument document;

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

            int digitCount = 0;

            try
            {
                XElement element = document.Root.Element("Digits");
                digitCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                digitCount = 0;
                //throw new Exception("Errors in part Digits of xml file!");
            }

            for (int i = 0; i < digitCount; i++)
            {
                try
                {
                    XElement   element = document.Root.Element("Digit" + (i + 1).ToString());
                    DigitPlate dp      = new DigitPlate();
                    dp.Titl = element.Attribute("Title").Value;


                    if (element.Attribute("Type").Value == "DigInput")
                    {
                        dp.DigitType = DigitType.DigInput;
                    }
                    else
                    {
                        dp.DigitType = DigitType.DigOutput;
                    }

                    if (element.Attribute("Invert").Value.ToString().ToUpper() == "TRUE")
                    {
                        dp.Invert = true;
                    }
                    else
                    {
                        dp.Invert = false;
                    }


                    dp.StartAddr       = (ushort)ConvertFuncs.StrToShort(element.Attribute("Addr").Value.ToString());
                    dp.EventStructAddr = (ushort)ConvertFuncs.StrToShort(element.Attribute("EventPos").Value.ToString());

                    dp.UseMask = Convert.ToUInt16(element.Attribute("UseMask").Value, 10);
                    for (int i2 = 0; i2 < 16; i2++)
                    {
                        dp.DigitNames[i2] = element.Attribute("Line" + (i2).ToString()).Value;
                    }



                    digitPlates.Add(dp);
                }
                catch
                {
                    throw new Exception("Errors in part Digit" + (i + 1).ToString() + " of xml file!");
                }
            }


            int measureCount = 0;

            measureParams = new List <MeasureParam>();
            try
            {
                XElement element = document.Root.Element("MeasureParams");
                measureCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                measureCount = 0;
                //throw new Exception("Errors in part MeasureParams of xml file!");
            }

            for (int i = 0; i < measureCount; i++)
            {
                try
                {
                    XElement element = document.Root.Element("MeasureParam" + (i + 1).ToString());
                    string   str1, str2, str3;
                    str1 = element.Attribute("Name").Value;
                    str2 = element.Attribute("Addr").Value;
                    str3 = element.Attribute("Format").Value;

                    MeasureParam dp = new MeasureParam(str1, str2, str3);
                    measureParams.Add(dp);
                }
                catch
                {
                    throw new Exception("Errors in part MeasureParam" + (i + 1).ToString() + " of xml file!");
                }
            }

            int eventCount = 0;

            eventCodes = new Hashtable();
            try
            {
                XElement element = document.Root.Element("EventCodes");
                eventCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                eventCount = 0;
                //throw new Exception("Errors in part MeasureParams of xml file!");
            }


            for (int i = 0; i < eventCount; i++)
            {
                try
                {
                    XElement element = document.Root.Element("EventCode" + (i + 1).ToString());
                    string   str1, str2;
                    str1 = element.Attribute("Name").Value;
                    str2 = element.Attribute("Code").Value;
                    eventCodes.Add(str2, str1);
                }
                catch
                {
                    throw new Exception("Errors in part EventCode" + (i + 1).ToString() + " of xml file!");
                }
            }

            try
            {
                XElement element = document.Root.Element("OtherParams");
                StartMeasureAddr  = (ushort)ConvertFuncs.StrToShort(element.Attribute("StartMeasureAddr").Value.ToString());
                EventCodeAddr     = (ushort)ConvertFuncs.StrToShort(element.Attribute("EventCodeAddr").Value.ToString());
                EventTimeAddr     = (ushort)ConvertFuncs.StrToShort(element.Attribute("EventTimeAddr").Value.ToString());
                EventBlockCount   = (ushort)ConvertFuncs.StrToShort(element.Attribute("EventBlockCount").Value.ToString());
                LoadEventAddr     = (ushort)ConvertFuncs.StrToShort(element.Attribute("LoadEventAddr").Value.ToString());
                LoadEventDataAddr = (ushort)ConvertFuncs.StrToShort(element.Attribute("LoadEventDataAddr").Value.ToString());
                EventCount        = (ushort)ConvertFuncs.StrToShort(element.Attribute("EventCount").Value.ToString());
            }
            catch
            {
                //eventCount = 0;
                throw new Exception("Errors in part OtherParams of xml file!");
            }

            XElement otherelements = document.Root.Element("OtherParams");

            if (otherelements.Attribute("EnaDigits") == null)
            {
                EnaDigits = false;
            }
            else
            {
                EnaDigits = otherelements.Attribute("EnaDigits").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaDirectAccess") == null)
            {
                EnaDirectAccess = false;
            }
            else
            {
                EnaDirectAccess = otherelements.Attribute("EnaDirectAccess").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaFloatDirectAccess") == null)
            {
                EnaFloatDirectAccess = false;
            }
            else
            {
                EnaFloatDirectAccess = otherelements.Attribute("EnaFloatDirectAccess").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaScope") == null)
            {
                EnaScope = false;
            }
            else
            {
                EnaScope = otherelements.Attribute("EnaScope").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaEventLog") == null)
            {
                EnaEventLog = false;
            }
            else
            {
                EnaEventLog = otherelements.Attribute("EnaEventLog").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaLoadSyms") == null)
            {
                EnaLoadSyms = false;
            }
            else
            {
                EnaLoadSyms = otherelements.Attribute("EnaLoadSyms").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaJog") == null)
            {
                EnaJog = false;
            }
            else
            {
                EnaJog = otherelements.Attribute("EnaJog").Value.ToBoolean();
            }


            if (otherelements.Attribute("EnaAngle") == null)
            {
                EnaAngle = false;
            }
            else
            {
                EnaAngle = otherelements.Attribute("EnaAngle").Value.ToBoolean();
            }

            if (otherelements.Attribute("EnaForceDig") == null)
            {
                EnaForceDig = false;
            }
            else
            {
                EnaForceDig = otherelements.Attribute("EnaForceDig").Value.ToBoolean();
            }



            /*
             *         try
             *         {
             *             object o = otherelements.Attribute("EnaDigits").Value;
             *             EnaDigits = (o != null);
             *         }
             *         catch
             *         {
             *             EnaDigits = false;
             *         }
             *
             *         try
             *         {
             *             object o = otherelements.Attribute("EnaDirectAccess").Value;
             *             EnaDirectAccess = (o != null);
             *         }
             *         catch
             *         {
             *             EnaDirectAccess = false;
             *         }
             *
             *         try
             *         {
             *             object o = otherelements.Attribute("EnaFloatDirectAccess").Value;
             *             EnaFloatDirectAccess = (o != null);
             *         }
             *         catch
             *         {
             *             EnaFloatDirectAccess = false;
             *         }
             *
             *         try
             *         {
             *             object o = otherelements.Attribute("EnaScope").Value;
             *             EnaScope = (o != null);
             *         }
             *         catch
             *         {
             *             EnaScope = false;
             *         }
             *
             *         try
             *         {
             *             object o = otherelements.Attribute("EnaEventLog").Value;
             *             EnaEventLog = (o != null);
             *         }
             *         catch
             *         {
             *             EnaEventLog = false;
             *         }
             *         try
             *         {
             *             object o = otherelements.Attribute("EnaLoadSyms").Value;
             *             EnaLoadSyms = (o != null);
             *         }
             *         catch
             *         {
             *             EnaLoadSyms = false;
             *         }
             *
             */


            int readyCount = 0;

            try
            {
                XElement element = document.Root.Element("Readys");
                readyCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                readyCount = 0;
                //throw new Exception("Errors in part Digits of xml file!");
            }


            for (int i = 0; i < readyCount; i++)
            {
                try
                {
                    XElement     element = document.Root.Element("Ready" + (i + 1).ToString());
                    WarningParam dp      = new WarningParam(element.Attribute("Title").Value.ToString());
                    dp.Titl = element.Attribute("Title").Value;



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


                    readyParams.Add(dp);
                }
                catch
                {
                    throw new Exception("Errors in part Ready" + (i + 1).ToString() + " of xml file!");
                }
            }


            int warningCount = 0;

            try
            {
                XElement element = document.Root.Element("Warnings");
                warningCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                warningCount = 0;
                //throw new Exception("Errors in part Digits of xml file!");
            }


            for (int i = 0; i < warningCount; i++)
            {
                try
                {
                    XElement     element = document.Root.Element("Warning" + (i + 1).ToString());
                    WarningParam dp      = new WarningParam(element.Attribute("Title").Value.ToString());
                    dp.Titl = element.Attribute("Title").Value;



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


                    warningParams.Add(dp);
                }
                catch
                {
                    throw new Exception("Errors in part Warning" + (i + 1).ToString() + " of xml file!");
                }
            }


            int alarmCount = 0;

            try
            {
                XElement element = document.Root.Element("Alarms");
                alarmCount = Convert.ToInt16(element.Attribute("Count").Value.ToString(), 10);
            }
            catch
            {
                alarmCount = 0;
                //throw new Exception("Errors in part Digits of xml file!");
            }


            for (int i = 0; i < alarmCount; i++)
            {
                try
                {
                    XElement     element = document.Root.Element("Alarm" + (i + 1).ToString());
                    WarningParam dp      = new WarningParam(element.Attribute("Title").Value.ToString());
                    dp.Titl = element.Attribute("Title").Value;

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


                    alarmParams.Add(dp);
                }
                catch
                {
                    throw new Exception("Errors in part Alarm" + (i + 1).ToString() + " of xml file!");
                }
            }



            try
            {
                XElement element = document.Root.Element("TimeSettings");
                timeConfig = new TimeConfig(element);
            }

            catch
            {
                throw new Exception("Errors in part TimeSettings of xml file!");
            }
        }
コード例 #7
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);
        }
コード例 #8
0
 public WarningSetupForm(WarningParam WarningParam)
 {
     InitializeComponent();
     warningSetup1.SetWarningParam(WarningParam);
 }