protected override void InitializeConvertFuncs()
        {
            ConvertFuncs.Add(typeof(decimal).Name, sourceValue => System.Convert.ToDecimal((string)sourceValue));
            ConvertFuncs.Add(typeof(double).Name, sourceValue => System.Convert.ToDouble((string)sourceValue));
            ConvertFuncs.Add(typeof(float).Name, sourceValue => System.Convert.ToSingle((string)sourceValue));
            ConvertFuncs.Add(typeof(long).Name, sourceValue => System.Convert.ToInt64((string)sourceValue));
            ConvertFuncs.Add(typeof(ulong).Name, sourceValue => System.Convert.ToUInt64((string)sourceValue));
            ConvertFuncs.Add(typeof(int).Name, sourceValue => System.Convert.ToInt32((string)sourceValue));
            ConvertFuncs.Add(typeof(uint).Name, sourceValue => System.Convert.ToUInt32((string)sourceValue));
            ConvertFuncs.Add(typeof(short).Name, sourceValue => System.Convert.ToInt16((string)sourceValue));
            ConvertFuncs.Add(typeof(ushort).Name, sourceValue => System.Convert.ToUInt16((string)sourceValue));
            ConvertFuncs.Add(typeof(char).Name, sourceValue => System.Convert.ToChar((string)sourceValue));
            ConvertFuncs.Add(typeof(byte).Name, sourceValue => System.Convert.ToByte((string)sourceValue));
            ConvertFuncs.Add(typeof(bool).Name, sourceValue => System.Convert.ToBoolean((string)sourceValue));
            ConvertFuncs.Add(typeof(DateTime).Name, sourceValue =>
            {
                DateTime dateTime;
                bool validCast = DateTime.TryParse((string)sourceValue, out dateTime);
                if (!validCast)
                {
                    throw new TestflowDataException(ModuleErrorCode.UnsupportedTypeCast,
                                                    "Illegal string for datetime cast.");
                }
                return(dateTime);
            });
//            ConvertFuncs.Add(typeof(string).Name, sourceValue => sourceValue.ToString());
        }
        public static string[] ExtractArrayTimeFromArray(ushort[] ParamRTU, TimeFormats TimeF)
        {
            if (TimeF == TimeFormats.STMFormat)
            {
                string[] strs = new string[6];
                if (ParamRTU.Length != 4)
                {
                    throw new Exception("Invalid data!");
                }

                strs[0] = (ParamRTU[3] & 0x00FF).ToString("X2");
                strs[1] = ((ParamRTU[2] >> 8) & 0x00FF).ToString("X2");
                strs[2] = (ParamRTU[2] & 0x00FF).ToString("X2");
                strs[3] = (ParamRTU[0] & 0x003F).ToString("X2");
                strs[4] = ((ParamRTU[0] >> 8) & 0x001F).ToString("X2");
                strs[5] = "20" + (ParamRTU[1] & 0x00FF).ToString("X2");
                return(strs);
            }
            else if (TimeF == TimeFormats.ADSPFormat)
            {
                string[] strs = new string[6];
                if (ParamRTU.Length != 7)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";
                str = str + (ParamRTU[2] & 0x00FF).ToString("X2") + ":";
                str = str + (ParamRTU[1] & 0x00FF).ToString("X2") + ":" + (ParamRTU[0] & 0x00FF).ToString("X2") + " ";

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

                strs[0] = (ParamRTU[2] & 0x00FF).ToString("X2");
                strs[1] = (ParamRTU[1] & 0x00FF).ToString("X2");
                strs[2] = (ParamRTU[0] & 0x00FF).ToString("X2");
                strs[3] = (ParamRTU[4] & 0x00FF).ToString("X2");
                strs[4] = (ParamRTU[5] & 0x001F).ToString("X2");
                strs[5] = "20" + (ParamRTU[6] & 0x00FF).ToString("X2");
                return(strs);
            }
            else if (TimeF == TimeFormats.RTCFormat)
            {
                string[] strs = new string[6];
                if (ParamRTU.Length != 4)
                {
                    throw new Exception("Invalid data!");
                }

                strs[0] = ConvertFuncs.FromBCD((ushort)(ParamRTU[3] & 0x003F)).ToString("D2");
                strs[1] = ConvertFuncs.FromBCD((ushort)((ParamRTU[2] & 0xFF00) >> 8)).ToString("D2");
                strs[2] = ConvertFuncs.FromBCD((ushort)(ParamRTU[2] & 0x00FF)).ToString("D2");
                strs[3] = ConvertFuncs.FromBCD((ushort)(ParamRTU[0] & 0x003F)).ToString("D2");
                strs[4] = ConvertFuncs.FromBCD((ushort)((ParamRTU[0] & 0x1F00) >> 8)).ToString("D2");
                strs[5] = "20" + ConvertFuncs.FromBCD((ushort)(ParamRTU[1] & 0x00FF)).ToString("D2");

                return(strs);
            }
            return(null);
        }
