Beispiel #1
0
        public static AdapterDataBase db;// = new AdapterDataBase("");//TODO:ADD CONNECTION STRING

        public static void Preloading()
        {
            string FileName = Application.StartupPath + "\\" + SQLOutAdapterConfigMgt._FileName;

            //TestCase.BuildTestConfigFile();   //DEBUG


            Log.WriteAppStart(Application.StartupPath + "\\SQLOutboundAdapter.log");

            db = new AdapterDataBase("");
            if (!SQLOutAdapterConfigMgt.Load(FileName))
            {
                Log.Write(LogType.Error, "Load configuration failed. \r\n" + FileName + "\r\n");//+ SQLOutAdapterConfigMgt.LastError);
            }
            else
            {
                //db.ConnectionString = SQLOutAdapterConfigMgt.SQLOutAdapterConfig.ThirdPartyInteractConfig.ConnectionParameter.ConnectionStr;
                if (SQLOutAdapterConfigMgt.SQLOutAdapterConfig.ThirdPartyInteractConfig.ConnectionParameter.FileConnection)
                {
                    db.ConnectionString = SQLOutAdapterConfigMgt.SQLOutAdapterConfig.ThirdPartyInteractConfig.ConnectionParameter.FileConnectionString;
                }
                else
                {
                    db.ConnectionString = SQLOutAdapterConfigMgt.SQLOutAdapterConfig.ThirdPartyInteractConfig.ConnectionParameter.ConnectionStr;
                }
            }
        }
