Beispiel #1
0
        /// <summary>
        /// 解析页面下发的命令
        /// </summary>
        /// <param name="instructionType"></param>
        /// <param name="entity"></param>
        /// <returns></returns>
        public override byte[] ParseControlInstruction(ControlCmdType cmdType, object entity)
        {
            //生在发送数据
            byte[] sendBuffer = null;

            //终端号
            string terminalNum = string.Empty;

            //选择命令
            switch (cmdType)
            {
                //监听喊话
                case ControlCmdType.ListenCall:
                    YWListenCallInfoEntity objParam = (YWListenCallInfoEntity)entity;
                    terminalNum = objParam.FullGPSCode.Substring(4);
                    bool isPhone = true;
                    //监听-1 喊话-2
                    if (objParam.ListenCallType == 1)
                        isPhone = false;
                    else if (objParam.ListenCallType == 2)
                        isPhone = true;
                    sendBuffer = CtrlListenPhone(terminalNum, isPhone, objParam.Phone);
                    break;

                //断油断电
                case ControlCmdType.BreakOilCircuitByForce:
                case ControlCmdType.BreakOilCircuitBySmart:

                    //去掉前缀
                    terminalNum = entity as string;
                    terminalNum = terminalNum.Substring(4);
                    sendBuffer = CtrlTelecontrollerReq(terminalNum, false, false);

                    break;

                //供油供电
                case ControlCmdType.SupplyOilCircuit:

                    terminalNum = entity as string;
                    terminalNum = terminalNum.Substring(4);
                    sendBuffer = CtrlTelecontrollerReq(terminalNum, false, true);

                    break;

                //配置报警器
                case ControlCmdType.AllocateAnnounciator:

                    SetAnnounciator setAnnounciator = (SetAnnounciator)entity;
                    SetAnnounciator.FixedData data = setAnnounciator.Data;

                    AnnounciatorState state = new AnnounciatorState();
                    state.AwayRoadAlarm = data.AwayRoadAlarm;
                    state.DoorUnClosed = data.DoorUnClosed;
                    state.InvalidOpenDoorAlarm = data.InvalidOpenDoorAlarm;
                    state.InvalidPower = data.InvalidPower;
                    state.OverBorderAlarm = data.OverBorderAlarm;
                    state.OverSpeeAlarm = data.OverSpeeAlarm;
                    state.PowerOffAlarm = data.PowerOffAlarm;
                    state.RobAlarm = data.RobAlarm;
                    state.ShakeAlarm = data.ShakeAlarm;
                    state.SpanCheck = data.SpanCheck;
                    state.UnderVolAlarm = data.UnderVolAlarm;
                    state.StopCheck = data.StopCheck;

                    sendBuffer = AllocateAnnounciator(setAnnounciator.GPSCode.Substring(4), state);

                    break;
            }

            return sendBuffer;
        }
Beispiel #2
0
        /// <summary>
        /// 配置报警
        /// </summary>
        /// <param name="terminalNum">终端号</param>
        /// <param name="state">报警分类状态:一共12个状态</param>
        /// <returns></returns>
        public byte[] AllocateAnnounciator(string terminalNum, AnnounciatorState state)
        {
            byte[] buffer = new byte[2];

            //最高位为零的全1码,127
            byte Hbit = 0x7f;
            if (state.UnderVolAlarm == 0x00)
            {
                Hbit = 0x3f;
            }
            if (state.RobAlarm == 0x00)
            {
                Hbit = (byte)(0x5f & Hbit);
            }
            if (state.ShakeAlarm == 0x00)
            {
                Hbit = (byte)(0x6f & Hbit);
            }
            if (state.InvalidOpenDoorAlarm == 0x00)
            {
                Hbit = (byte)(0x77 & Hbit);
            }
            if (state.PowerOffAlarm == 0x00)
            {
                Hbit = (byte)(0x7b & Hbit);
            }
            if (state.DoorUnClosed == 0x00)
            {
                Hbit = (byte)(0x7d & Hbit);
            }
            buffer[0] = Hbit;
            //低字节
            byte Lbit = 0x7f;

            if (state.OverBorderAlarm == 0x00)
            {
                Lbit = 0x3f;
            }
            if (state.OverSpeeAlarm == 0x00)
            {
                Lbit = (byte)(0x5f & Hbit);
            }
            if (state.StopCheck == 0x00)
            {
                Lbit = (byte)(0x6f & Hbit);
            }
            if (state.SpanCheck == 0x00)
            {
                Lbit = (byte)(0x77 & Hbit);
            }
            if (state.InvalidPower == 0x00)
            {
                Lbit = (byte)(0x7b & Hbit);
            }
            if (state.AwayRoadAlarm == 0x00)
            {
                Lbit = (byte)(0x7d & Hbit);
            }
            buffer[1] = Lbit;

            return BuildSubmitData(buffer, terminalNum, BusinessType.UserManage, DataType.AllocateAnnounciator);
        }