Exemple #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            NewEventCodes = new Hashtable();

            if (MessageBox.Show("Внести изменения в профиль?", "", MessageBoxButtons.OKCancel, MessageBoxIcon.Question) != System.Windows.Forms.DialogResult.OK)
            {
                DialogResult = System.Windows.Forms.DialogResult.No;
                return;
            }


            try
            {
                for (int i = 0; i < (dataGridView1.Rows.Count - 1); i++)
                {
                    short  u   = ConvertFuncs.StrToShort(dataGridView1.Rows[i].Cells[0].Value.ToString());
                    string st1 = "0x" + u.ToString("X4");
                    string st2 = dataGridView1.Rows[i].Cells[1].Value.ToString();
                    NewEventCodes.Add(st1, st2);
                }
            }
            catch
            {
                MessageBox.Show("Неправильно заданы коды события!", "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            DialogResult = System.Windows.Forms.DialogResult.OK;
        }
 private void DataRecieved(bool DataOk, ushort[] ParamRTU, object param)
 {
     if (InvokeRequired)
     {
         Invoke(new AsynchSerialPort.DataRecievedRTU(DataRecieved), DataOk, ParamRTU, null);
     }
     else
     {
         portBusy = false;
         if (DataOk)
         {
             ushort u = ParamRTU[0];
             if (invert)
             {
                 u = (ushort)(u ^ 0xFFFF);
             }
             for (int i = 0; i < 16; i++)
             {
                 if (ConvertFuncs.GetBit(u, i))
                 {
                     lampLabels[i].BackColor = Color.LightGreen;
                 }
                 else
                 {
                     lampLabels[i].BackColor = Color.White;
                 }
             }
         }
     }
 }
        private void writeBtn_Click(object sender, EventArgs e)
        {
            ushort w1 = 0;
            ushort w2 = 0;

            try
            {
                ulong       u  = ConvertFuncs.StrToULong(longTextBox.Text);
                FloatStruct fs = new FloatStruct();
                fs.ULong = u;
                w1       = fs.Word1;
                w2       = fs.Word2;
            }
            catch
            {
                ErrorMessage(texts[9]);
                return;
            }

            ushort Addr = 0;

            if (!CheckAddr(out Addr))
            {
                ErrorMessage(texts[6]);
                return;
            }

            serialPort.SetDataRTU(Addr, WriteDataRecieved, RequestPriority.Normal, w1, w2);
        }
        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];
            }
        }
Exemple #7
0
            public void ReloadSeries()
            {
                var views = items.Where(p => p.IsFinishedWithDate).ToList();

                Series.Clear();
                Counts.Clear();
                foreach (var t in MovieViewModel.TypesDict)
                {
                    int c      = 0;
                    var points = new List <DataModel>();
                    for (var dt = 2012; dt <= DateTime.Today.Year; dt = dt + 1)
                    {
                        var count = views.Count(p => p.FinishDate.Value.Year == dt && p.Type == t.Key);
                        points.Add(
                            new DataModel()
                        {
                            Year  = dt,
                            Count = count
                        });
                        c = c + count;
                    }
                    var a = new StackedColumnSeries()
                    {
                        Values = new ChartValues <DataModel>(points),
                        Title  = t.Value,
                        Fill   = ConvertFuncs.TypeToBrushFunc(t.Key)
                    };
                    Series.Add(a);
                    Counts.Add(new CountClass(c, t.Key, t.Value));
                }
                Totals = Counts.Sum(p => p.Count);
                Reloaded?.Invoke(null, EventArgs.Empty);
            }
