예제 #1
0
        //_________________________________________________________________________
        // { 0xcd, 0xcc, 0xf6, 0x42 };	//, 0x11,0, 1, 0, 2, 0, 10, 0, 15, 0, 1, 0 };// { 0x0, 0x0, 0, 0x1};	// {  0x30, 0x31, 0x2f, 0x30, 0x31, 0x2f, 0x31, 0x39, 0x37, 0x30, 0x00, 0x30, 0x3a, 0x30, 0x30, 0x3a, 0x30, 0x30, 0x00 };//{,  0x00, 0x00, 0xe4, 0x43 }; //0x00, 0x80, 0xa0, 0x43
        private void BWritePar_Click(object sender, EventArgs e)
        {
            CBDataSave();
            CBDataWriteParSave();
            CBParameterNameSave();

            Properties.Settings.Default.Save();
            int    iID     = int.Parse(TBIDwritePar.Text);
            string sParams = "[\"" + CONST.ПАРАМЕТРЫ.DeviceName.ToString() + "\":\"" + CBDeviceWr.Text + "\"," +
                             CONST.ПАРАМЕТРЫ.Data.ToString() + "\":\"" + CBData.Text + "\"," +
                             CONST.ПАРАМЕТРЫ.ParameterType.ToString() + "\":\"" + CBTypeData.Text + "\"," +
                             CONST.ПАРАМЕТРЫ.ParameterName.ToString() + "\":\"" + CBParameterName.Text + "\"," +
                             CONST.ПАРАМЕТРЫ.RequestName.ToString() + "\":\"MT16\"," +
                             CONST.ПАРАМЕТРЫ.INorOUT.ToString() + "\":\"out" + "\"," +
                             CONST.ПАРАМЕТРЫ.RequestType.ToString() + "\":\"" + CONST.RequestType.Single.ToString() + "\"," +
                             CONST.ПАРАМЕТРЫ.TimeRequest.ToString() + "\":\"" + NTimeResp.Text +
                             "\"]";

            string[] asaDataWritePar = CBDataWritePar.Text.Split(' ');
            int      iSizeData       = CONST.SizeTypeData((TYPE)Enum.Parse(typeof(TYPE), CBTypeData.Text));

            if (iSizeData != asaDataWritePar.Length)
            {
                MessageBox.Show(string.Format("Длина данных [{0}] не равна размеру типа [{1}]", iSizeData, asaDataWritePar.Length));
                return;
            }
            byte[] btaDataWritePar = new byte[iSizeData];
            int    i = 0;

            foreach (var item in asaDataWritePar)
            {
                btaDataWritePar[i++] = byte.Parse(item);
            }
            DRV.WriteValue(iID, sParams, btaDataWritePar);
        }
예제 #2
0
        public void WriteToDev(int iID, int iRow)
        {
            string sParams = "[\"" + CONST.ПАРАМЕТРЫ.DeviceName.ToString() + "\":\"" + GVDataWr.Rows[iRow].Cells[(int)Params.Прибор].Value + "\"," +
                             CONST.ПАРАМЕТРЫ.Data.ToString() + "\":\"" + GVDataWr.Rows[iRow].Cells[(int)Params.Data].Value + "\"," +
                             CONST.ПАРАМЕТРЫ.ParameterType.ToString() + "\":\"" + GVDataWr.Rows[iRow].Cells[(int)Params.Typ].Value + "\"," +
                             CONST.ПАРАМЕТРЫ.ParameterName.ToString() + "\":\"" + GVDataWr.Rows[iRow].Cells[(int)Params.ParamName].Value + "\"," +
                             CONST.ПАРАМЕТРЫ.RequestName.ToString() + "\":\"MT16\"," +
                             CONST.ПАРАМЕТРЫ.INorOUT.ToString() + "\":\"out" + "\"," +
                             CONST.ПАРАМЕТРЫ.RequestType.ToString() + "\":\"" + CONST.RequestType.Single.ToString() + "\"," +
                             CONST.ПАРАМЕТРЫ.TimeRequest.ToString() + "\":\"" + GVDataWr.Rows[iRow].Cells[(int)Params.TimeResp].Value +
                             "\"]";

            FTestDrvs FormOwn = Owner as FTestDrvs;

            EReverce Reverce = (EReverce)Enum.Parse(typeof(EReverce), GVDataWr.Rows[iRow].Cells[(int)Params.ПоследовБайт].Value.ToString());

            byte[] btaDataWritePar = StrToTypeThenBytes(GVDataWr.Rows[iRow].Cells[(int)Params.DataToWr].Value.ToString(),
                                                        GVDataWr.Rows[iRow].Cells[(int)Params.Typ].Value.ToString(),
                                                        Reverce, iRow);

            if (btaDataWritePar != null)
            {
                DRV.WriteValue(iID, sParams, btaDataWritePar);
            }
        }