Exemple #1
0
        /// <summary>
        /// 读取数据方法,返回数据为处理之后的数据,为双精度浮点数组
        /// </summary>
        /// <param name="dataIdentification">对应数据的标识码</param>
        /// <returns></returns>
        public double[] Read(DataIdentification dataIdentification)   //读取方法负责(状态指令1,电流指令)
        {
            communicationOK = false;
            List <int> list = new List <int>();

            double[] result  = new double[6];
            ReadCmd  readCmd = new ReadCmd();

            readCmd.start       = Start;
            readCmd.address0    = Address.a0;
            readCmd.address1    = Address.a1;
            readCmd.address2    = Address.a2;
            readCmd.address3    = Address.a3;
            readCmd.address4    = Address.a4;
            readCmd.address5    = Address.a5;;
            readCmd.datastart   = Start;
            readCmd.controlCode = (byte)ControlCode.Read;
            readCmd.dataLength  = 0x04;
            readCmd.di0         = (byte)(dic[dataIdentification].di0 + Mask);
            readCmd.di1         = (byte)(dic[dataIdentification].di1 + Mask);
            readCmd.di2         = (byte)(dic[dataIdentification].di2 + Mask);
            readCmd.di3         = (byte)(dic[dataIdentification].di3 + Mask);
            readCmd.cs          = GetCS(new byte[] { readCmd.start, readCmd.address0, readCmd.address1, readCmd.address2, readCmd.address3, readCmd.address4, readCmd.address5
                                                     , readCmd.datastart, readCmd.controlCode, readCmd.dataLength, readCmd.di0, readCmd.di1, readCmd.di2, readCmd.di3 }, 14);
            readCmd.end = End;
            byte[] bytes = { readCmd.start, readCmd.address0,  readCmd.address1,    readCmd.address2,   readCmd.address3, readCmd.address4, readCmd.address5
                             ,              readCmd.datastart, readCmd.controlCode, readCmd.dataLength, readCmd.di0,      readCmd.di1,      readCmd.di2,readCmd.di3, readCmd.cs, readCmd.end };
            byte[] ByteBack = SendData(bytes);
            if ((ByteBack[0] == Start) && (ByteBack[8] == 0x91)) //返回数据的判断
            {
                switch (dataIdentification)
                {
                case DataIdentification.ReadCurrent:        //get three phase current
                    result = GetThreePhaseCurrent(ByteBack);
                    break;

                case DataIdentification.ReadVoltage:       //get three phase voltage
                    result = GetThreePhaseVoltage(ByteBack);
                    break;

                case DataIdentification.ReadResidualCurrent:
                    result = GetResidualCurrent(ByteBack);
                    break;

                case DataIdentification.GetSwitchProtect:
                    result = GetProtectData(ByteBack);
                    break;
                }
            }
            return(result);
        }