Exemple #8
0
            public void ReloadSeries()
            {
                var views = items.Where(p => p.States.IsStateDoneWithDate(StateEnum.Finished)).ToList();

                Series.Clear();
                Counts.Clear();
                foreach (var t in MovieViewModel.TypesDict)
                {
                    int c      = 0;
                    var points = new List <DateTimePoint>();
                    for (var dt = FirstDay; dt <= LastDay; dt = dt.AddDays(1))
                    {
                        var count = views.Count(p => p.FinishDate == dt && p.Type == t.Key);
                        points.Add(
                            new DateTimePoint()
                        {
                            DateTime = dt,
                            Value    = count
                        });
                        c = c + count;
                    }

                    var a = new StackedColumnSeries()
                    {
                        Values = new ChartValues <DateTimePoint>(points),
                        Title  = t.Value,
                        Fill   = ConvertFuncs.TypeToBrushFunc(t.Key)
                    };
                    Series.Add(a);
                    Counts.Add(new CountClass(c, t.Key, t.Value));
                }
                Totals = Counts.Sum(p => p.Count);
                Reloaded?.Invoke(null, EventArgs.Empty);
            }
        private bool CheckAddr(out ushort Addr)
        {
            Addr = 0;
            try
            {
                Addr = (ushort)ConvertFuncs.StrToShort(addrTextBox.Text);
            }
            catch
            {
                MessageBox.Show(texts[6], "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (Addr > 0x3FFF)
            {
                MessageBox.Show(texts[6], "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            if (ConvertFuncs.GetBit(Addr, 0))
            {
                MessageBox.Show(texts[7], "", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }
            return(true);
        }
Exemple #10
0
    //void calculate(string serverSays)
    void calculate(byte[] bytesFromServer)
    {
        // just return sensor fusion is not yet ready
        if (sF == null)
        {
            return;
        }

        samplecount += 1;

        var bytes = ConvertFuncs.ToByteArray(bytesFromServer);

        // TODO: Add other stream data options/data lengths
        if (bytes.Length == 9)
        {
            // get Gyroscope data
            gtx = bytes[0];
            gty = bytes[1];
            gtz = bytes[2];
            gx  = gtx * gyroRawMultiplier;
            gy  = gty * gyroRawMultiplier;
            gz  = gtz * gyroRawMultiplier;

            grx = gx; gry = gy; grz = gz;
            gx -= gxo; gy -= gyo; gz -= gzo;

            // get Accelerometer data
            ax = bytes[3];
            ay = bytes[4];
            az = bytes[5];

            // store previous values
            if (prevAx != 0 || prevAy != 0 || prevAz != 0)
            {
                //print(String.Format("acc difference: {0}, {1}, {2}", Math.Abs(ax - prevAx), Math.Abs(ay - prevAy), Math.Abs(az - prevAz)));
                if (Math.Abs(ax - prevAx) >= 100 || Math.Abs(ay - prevAy) >= 100 || Math.Abs(az - prevAz) >= 100)
                {
                    movementDetected = true;
                }
                else
                {
                    movementDetected = false;
                }
            }

            prevAx = ax;
            prevAy = ay;
            prevAz = az;

            // get Magnetometer data
            mx = bytes[6];
            my = bytes[7];
            mz = bytes[8];
        }

        // run sensor fusion with raw sensor data
        runFusion(bytesFromServer);
    }
        public TimeConfig(XElement TimeXElement)
        {
            try
            {
                timeFormat = StringToTimeFormat(TimeXElement.Attribute("TimeFormat").Value);
            }
            catch
            {
                throw new Exception("Error time format!");
            }


            if (timeFormat == TimeFormats.STMFormat)
            {
                try
                {
                    STMProcAddr1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr1").Value);
                    STMProcAddr2 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr2").Value);
                    STMProcAddr3 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr3").Value);
                    STMProcAddr4 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr4").Value);

                    STMProcAddr1_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr1_1").Value);
                    STMProcAddr2_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr2_1").Value);
                    STMProcAddr3_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr3_1").Value);
                    STMProcAddr4_1 = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("STMProcAddr4_1").Value);
                }
                catch
                {
                    throw new Exception("Error time format!");
                }
            }
            else if (timeFormat == TimeFormats.ADSPFormat)
            {
                try
                {
                    ReadAddr    = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("ReadAddr").Value);
                    SetAddr     = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("SetAddr").Value);
                    AddrSetTime = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("AddrSetTime").Value);
                }
                catch
                {
                    throw new Exception("Error time format!");
                }
            }
            else if (timeFormat == TimeFormats.RTCFormat)
            {
                try
                {
                    ReadAddr = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("ReadAddr").Value);
                    SetAddr  = ConvertFuncs.UInt16ToWord(TimeXElement.Attribute("SetAddr").Value);
                }
                catch
                {
                    throw new Exception("Error time format!");
                }
            }
        }
