Example #1
0
        private void ScanNet()
        {
            lock (_hyperTerminal)
            {
                _flagScanI = (int)EFlagState.Yes;
                Modules.Clear();
                for (byte address10 = _beginAddress; address10 <= _endAddress; address10++)
                {
                    if (_actionUpdateView != null)
                    {
                        _actionUpdateView(address10.ToString());
                    }
                    string address = NewModuleAbstract.ByteToHex(address10);

                    string stIn = _dlgSendCommand("$" + address + "2");
                    if ((stIn.Length == 9) && (stIn.StartsWith("!" + address)))
                    {
                        stIn = _dlgSendCommand("$" + address + "M");
                        if ((stIn.Length > 3) && (stIn.StartsWith("!" + address)))
                        {
                            string mod = stIn.Substring(3);

                            NewModuleAbstract newModule = null;

                            switch (mod)
                            {
                            case "4019P":
                                newModule = new NewModuleAdam4019Plus(Modules, address);
                                break;
                            }

                            if (newModule != null)
                            {
                                newModule.ReadModuleSettings();
                                Modules.AddModule(address, newModule);
                                if (EventNewModuleFind != null)
                                {
                                    EventNewModuleFind(address);
                                }
                            }
                        }
                    }
                    //if ((_flagScan == EFlagState.Stop) || (address10 == 255)) break;
                    if ((_flagScanI == (int)EFlagState.Stop) || (address10 == 255))
                    {
                        break;
                    }
                }

                if (_actionUpdateView != null)
                {
                    _actionUpdateView(null);
                }
                //_flagScan = EFlagState.No;
                _flagScanI = (int)EFlagState.No;
            }
        }
Example #2
0
        private string GetFf()
        {
            //Возвращает подстроку FF в команде $AA2
            //--var b = (byte) ((ClassAbstractAdamModule.HexToByte(_dataFormat) ?? 0) +
            //--                (_checkSumStatus ? Math.Pow(2, 6) : 0) + (_integrationTime ? Math.Pow(2, 7) : 0));
            //--return ClassAbstractAdamModule.ByteToHex(b);

            var b = (byte)((NewModuleAbstract.HexToByte(_dataFormat) ?? 0) +
                           (_checkSumStatus ? Math.Pow(2, 6) : 0) + (_integrationTime ? Math.Pow(2, 7) : 0));

            return(NewModuleAbstract.ByteToHex(b));
        }
Example #3
0
        private void ScanVirtualNet()
        {
            for (byte i = 0; i <= 255; i++)
            {
                //--string addr = ClassAbstractAdamModule.ByteToHex(i);
                string addr = NewModuleAbstract.ByteToHex(i);
                string stIn = Program.Net.VirtSendCommand("$" + addr + "M");

                GroupBox groupBox;
                if ((i >= 0) && (i <= 31))
                {
                    groupBox = gb001F;
                }
                else if ((i >= 32) && (i <= 63))
                {
                    groupBox = gb203F;
                }
                else if ((i >= 64) && (i <= 95))
                {
                    groupBox = gb405F;
                }
                else if ((i >= 96) && (i <= 127))
                {
                    groupBox = gb607F;
                }
                else if ((i >= 128) && (i <= 159))
                {
                    groupBox = gb809F;
                }
                else if ((i >= 160) && (i <= 191))
                {
                    groupBox = gbA0BF;
                }
                else if ((i >= 182) && (i <= 223))
                {
                    groupBox = gbC0DF;
                }
                else
                {
                    groupBox = gbE0FF;
                }

                ((ComboBox)groupBox.Controls["cb" + addr]).SelectedIndex = (stIn == "!" + addr + "4019P") ? 1 : 0;

                if (i == 255)
                {
                    break;
                }
            }
        }
Example #4
0
        private void tbAddress10_Validating(object sender, CancelEventArgs e)
        {
            byte address10;

            if (byte.TryParse(tbAddress10.Text, NumberStyles.Integer, CultureInfo.InvariantCulture, out address10))
            {
                //tbAddress.Text = ClassAbstractAdamModule.ByteToHex(address10);
                tbAddress.Text = NewModuleAbstract.ByteToHex(address10);
                tbCommand.Text = GetCommandString();
            }
            else
            {
                MessageBox.Show(@"Адрес должен быть целым числом от 0 до 255");
                e.Cancel = true;
                tbAddress10.SelectionStart  = 0;
                tbAddress10.SelectionLength = tbAddress10.Text.Length;
            }
        }
Example #5
0
 public ClassVirtualNet(string modules)
 {
     if (modules != null)
     {
         var mods = modules.Split(new[] { "/" }, StringSplitOptions.None);
         for (int i = 0; i <= mods.GetUpperBound(0); i++)
         {
             switch (mods[i])
             {
             case "4019+":
                 //--string address = ClassAbstractAdamModule.ByteToHex((byte) i);
                 string address = NewModuleAbstract.ByteToHex((byte)i);
                 _virtualNet.Add(address, new ClassVirtualAdamModule4019Plus(address));
                 break;
             }
         }
     }
 }
Example #6
0
 private void butProgramModules_Click(object sender, EventArgs e)
 {
     for (byte i = 0; i <= 255; i++)
     {
         //--string addr = ClassAbstractAdamModule.ByteToHex(i);
         string addr = NewModuleAbstract.ByteToHex(i);
         if (Program.Net.Modules[addr] != null)
         {
             var fmModule = new FormModule4019P(addr);
             fmModule.ShowDialog();
             break;
         }
         if (i == 255)
         {
             MessageBox.Show(@"Модули не найдены" + "\n" +
                             @"Выполните сканирование сети и повторите попытку");
             break;
         }
     }
 }
Example #7
0
        private void butOK_Click(object sender, EventArgs e)
        {
            string virtModules = "";

            for (byte i = 0; i <= 255; i++)
            {
                //--string addr = ClassAbstractAdamModule.ByteToHex(i);
                string addr = NewModuleAbstract.ByteToHex(i);

                GroupBox groupBox;
                if ((i >= 0) && (i <= 31))
                {
                    groupBox = gb001F;
                }
                else if ((i >= 32) && (i <= 63))
                {
                    groupBox = gb203F;
                }
                else if ((i >= 64) && (i <= 95))
                {
                    groupBox = gb405F;
                }
                else if ((i >= 96) && (i <= 127))
                {
                    groupBox = gb607F;
                }
                else if ((i >= 128) && (i <= 159))
                {
                    groupBox = gb809F;
                }
                else if ((i >= 160) && (i <= 191))
                {
                    groupBox = gbA0BF;
                }
                else if ((i >= 182) && (i <= 223))
                {
                    groupBox = gbC0DF;
                }
                else
                {
                    groupBox = gbE0FF;
                }

                if (((groupBox).Controls["cb" + addr]).Text == @"Adam 4019+")
                {
                    virtModules += "4019+/";
                }
                else
                {
                    virtModules += "/";
                }

                if (i == 255)
                {
                    break;
                }
            }

            Program.Net.InitVirtNet(virtModules);

            MessageBox.Show(@"Виртуальная сеть обновлена");
            //Close();
        }