Beispiel #2
0
        private void ButtonConnectDevice_Click(object sender, EventArgs e)
        {
            try
            {
                if (modbusClient == null || modbusClient.Connected == false)
                {
                    connectSKU(IpAdress.Text, Convert.ToInt32(Port.Text));

                    statIpAdress = IpAdress.Text;
                    statPort     = Port.Text;
                }
                if (modbusClient != null && modbusClient.Connected == true)
                {
                    float[] regf = new float[50];
                    int[]   regi = new int[50];
                    for (int i = 10; i < 60; i++)
                    {
                        regi[i - 10] = RegisterValueConvertToInt(modbusClient, i);
                        regf[i - 10] = RegisterValueConvertToFloat(modbusClient, i);
                    }
                    textBoxNumberBrigada.Text = RegisterValueConvertToInt(modbusClient, 28).ToString();//Id текущей бригады 27 регистр
                    if (RegisterValueConvertToInt(modbusClient, 8) == 1)
                    {
                        radioButton2.Checked = true;
                    }
                    else if (RegisterValueConvertToInt(modbusClient, 8) == 0)
                    {
                        radioButton1.Checked = true;
                    }
                    LabelTimeNow.Text = getDateTimeFromDevice();//время и дата(число секунд прошедших с 1.1.2013 0х420,0х421)
                    if (!SubscribeToTimerEvent)
                    {
                        TimeSubscribe();
                    }
                    textBoxPorogLog.Text = RegisterValueConvertToFloat(modbusClient, 58).ToString(); //Порог логирования
                    textBoxPorogK2.Text  = RegisterValueConvertToFloat(modbusClient, 54).ToString(); //Порог K1 оповщатель
                    textBoxPorogK1.Text  = RegisterValueConvertToFloat(modbusClient, 55).ToString(); //Порог K2 отс клапан
                    textBoxImpVP.Text    = RegisterValueConvertToInt(modbusClient, 59).ToString();   //Импульс на оборот ВП
                    textBoxImpNP.Text    = RegisterValueConvertToInt(modbusClient, 99).ToString();   //Импульс на оборот НП
                    LabelTimeNow.Visible = true;
                    //точки апроксимации
                    if (comboBox1.SelectedIndex < 1)
                    {
                        comboBox1.SelectedIndex = 0;
                        textBox2mA.Text         = RegisterValueConvertToFloat(modbusClient, 62).ToString();
                        textBox3mA.Text         = RegisterValueConvertToFloat(modbusClient, 64).ToString();
                        textBox4mA.Text         = RegisterValueConvertToFloat(modbusClient, 66).ToString();
                        textBox5mA.Text         = RegisterValueConvertToFloat(modbusClient, 68).ToString();
                        textBox6mA.Text         = RegisterValueConvertToFloat(modbusClient, 70).ToString();
                        textBox7mA.Text         = RegisterValueConvertToFloat(modbusClient, 72).ToString();
                        textBox8mA.Text         = RegisterValueConvertToFloat(modbusClient, 74).ToString();
                        textBox9mA.Text         = RegisterValueConvertToFloat(modbusClient, 76).ToString();
                        textBox10mA.Text        = RegisterValueConvertToFloat(modbusClient, 78).ToString();
                        textBox2kH.Text         = RegisterValueConvertToFloat(modbusClient, 80).ToString();
                        textBox3kH.Text         = RegisterValueConvertToFloat(modbusClient, 82).ToString();
                        textBox4kH.Text         = RegisterValueConvertToFloat(modbusClient, 84).ToString();
                        textBox5kH.Text         = RegisterValueConvertToFloat(modbusClient, 86).ToString();
                        textBox6kH.Text         = RegisterValueConvertToFloat(modbusClient, 88).ToString();
                        textBox7kH.Text         = RegisterValueConvertToFloat(modbusClient, 90).ToString();
                        textBox8kH.Text         = RegisterValueConvertToFloat(modbusClient, 92).ToString();
                        textBox9kH.Text         = RegisterValueConvertToFloat(modbusClient, 94).ToString();
                        textBox10kH.Text        = RegisterValueConvertToFloat(modbusClient, 96).ToString();
                    }
                    else
                    {
                        comboBox1.SelectedIndex = 1;
                        textBox2mA.Text         = RegisterValueConvertToFloat(modbusClient, 102).ToString();
                        textBox3mA.Text         = RegisterValueConvertToFloat(modbusClient, 104).ToString();
                        textBox4mA.Text         = RegisterValueConvertToFloat(modbusClient, 106).ToString();
                        textBox5mA.Text         = RegisterValueConvertToFloat(modbusClient, 108).ToString();
                        textBox6mA.Text         = RegisterValueConvertToFloat(modbusClient, 110).ToString();
                        textBox7mA.Text         = RegisterValueConvertToFloat(modbusClient, 112).ToString();
                        textBox8mA.Text         = RegisterValueConvertToFloat(modbusClient, 114).ToString();
                        textBox9mA.Text         = RegisterValueConvertToFloat(modbusClient, 116).ToString();
                        textBox10mA.Text        = RegisterValueConvertToFloat(modbusClient, 118).ToString();
                        textBox2kH.Text         = RegisterValueConvertToFloat(modbusClient, 120).ToString();
                        textBox3kH.Text         = RegisterValueConvertToFloat(modbusClient, 122).ToString();
                        textBox4kH.Text         = RegisterValueConvertToFloat(modbusClient, 124).ToString();
                        textBox5kH.Text         = RegisterValueConvertToFloat(modbusClient, 126).ToString();
                        textBox6kH.Text         = RegisterValueConvertToFloat(modbusClient, 128).ToString();
                        textBox7kH.Text         = RegisterValueConvertToFloat(modbusClient, 130).ToString();
                        textBox8kH.Text         = RegisterValueConvertToFloat(modbusClient, 132).ToString();
                        textBox9kH.Text         = RegisterValueConvertToFloat(modbusClient, 134).ToString();
                        textBox10kH.Text        = RegisterValueConvertToFloat(modbusClient, 136).ToString();
                    }
                }
            }
            catch (Exception ex)
            {
                LabelTimeNow.Visible = false;
                if (ex.Message == "connection timed out")
                {
                    MessageBox.Show("Подключение не установленно. Время ожидания подключения истекло");
                }
                else
                {
                    MessageBox.Show(ex.Message);
                }
            }
            AdapterDataBase.RecordDBDataLogsAsync();
        }