Exemple #12
0
        public bool GetDigitPlate(out DigitPlate DigitPlate)
        {
            bool       b          = true;
            DigitPlate digitPlate = new DigitPlate();

            digitPlate.Titl = textBox1.Text;

            try
            {
                short u = ConvertFuncs.StrToShort(textBox2.Text);
                digitPlate.StartAddr = (ushort)u;
            }
            catch
            {
                b = false;
            }

            try
            {
                short u = ConvertFuncs.StrToShort(textBox3.Text);
                digitPlate.EventStructAddr = (ushort)u;
            }
            catch
            {
                b = false;
            }

            ushort step  = 1;
            ushort value = 0;

            for (int i = 0; i < 16; i++)
            {
                digitPlate.DigitNames[i] = textBoxs[i].Text;
                if (checkBoxs[i].Checked)
                {
                    value = (ushort)(value | step);
                }
                step = (ushort)(step << 1);
            }

            digitPlate.UseMask = value;

            if (radioButton1.Checked)
            {
                digitPlate.DigitType = DigitType.DigInput;
            }
            else
            {
                digitPlate.DigitType = DigitType.DigOutput;
            }

            digitPlate.Invert = radioButton4.Checked;
            DigitPlate        = digitPlate;
            return(b);
        }
Exemple #13
0
        public static ushort[] ToVHzRef(this double Value)
        {
            ushort[] us = new ushort[2];
            double   d  = 8000.0 / Value;
            double   d1 = Math.Truncate(d);
            ulong    u  = (ulong)d;

            us[0] = (ushort)d;
            us[1] = ConvertFuncs.U0_16ToWord(d - d1);
            return(us);
        }
        public static string ExtractTimeFromArray(ushort[] ParamRTU, TimeFormats TimeF, int Index = 0)
        {
            if (TimeF == TimeFormats.STMFormat)
            {
                if (ParamRTU.Length - Index < 4)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";
                str = str + (ParamRTU[3 + Index] & 0x00FF).ToString("X2") + ":";
                str = str + ((ParamRTU[2 + Index] >> 8) & 0x00FF).ToString("X2") + ":" + (ParamRTU[2 + Index] & 0x00FF).ToString("X2") + " ";

                str = str + (ParamRTU[0 + Index] & 0x003F).ToString("X2") + "/" + ((ParamRTU[0 + Index] >> 8) & 0x001F).ToString("X2") + "/";
                str = str + "20" + (ParamRTU[1 + Index] & 0x00FF).ToString("X2");
                return(str);
            }
            else if (TimeF == TimeFormats.ADSPFormat)
            {
                if (ParamRTU.Length - Index < 7)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";

                str = (ParamRTU[4 + Index] & 0x00FF).ToString("X2") + "/" + (ParamRTU[5 + Index] & 0x001F).ToString("X2") + "/" +
                      "20" + (ParamRTU[6 + Index] & 0x00FF).ToString("X2") + " " +
                      (ParamRTU[2 + Index] & 0x00FF).ToString("X2") + ":" +
                      (ParamRTU[1 + Index] & 0x00FF).ToString("X2") + ":" + (ParamRTU[0 + Index] & 0x00FF).ToString("X2") /* + "." + (ParamRTU[3]).ToString("D3")*/;


                return(str);
            }
            else if (TimeF == TimeFormats.RTCFormat)
            {
                if (ParamRTU.Length - Index < 4)
                {
                    throw new Exception("Invalid data!");
                }

                string str = "";

                str = ConvertFuncs.FromBCD((ushort)(ParamRTU[0 + Index] & 0x003F)).ToString("D2") + " / " + ConvertFuncs.FromBCD((ushort)((ParamRTU[0 + Index] & 0x1F00) >> 8)).ToString("D2") + " / " +
                      "20" + ConvertFuncs.FromBCD((ushort)(ParamRTU[1 + Index] & 0x00FF)).ToString("D2") + "   " +
                      ConvertFuncs.FromBCD((ushort)(ParamRTU[3 + Index] & 0x003F)).ToString("D2") + ":" +
                      ConvertFuncs.FromBCD((ushort)((ParamRTU[2 + Index] & 0xFF00) >> 8)).ToString("D2") + ":" + ConvertFuncs.FromBCD((ushort)(ParamRTU[2 + Index] & 0x00FF)).ToString("D2") +
                      "." + (ParamRTU[3 + Index] >> 6).ToString("D3");


                return(str);
            }
            return("");
        }
 bool CheckValue()
 {
     try
     {
         value = (ushort)ConvertFuncs.StrToShort(textBox2.Text);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
        //********************************************************************************************************//
        //********************************************************************************************************//
        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);
        }