Exemple #2
0
 /// <summary>
 /// 远程调试模式
 /// </summary>
 /// <param name="data"></param>
 /// <param name="dataIdentification">不同调试功能的标识符</param>
 /// <returns></returns>
 public bool Debugging(DataIdentification dataIdentification)
 {
     communicationOK = false;
     byte[] ByteSend = new byte[]
     {
         Start, Address.a0, Address.a1, Address.a2, Address.a3, Address.a4, Address.a5, Start, (byte)ControlCode.debugging, 12,
         (byte)(dic[dataIdentification].di0 + Mask), (byte)(dic[dataIdentification].di1 + Mask), (byte)(dic[dataIdentification].di2 + Mask),
         (byte)(dic[dataIdentification].di3 + Mask), (byte)(Password.pa + Mask), (byte)(Password.p0 + Mask), (byte)(Password.p1 + Mask)
         , (byte)(Password.p2 + Mask), (byte)(Operator.c0 + Mask), (byte)(Operator.c1 + Mask), (byte)(Operator.c2 + Mask), (byte)(Operator.c3 + Mask)
         , 0, 0x16
     };
     ByteSend[ByteSend.Length - 2] = GetCS(ByteSend, ByteSend.Length - 2);
     byte[] ByteBack = SendData(ByteSend);
     if ((ByteBack[0] == Start) && (ByteBack[8] == 0x9f) && (ByteBack[9] != 0x00))
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
Exemple #3
0
        /// <summary>
        /// 校对指令
        /// </summary>
        /// <param name="data"></param>
        /// <param name="dataIdentification"></param>
        /// <returns></returns>
        public double[] Proof(int data, DataIdentification dataIdentification)
        {
            communicationOK = false;
            byte[] ByteSend = new byte[]
            {
                Start, Address.a0, Address.a1, Address.a2, Address.a3, Address.a4, Address.a5, Start, (byte)ControlCode.debugging, 13,
                (byte)(dic[dataIdentification].di0 + Mask), (byte)(dic[dataIdentification].di1 + Mask), (byte)(dic[dataIdentification].di2 + Mask),
                (byte)(dic[dataIdentification].di3 + Mask), (byte)(Password.pa + Mask), (byte)(Password.p0 + Mask), (byte)(Password.p1 + Mask)
                , (byte)(Password.p2 + Mask), (byte)(Operator.c0 + Mask), (byte)(Operator.c1 + Mask), (byte)(Operator.c2 + Mask), (byte)(Operator.c3 + Mask)
                , (byte)(data + Mask), 0, 0x16
            };
            ByteSend[ByteSend.Length - 2] = GetCS(ByteSend, ByteSend.Length - 2);
            byte[] ByteBack = SendData(ByteSend);
            if ((ByteBack[0] == Start) && (ByteBack[8] == 0x9f) && (ByteBack[9] != 0x00))
            {
                switch (dataIdentification)
                {
                case DataIdentification.CurrentProofreading1:
                    return(GetThreePhaseCurrent(ByteBack));

                case DataIdentification.CurrentProofreading2:
                    return(GetThreePhaseCurrent(ByteBack));

                case DataIdentification.CurrentProofreading3:
                    return(GetThreePhaseCurrent(ByteBack));

                case DataIdentification.CurrentProofreading4:
                    return(GetThreePhaseCurrent(ByteBack));

                case DataIdentification.CurrentProofreading5:
                    return(GetThreePhaseCurrent(ByteBack));

                case DataIdentification.VoltageProofreading1:
                    return(GetThreePhaseVoltage(ByteBack));

                case DataIdentification.VoltageProofreading2:
                    return(GetThreePhaseVoltage(ByteBack));

                case DataIdentification.VoltageProofreading3:
                    return(GetThreePhaseVoltage(ByteBack));

                case DataIdentification.VoltageProofreading4:
                    return(GetThreePhaseVoltage(ByteBack));

                case DataIdentification.VoltageProofreading5:
                    return(GetThreePhaseVoltage(ByteBack));

                case DataIdentification.ResidualCurrentProofreading1:
                    return(GetResidualCurrent(ByteBack));

                case DataIdentification.ResidualCurrentProofreading2:
                    return(GetResidualCurrent(ByteBack));

                case DataIdentification.ResidualCurrentProofreading3:
                    return(GetResidualCurrent(ByteBack));

                case DataIdentification.ResidualCurrentProofreading4:
                    return(GetResidualCurrent(ByteBack));

                case DataIdentification.ResidualCurrentProofreading5:
                    return(GetResidualCurrent(ByteBack));

                case DataIdentification.FactorySet:
                    return(new double[] { 0 });

                case DataIdentification.ReadPeakValue:
                    return(GetPeakValue(ByteBack));

                case DataIdentification.ClearTestRecord:
                    return(new double[] { 0 });

                default:
                    break;
                }
            }
            return(new double[] { -1 });
        }
Exemple #4
0
 /// <summary>
 /// 写数据
 /// </summary>
 /// <param name="dt"></param>
 /// <param name="data"></param>
 /// <returns></returns>
 public bool Write(DataIdentification dt, int data)
 {
     communicationOK = false;
     return(true);
 }