Exemple #17
0
 bool CheckAddr()
 {
     try
     {
         addr = (ushort)ConvertFuncs.StrToShort(textBox1.Text);
     }
     catch
     {
         return(false);
     }
     if (addr > 0x3FFF)
     {
         return(false);
     }
     return(true);
 }
Exemple #18
0
        protected override void InitializeConvertFuncs()
        {
            ConvertFuncs.Add(typeof(decimal).Name, sourceValue => System.Convert.ToDecimal((byte)sourceValue));
            ConvertFuncs.Add(typeof(double).Name, sourceValue => System.Convert.ToDouble((byte)sourceValue));
            ConvertFuncs.Add(typeof(float).Name, sourceValue => System.Convert.ToSingle((byte)sourceValue));
            ConvertFuncs.Add(typeof(long).Name, sourceValue => System.Convert.ToInt64((byte)sourceValue));
            ConvertFuncs.Add(typeof(ulong).Name, sourceValue => System.Convert.ToUInt64((byte)sourceValue));
            ConvertFuncs.Add(typeof(int).Name, sourceValue => System.Convert.ToInt32((byte)sourceValue));
            ConvertFuncs.Add(typeof(uint).Name, sourceValue => System.Convert.ToUInt32((byte)sourceValue));
            ConvertFuncs.Add(typeof(short).Name, sourceValue => System.Convert.ToInt16((byte)sourceValue));
            ConvertFuncs.Add(typeof(ushort).Name, sourceValue => System.Convert.ToUInt16((byte)sourceValue));
            ConvertFuncs.Add(typeof(char).Name, sourceValue => System.Convert.ToChar((byte)sourceValue));
//            ConvertFuncs.Add(typeof (byte).Name, sourceValue => System.Convert.ToByte((byte)sourceValue));
            ConvertFuncs.Add(typeof(bool).Name, sourceValue => (byte)sourceValue > 0);
            ConvertFuncs.Add(typeof(string).Name, sourceValue => sourceValue.ToString());
        }
Exemple #19
0
        protected override void InitializeConvertFuncs()
        {
            ConvertFuncs.Add(typeof(decimal).Name, sourceValue => (bool)sourceValue ? 1 : 0);
//            ConvertFuncs.Add(typeof(double).Name, sourceValue => sourceValue.ToString());
//            ConvertFuncs.Add(typeof(float).Name, sourceValue => sourceValue.ToString());
            ConvertFuncs.Add(typeof(long).Name, sourceValue => (long)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(ulong).Name, sourceValue => (ulong)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(int).Name, sourceValue => (int)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(uint).Name, sourceValue => (uint)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(short).Name, sourceValue => (short)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(ushort).Name, sourceValue => (ushort)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(char).Name, sourceValue => (char)((bool)sourceValue ? 1 : 0));
            ConvertFuncs.Add(typeof(byte).Name, sourceValue => (byte)((bool)sourceValue ? 1 : 0));
//            ConvertFuncs.Add(typeof(bool).Name, sourceValue => sourceValue.ToString());
            ConvertFuncs.Add(typeof(string).Name, sourceValue => sourceValue.ToString());
        }
Exemple #20
0
        private void loadSensorPanelBtn_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            // ofd.Filter = appTexts.ParameterName(102);

            if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
            {
                List <ushort[]> loadEventDataPanel = new List <ushort[]>();
                FileStream      fs = new FileStream(ofd.FileName, FileMode.Open);
                StreamReader    sr = new StreamReader(fs);
                try
                {
                    for (int i1 = 0; i1 < systemConfiguration.EventCount; i1++)
                    {
                        ushort[] us = new ushort[systemConfiguration.EventBlockCount * 32];
                        for (int i2 = 0; i2 < us.Length; i2++)
                        {
                            us[i2] = (ushort)ConvertFuncs.StrToShort(sr.ReadLine());
                        }
                        loadEventDataPanel.Add(us);
                    }
                    fs.Close();
                    sr.Close();
                }
                catch
                {
                    MessageBox.Show(appTexts.ParameterName(110), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                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)
                {
                    EventLogFile eventLogFile = new EventLogFile(systemConfiguration, appTexts, loadEventDataPanel);
                    eventLogFile.CreateEventlogXMLFile(sfd.FileName);
                    EventlogViewerForm elvf = new EventlogViewerForm(sfd.FileName, appTexts);
                    elvf.Show();
                }
            }
        }
 private void textBox2_TextChanged(object sender, EventArgs e)
 {
     if ((!longTextBox.Focused) || nowReading)
     {
         return;
     }
     try
     {
         ulong       u  = ConvertFuncs.StrToULong(longTextBox.Text);
         FloatStruct fs = new FloatStruct();
         fs.ULong          = u;
         floatTextBox.Text = fs.Float.ToString();
     }
     catch
     {
     }
 }
        private void textBox2_TextChanged(object sender, EventArgs e)
        {
            ushort u = addr;

            try
            {
                u = (ushort)ConvertFuncs.StrToShort(textBox2.Text);
                textBox2.BackColor = Color.White;
                addrCorrect        = true;
            }
            catch
            {
                textBox2.BackColor = Color.Red;
                addrCorrect        = false;
                u = 0;
            }

            addr = u;
        }
 public void ReloadSeries()
 {
     Series = new SeriesCollection();
     items  = MainViewModel.Default.BooksViewModel.Items.ToList();
     foreach (var x in BookViewModel.StatesDict)
     {
         var ps = new PieSeries()
         {
             Values = new ChartValues <int>()
             {
                 items.Count(p => p.LastState.Name == x.Key)
             },
             Title      = x.Value,
             DataLabels = true,
             Fill       = ConvertFuncs.StateToBrushFunc(x.Key)
         };
         Series.Add(ps);
     }
 }
Exemple #24
0
            public void ReloadSeries()
            {
                items = MainViewModel.Default.MoviesViewModel.Items.ToList();
                Series.Clear();

                foreach (var x in MovieViewModel.TypesDict)
                {
                    var ps = new PieSeries()
                    {
                        Values = new ChartValues <int>()
                        {
                            items.Where(p => p.Type == x.Key).Count()
                        },
                        Title      = x.Value,
                        DataLabels = true,
                        Fill       = ConvertFuncs.TypeToBrushFunc(x.Key)
                    };
                    Series.Add(ps);
                }
            }
Exemple #25
0
        public TimeConfig CalcTimeConfig()
        {
            TimeConfig timeConfig = new TimeConfig();

            if (radioButton1.Checked)
            {
                timeConfig.TimeFormat = TimeFormats.ADSPFormat;
            }
            else
            {
                timeConfig.TimeFormat = TimeFormats.RTCFormat;
            }

            if (timeConfig.TimeFormat == TimeFormats.ADSPFormat)
            {
                try
                {
                    timeConfig.ReadAddr    = ConvertFuncs.UInt16ToWord(textBox1.Text);
                    timeConfig.AddrSetTime = ConvertFuncs.UInt16ToWord(textBox2.Text);
                    timeConfig.SetAddr     = ConvertFuncs.UInt16ToWord(textBox3.Text);
                }
                catch
                {
                    throw new Exception("Error in addresses!");
                }
            }
            else if (timeConfig.TimeFormat == TimeFormats.RTCFormat)
            {
                try
                {
                    timeConfig.ReadAddr = ConvertFuncs.UInt16ToWord(textBox2_1.Text);
                    timeConfig.SetAddr  = ConvertFuncs.UInt16ToWord(textBox2_2.Text);
                }
                catch
                {
                    throw new Exception("Error in addresses!");
                }
            }
            return(timeConfig);
        }
        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);
        }
        public MeasureParam(string ParameterName, string Addr, string Format)
        {
            this.ParameterName = ParameterName;

            try
            {
                addr = (ushort)ConvertFuncs.StrToShort(Addr);
            }
            catch
            {
                addr = 0;
            }


            try
            {
                format = Format.ToConvertFormats();
            }
            catch
            {
                format = ConvertFormats.Percent;
            }
        }
        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!");
            }
        }
Exemple #29
0
        private byte[] GenerateData()
        {
            DataSet dataSet;

            using (FileStream stream = new FileStream(this.InputFilePath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
            {
                dataSet = EPPlusHelper.ReadExcelToDataSet(stream);
            }
            ProjectItems collection = this.ProjectItem.Collection;

            // Generate code
            StringBuilder builder = new StringBuilder();

            builder.AppendLine(string.Format(System.Globalization.CultureInfo.InvariantCulture, Parameters.DO_NOT_MODIFY, this.GetType().Name));
            builder.AppendLine($"using System;");
            builder.AppendLine($"using System.Collections.Generic;");
            builder.AppendLine($"using System.Globalization;");
            builder.AppendLine($"using System.Reflection;");
            builder.AppendLine($"using Xunit.Sdk;");
            builder.AppendLine($"");
            builder.AppendLine($"namespace {this.CodeNamespace}");
            builder.AppendLine($"{{");
            builder.AppendLine($"    public class ExcelTestDataAttribute : DataAttribute");
            builder.AppendLine($"    {{");
            builder.AppendLine($"        public override IEnumerable<object[]> GetData(MethodInfo testMethod)");
            builder.AppendLine($"        {{");
            builder.AppendLine($"            ParameterInfo[] parameters = testMethod.GetParameters();");
            builder.AppendLine($"            switch ($\"{{testMethod.DeclaringType.Name}}\")");
            builder.AppendLine($"            {{");
            foreach (DataTable table in dataSet.Tables)
            {
                builder.AppendLine($"                case \"{table.TableName}\":");

                ProjectItem referenceItem = null;
                foreach (ProjectItem item in collection)
                {
                    if (item.Name.Equals(table.TableName + ".cs", StringComparison.OrdinalIgnoreCase))
                    {
                        referenceItem = item;
                        break;
                    }
                }
                if (referenceItem != null)
                {
                    FileCodeModel model = referenceItem.FileCodeModel;
                    builder.AppendLine($"                    switch ($\"{{testMethod.Name}}\")");
                    builder.AppendLine($"                    {{");
                    foreach (var group in table.Rows.Cast <DataRow>().GroupBy <DataRow, string>(dr => dr["Method"].ToString()))
                    {
                        string       method    = group.Key;
                        CodeFunction eFunction = this.FindMethod(model, table.TableName, method);
                        if (eFunction == null)
                        {
                            continue;
                        }
                        string[] types = eFunction.Parameters.Cast <CodeParameter>().Select(p => p.Type.AsFullName).ToArray();
                        if (!types.All(p => ConvertFuncs.ContainsKey(p)))
                        {
                            continue;
                        }

                        builder.AppendLine($"                        case \"{method}\":");
                        foreach (DataRow row in group)
                        {
                            builder.AppendLine($"                            yield return new object[]");
                            builder.AppendLine($"                            {{");
                            for (int i = 0; i < types.Length; i++)
                            {
                                string text = (string)row[i + 1];
                                builder.AppendLine($"                                {ConvertFuncs[types[i]](text)},");
                            }
                            builder.AppendLine($"                            }};");
                        }
                        builder.AppendLine($"                            yield break;");
                    }
                    builder.AppendLine($"                        default:");
                    builder.AppendLine($"                            yield break;");
                    builder.AppendLine($"                    }}");
                }
                else
                {
                    builder.AppendLine($"                    yield break;");
                }
            }
            builder.AppendLine($"                default:");
            builder.AppendLine($"                    yield break;");
            builder.AppendLine($"            }}");
            builder.AppendLine($"        }}");
            // End Method.

            builder.AppendLine($"    }}");
            builder.AppendLine($"}}");
            builder.AppendLine($"");

            string code = builder.ToString();

            return(Encoding.UTF8.GetBytes(code));
        }
        //************************** ЧТЕНИЕ ДАННЫХ ИЗ ФАЙЛА *****************************************************//
        //********************************************************************************************************//
        private bool LoadProfileFromFile(string filename)
        {
            ushort newStartAddr, tresh, newBlockCount;
            ushort index = 0;
            string line;

            try
            {
                using (StreamReader sr = new StreamReader(filename))
                {
                    List <ushort> fileParams = new List <ushort>();
                    line       = sr.ReadLine();
                    fileParams = ConvertFuncs.LineToUshorts(line);

                    if (fileParams.Count != 2)
                    {
                        MessageBox.Show(appTexts.ParameterName(66), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    newStartAddr  = fileParams[0];
                    tresh         = fileParams[1];
                    newBlockCount = (ushort)((tresh - newStartAddr + 1) / 16);
                    tresh         = (ushort)(newStartAddr + 16 * newBlockCount - 1);

                    if (tresh != fileParams[1])
                    {
                        MessageBox.Show(appTexts.ParameterName(66), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return(false);
                    }

                    systemProfile = new ushort[16 * newBlockCount];

                    for (int i = 0; i < newBlockCount; i++)
                    {
                        line       = sr.ReadLine();
                        fileParams = ConvertFuncs.LineToUshorts(line);
                        if (fileParams.Count != 2)
                        {
                            MessageBox.Show(appTexts.ParameterName(66), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return(false);
                        }

                        for (int i1 = 0; i1 < 4; i1++)
                        {
                            line       = sr.ReadLine();
                            fileParams = ConvertFuncs.LineToUshorts(line);
                            if (fileParams.Count != 4)
                            {
                                MessageBox.Show(appTexts.ParameterName(66), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                                return(false);
                            }
                            else
                            {
                                systemProfile[index++] = fileParams[0];
                                systemProfile[index++] = fileParams[1];
                                systemProfile[index++] = fileParams[2];
                                systemProfile[index++] = fileParams[3];
                            }
                        }
                    }
                }
            }
            catch
            {
                MessageBox.Show(appTexts.ParameterName(66), this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(false);
            }

            textBox1.Text = "0x" + newStartAddr.ToString("X4");
            textBox2.Text = "0x" + (newStartAddr + 16 * newBlockCount - 1).ToString("X4");
            return(true);
        }