using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Threading;
using NetSDKCS;
using System.Runtime.InteropServices;

namespace NetClient
{
    public class IVSEventClient : BaseClient
    {
        private IVSEventManager m_IVSEventManager;
        private readonly object m_Lock = new object();
        private List<IntPtr> m_HandleList = new List<IntPtr>();
        public List<IntPtr> HandleList
        {
            get { return m_HandleList; }
        }

        private readonly fAnalyzerDataCallBack m_AnalyzerDataCallBack;
        public event IVSEventHandler IVSDataReceived;
        private void OnIVSDataReceived(object sender, IVSEventArgs args)
        {
            if (IVSDataReceived != null)
            {
                if (LoginID == args.LoginID)
                {
                    IVSDataReceived(this, args);
                }
            }
        }

        public IVSEventClient()
        {
            m_IVSEventManager = IVSEventManager.GetInstance();
            m_AnalyzerDataCallBack = m_IVSEventManager.GetCallBack();
            m_IVSEventManager.AddEvent(OnIVSDataReceived);
        }

        ~IVSEventClient()
        {
            m_IVSEventManager.RemoveEvent(OnIVSDataReceived);
        }

        public IntPtr IVSStartListen(int channelID, bool needPicture)
        {
            IntPtr n_handle = IntPtr.Zero;
            try
            {
                n_handle = NETClient.RealLoadPicture(LoginID, channelID, (uint)EM_EVENT_IVS_TYPE.ALL, needPicture, m_AnalyzerDataCallBack, LoginID, IntPtr.Zero);
                if (n_handle != IntPtr.Zero)
                {
                    lock (m_Lock)
                    {
                        m_HandleList.Add(n_handle);
                    }
                }
            }
            catch (NetSDKCS.NETClientExcetion ex)
            {
                throw new NETClientExcetion(ex.ErrorCode, ex.Message);
            }
            return n_handle;
        }

        public void IVSStop(IntPtr handle)
        {
            bool res = false;
            try
            {
                res = NETClient.StopLoadPic(handle);
                lock (m_Lock)
                {
                    m_HandleList.Remove(handle);
                }
            }
            catch (NetSDKCS.NETClientExcetion ex)
            {
                throw new NETClientExcetion(ex.ErrorCode, ex.Message);
            }
        }

        public void IVSStop()
        {
            lock (m_Lock)
            {
                foreach (var item in m_HandleList)
                {
                    try
                    {
                        NETClient.StopLoadPic(item);
                    }
                    catch
                    {
                        continue;
                    }
                }
                m_HandleList.Clear();
            }
        }

        public override void Logout()
        {
            m_IVSEventManager.RemoveEvent(OnIVSDataReceived);
            base.Logout();
        }

        public override void Dispose()
        {
            m_IVSEventManager.RemoveEvent(OnIVSDataReceived);
            base.Dispose();
        }
    }

    public sealed class IVSEventManager : DispatcherObject
    {
        private readonly fAnalyzerDataCallBack m_analyzerDataCallBack;
        private event IVSEventHandler m_IVSEventReceived;
        private void OnIVSEventReceived(object sender, IVSEventArgs args)
        {
            if (m_IVSEventReceived != null)
            {
                m_IVSEventReceived(sender, args);
            }
        }

        private IVSEventManager()
        {
            m_analyzerDataCallBack = new fAnalyzerDataCallBack(AnalyzerDataCallBack);
        }

        private int AnalyzerDataCallBack(IntPtr lAnalyzerHandle, uint dwAlarmType, IntPtr pAlarmInfo, IntPtr pBuffer, uint dwBufSize, IntPtr dwUser, int nSequence, IntPtr reserved)
        {
            object obj = PtrToObj(pAlarmInfo, dwAlarmType);
            byte[] data = new byte[dwBufSize];
            Marshal.Copy(pBuffer, data, 0, (int)dwBufSize);
            IVSEventArgs arg = new IVSEventArgs(dwUser, lAnalyzerHandle, (EM_EVENT_IVS_TYPE)dwAlarmType, obj, data, nSequence);
            Dispatcher.BeginInvoke((Action<object, IVSEventArgs>)OnIVSEventReceived, null, arg);
            return 0;
        }

        private object PtrToObj(IntPtr source, uint dwAlarmType)
        {
            object obj = null;
            switch ((EM_EVENT_IVS_TYPE)dwAlarmType)
            {
                case EM_EVENT_IVS_TYPE.TRAFFIC_RUNREDLIGHT:
                    {
                        NET_DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO info = new NET_DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFICJUNCTION:
                    {
                        NET_DEV_EVENT_TRAFFICJUNCTION_INFO info = new NET_DEV_EVENT_TRAFFICJUNCTION_INFO();
                        info = (NET_DEV_EVENT_TRAFFICJUNCTION_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFICJUNCTION_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFICGATE:
                    {
                        NET_DEV_EVENT_TRAFFICGATE_INFO info = new NET_DEV_EVENT_TRAFFICGATE_INFO();
                        info = (NET_DEV_EVENT_TRAFFICGATE_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFICGATE_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_TURNLEFT:
                    {
                        NET_DEV_EVENT_TRAFFIC_TURNLEFT_INFO info = new NET_DEV_EVENT_TRAFFIC_TURNLEFT_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_TURNLEFT_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_TURNLEFT_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_TURNRIGHT:
                    {
                        NET_DEV_EVENT_TRAFFIC_TURNRIGHT_INFO info = new NET_DEV_EVENT_TRAFFIC_TURNRIGHT_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_TURNRIGHT_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_TURNRIGHT_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_OVERSPEED:
                    {
                        NET_DEV_EVENT_TRAFFIC_OVERSPEED_INFO info = new NET_DEV_EVENT_TRAFFIC_OVERSPEED_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_OVERSPEED_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_OVERSPEED_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_UNDERSPEED:
                    {
                        NET_DEV_EVENT_TRAFFIC_UNDERSPEED_INFO info = new NET_DEV_EVENT_TRAFFIC_UNDERSPEED_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_UNDERSPEED_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_UNDERSPEED_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_MANUALSNAP:
                    {
                        NET_DEV_EVENT_TRAFFIC_MANUALSNAP_INFO info = new NET_DEV_EVENT_TRAFFIC_MANUALSNAP_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_MANUALSNAP_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_MANUALSNAP_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_PARKINGSPACEPARKING:
                    {
                        NET_DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO info = new NET_DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.TRAFFIC_PARKINGSPACENOPARKING:
                    {
                        NET_DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO info = new NET_DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO();
                        info = (NET_DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO));
                        obj = info;
                        break;
                    }
                case EM_EVENT_IVS_TYPE.PARKINGDETECTION:
                    {
                        NET_DEV_EVENT_PARKINGDETECTION_INFO info = new NET_DEV_EVENT_PARKINGDETECTION_INFO();
                        info = (NET_DEV_EVENT_PARKINGDETECTION_INFO)Marshal.PtrToStructure(source, typeof(NET_DEV_EVENT_PARKINGDETECTION_INFO));
                        obj = info;
                        break;
                    }
                default:
                    break;
            }
            return obj;
        }

        public static IVSEventManager GetInstance()
        {
            if (ClientManager.IVSEventInstance == null)
            {
                lock (ClientManager.IVSEvnetLock)
                {
                    if (ClientManager.IVSEventInstance == null)
                    {
                        ClientManager.IVSEventInstance = new IVSEventManager();
                    }
                }
            }
            return ClientManager.IVSEventInstance;
        }

        public fAnalyzerDataCallBack GetCallBack()
        {
            return m_analyzerDataCallBack;
        }

        public void AddEvent(IVSEventHandler handler)
        {
            m_IVSEventReceived += handler;
        }

        public void RemoveEvent(IVSEventHandler handler)
        {
            m_IVSEventReceived -= handler;
        }
    }

    public enum EM_EVENT_IVS_TYPE
    {
        ALL = 0x00000001,		                // subscription all event
        CROSSLINEDETECTION = 0x00000002,		                // cross line event(Corresponding to NET_DEV_EVENT_CROSSLINE_INFO)
        CROSSREGIONDETECTION = 0x00000003,		                // cross region event(Corresponding to NET_DEV_EVENT_CROSSREGION_INFO)
        PASTEDETECTION = 0x00000004,		                // past event(Corresponding to NET_DEV_EVENT_PASTE_INFO)
        LEFTDETECTION = 0x00000005,		                // left event(Corresponding to NET_DEV_EVENT_LEFT_INFO)
        STAYDETECTION = 0x00000006,		                // stay event(Corresponding to NET_DEV_EVENT_STAY_INFO)
        WANDERDETECTION = 0x00000007,		                // wander event(Corresponding to NET_DEV_EVENT_WANDER_INFO)
        PRESERVATION = 0x00000008,		                // reservation event(Corresponding to NET_DEV_EVENT_PRESERVATION_INFO) 
        MOVEDETECTION = 0x00000009,		                // move event(Corresponding to NET_DEV_EVENT_MOVE_INFO)
        TAILDETECTION = 0x0000000A,		                // tail event(Corresponding to NET_DEV_EVENT_TAIL_INFO)
        RIOTERDETECTION = 0x0000000B,		                // rioter event(Corresponding to NET_DEV_EVENT_RIOTERL_INFO)
        FIREDETECTION = 0x0000000C,		                // fire event(Corresponding to NET_DEV_EVENT_FIRE_INFO)
        SMOKEDETECTION = 0x0000000D,		                // smoke event(Corresponding to NET_DEV_EVENT_SMOKE_INFO)
        FIGHTDETECTION = 0x0000000E,		                // fight event(Corresponding to NET_DEV_EVENT_FLOWSTAT_INFO)
        FLOWSTAT = 0x0000000F,		                // flow stat event(Corresponding to NET_DEV_EVENT_FLOWSTAT_INFO)
        NUMBERSTAT = 0x00000010,		                // number stat event(Corresponding to NET_DEV_EVENT_NUMBERSTAT_INFO)
        CAMERACOVERDDETECTION = 0x00000011,		                // camera cover event
        CAMERAMOVEDDETECTION = 0x00000012,		                // camera move event
        VIDEOABNORMALDETECTION = 0x00000013,		                // video abnormal event(Corresponding to NET_DEV_EVENT_VIDEOABNORMALDETECTION_INFO)
        VIDEOBADDETECTION = 0x00000014,		                // video bad event
        TRAFFICCONTROL = 0x00000015,		                // traffic control event(Corresponding to NET_DEV_EVENT_TRAFFICCONTROL_INFO)
        TRAFFICACCIDENT = 0x00000016,		                // traffic accident event(Corresponding to NET_DEV_EVENT_TRAFFICACCIDENT_INFO)
        TRAFFICJUNCTION = 0x00000017,		                // traffic junction event(Corresponding to NET_DEV_EVENT_TRAFFICJUNCTION_INFO)
        TRAFFICGATE = 0x00000018,		                // traffic gate event(Corresponding to NET_DEV_EVENT_TRAFFICGATE_INFO)
        TRAFFICSNAPSHOT = 0x00000019,		                // traffic snapshot(Corresponding to NET_DEV_EVENT_TRAFFICSNAPSHOT_INFO)
        FACEDETECT = 0x0000001A,                       // face detection(Corresponding to NET_DEV_EVENT_FACEDETECT_INFO)
        TRAFFICJAM = 0x0000001B,                       // traffic-Jam(Corresponding to NET_DEV_EVENT_TRAFFICJAM_INFO)
        TRAFFIC_RUNREDLIGHT = 0x00000100,		                // traffic-RunRedLight(Corresponding to NET_DEV_EVENT_TRAFFIC_RUNREDLIGHT_INFO)
        TRAFFIC_OVERLINE = 0x00000101,		                // traffic-Overline(Corresponding to NET_DEV_EVENT_TRAFFIC_OVERLINE_INFO)
        TRAFFIC_RETROGRADE = 0x00000102,		                // traffic-Retrograde(Corresponding to NET_DEV_EVENT_TRAFFIC_RETROGRADE_INFO)
        TRAFFIC_TURNLEFT = 0x00000103,		                // traffic-TurnLeft(Corresponding to NET_DEV_EVENT_TRAFFIC_TURNLEFT_INFO)
        TRAFFIC_TURNRIGHT = 0x00000104,		                // traffic-TurnRight(Corresponding to NET_DEV_EVENT_TRAFFIC_TURNRIGHT_INFO)	
        TRAFFIC_UTURN = 0x00000105,		                // traffic-Uturn(Corresponding to NET_DEV_EVENT_TRAFFIC_UTURN_INFO)
        TRAFFIC_OVERSPEED = 0x00000106,		                // traffic-Overspeed(Corresponding to NET_DEV_EVENT_TRAFFIC_OVERSPEED_INFO)
        TRAFFIC_UNDERSPEED = 0x00000107,		                // traffic-Underspeed(Corresponding to NET_DEV_EVENT_TRAFFIC_UNDERSPEED_INFO)
        TRAFFIC_PARKING = 0x00000108,                       // traffic-Parking(Corresponding to NET_DEV_EVENT_TRAFFIC_PARKING_INFO)
        TRAFFIC_WRONGROUTE = 0x00000109,                       // traffic-WrongRoute(Corresponding to NET_DEV_EVENT_TRAFFIC_WRONGROUTE_INFO)
        TRAFFIC_CROSSLANE = 0x0000010A,                       // traffic-CrossLane(Corresponding to NET_DEV_EVENT_TRAFFIC_CROSSLANE_INFO)
        TRAFFIC_OVERYELLOWLINE = 0x0000010B,                       // traffic-OverYellowLine(Corresponding to NET_DEV_EVENT_TRAFFIC_OVERYELLOWLINE_INFO)
        TRAFFIC_DRIVINGONSHOULDER = 0x0000010C,                       // traffic-DrivingOnShoulder(Corresponding to NET_DEV_EVENT_TRAFFIC_DRIVINGONSHOULDER_INFO)   
        TRAFFIC_YELLOWPLATEINLANE = 0x0000010E,                       // traffic-YellowPlateInLane(Corresponding to NET_DEV_EVENT_TRAFFIC_YELLOWPLATEINLANE_INFO)
        TRAFFIC_PEDESTRAINPRIORITY = 0x0000010F,		                // Traffic offense-Pedestral has higher priority at the  crosswalk(Corresponding to NET_DEV_EVENT_TRAFFIC_PEDESTRAINPRIORITY_INFO)
        CROSSFENCEDETECTION = 0x0000011F,                       // cross fence(Corresponding to NET_DEV_EVENT_CROSSFENCEDETECTION_INFO) 
        ELECTROSPARKDETECTION = 0X00000110,                       // ElectroSpark event(Corresponding to NET_DEV_EVENT_ELECTROSPARK_INFO) 
        TRAFFIC_NOPASSING = 0x00000111,                       // no passing(Corresponding to NET_DEV_EVENT_TRAFFIC_NOPASSING_INFO)
        ABNORMALRUNDETECTION = 0x00000112,                       // abnormal run(Corresponding to NET_DEV_EVENT_ABNORMALRUNDETECTION_INFO)
        RETROGRADEDETECTION = 0x00000113,                       // retrograde(Corresponding to NET_DEV_EVENT_RETROGRADEDETECTION_INFO)
        INREGIONDETECTION = 0x00000114,                       // in region detection(Corresponding to NET_DEV_EVENT_INREGIONDETECTION_INFO)
        TAKENAWAYDETECTION = 0x00000115,                       // taking away things(Corresponding to NET_DEV_EVENT_TAKENAWAYDETECTION_INFO)
        PARKINGDETECTION = 0x00000116,                       // parking(Corresponding to NET_DEV_EVENT_PARKINGDETECTION_INFO)
        FACERECOGNITION = 0x00000117,		                // face recognition(Corresponding to NET_DEV_EVENT_FACERECOGNITION_INFO)
        TRAFFIC_MANUALSNAP = 0x00000118,                       // manual snap(Corresponding to NET_DEV_EVENT_TRAFFIC_MANUALSNAP_INFO)
        TRAFFIC_FLOWSTATE = 0x00000119,		                // traffic flow state(Corresponding to NET_DEV_EVENT_TRAFFIC_FLOW_STATE)
        TRAFFIC_STAY = 0x0000011A,		                // traffic stay(Corresponding to NET_DEV_EVENT_TRAFFIC_STAY_INFO)
        TRAFFIC_VEHICLEINROUTE = 0x0000011B,		                // traffic vehicle route(Corresponding to NET_DEV_EVENT_TRAFFIC_VEHICLEINROUTE_INFO)
        ALARM_MOTIONDETECT = 0x0000011C,                       // motion detect(Corresponding to NET_DEV_EVENT_ALARM_INFO)
        ALARM_LOCALALARM = 0x0000011D,                       // local alarm(Corresponding to NET_DEV_EVENT_ALARM_INFO)
        PRISONERRISEDETECTION = 0x0000011E,		                // prisoner rise detect(Corresponding to NET_DEV_EVENT_PRISONERRISEDETECTION_INFO)
        TRAFFIC_TOLLGATE = 0x00000120,		                // traffic tollgate(Corresponding to NET_DEV_EVENT_TRAFFICJUNCTION_INFO)
        DENSITYDETECTION = 0x00000121,                       // density detection of persons(Corresponding to NET_DEV_EVENT_DENSITYDETECTION_INFO)
        VIDEODIAGNOSIS = 0x00000122,		                // video diagnosis result(Corresponding to NET_VIDEODIAGNOSIS_COMMON_INFO and NET_REAL_DIAGNOSIS_RESULT)
        QUEUEDETECTION = 0x00000123,                       // queue detection(Corresponding to NET_DEV_EVENT_QUEUEDETECTION_INFO)
        TRAFFIC_VEHICLEINBUSROUTE = 0x00000124,                       // take up in bus route(Corresponding to NET_DEV_EVENT_TRAFFIC_VEHICLEINBUSROUTE_INFO)
        TRAFFIC_BACKING = 0x00000125,                       // illegal astern(Corresponding to NET_DEV_EVENT_IVS_TRAFFIC_BACKING_INFO) 
        AUDIO_ABNORMALDETECTION = 0x00000126,                       // audio abnormity(Corresponding to NET_DEV_EVENT_IVS_AUDIO_ABNORMALDETECTION_INFO)
        TRAFFIC_RUNYELLOWLIGHT = 0x00000127,                       // run yellow light(Corresponding to NET_DEV_EVENT_TRAFFIC_RUNYELLOWLIGHT_INFO)
        CLIMBDETECTION = 0x00000128,                       // climb detection(Corresponding to NET_DEV_EVENT_IVS_CLIMB_INFO) 
        LEAVEDETECTION = 0x00000129,                       // leave detection(Corresponding to NET_DEV_EVENT_IVS_LEAVE_INFO)
        TRAFFIC_PARKINGONYELLOWBOX = 0x0000012A,                       // parking on yellow box(Corresponding to NET_DEV_EVENT_TRAFFIC_PARKINGONYELLOWBOX_INFO)
        TRAFFIC_PARKINGSPACEPARKING = 0x0000012B,                       // parking space parking(Corresponding to NET_DEV_EVENT_TRAFFIC_PARKINGSPACEPARKING_INFO)
        TRAFFIC_PARKINGSPACENOPARKING = 0x0000012C,                       // parking space no parking(Corresponding to NET_DEV_EVENT_TRAFFIC_PARKINGSPACENOPARKING_INFO)
        TRAFFIC_PEDESTRAIN = 0x0000012D,                       // passerby(Corresponding to NET_DEV_EVENT_TRAFFIC_PEDESTRAIN_INFO)
        TRAFFIC_THROW = 0x0000012E,                       // throw(Corresponding to NET_DEV_EVENT_TRAFFIC_THROW_INFO)
        TRAFFIC_IDLE = 0x0000012F,                       // idle(Corresponding to NET_DEV_EVENT_TRAFFIC_IDLE_INFO)
        ALARM_VEHICLEACC = 0x00000130,                       // Vehicle ACC power outage alarm events(Corresponding to NET_DEV_EVENT_ALARM_VEHICLEACC_INFO)
        ALARM_VEHICLE_TURNOVER = 0x00000131,                       // Vehicle rollover alarm events(Corresponding to NET_DEV_EVENT_VEHICEL_ALARM_INFO)
        ALARM_VEHICLE_COLLISION = 0x00000132,                       // Vehicle crash alarm events(Corresponding to NET_DEV_EVENT_VEHICEL_ALARM_INFO)
        ALARM_VEHICLE_LARGE_ANGLE = 0x00000133,                       // On-board camera large Angle turn events
        TRAFFIC_PARKINGSPACEOVERLINE = 0x00000134,                       // Parking line pressing events(Corresponding to NET_DEV_EVENT_TRAFFIC_PARKINGSPACEOVERLINE_INFO)
        MULTISCENESWITCH = 0x00000135,                       // Many scenes switching events(Corresponding to NET_DEV_EVENT_IVS_MULTI_SCENE_SWICH_INFO)
        TRAFFIC_RESTRICTED_PLATE = 0X00000136,                       // Limited license plate event(Corresponding to NET_DEV_EVENT_TRAFFIC_RESTRICTED_PLATE)
        TRAFFIC_OVERSTOPLINE = 0X00000137,                       // Cross stop line event(Corresponding to NET_DEV_EVENT_TRAFFIC_OVERSTOPLINE)
        TRAFFIC_WITHOUT_SAFEBELT = 0x00000138,                       // Traffic unfasten seat belt event(Corresponding to NET_DEV_EVENT_TRAFFIC_WITHOUT_SAFEBELT) 
        TRAFFIC_DRIVER_SMOKING = 0x00000139,                       // Driver smoking event(Corresponding to NET_DEV_EVENT_TRAFFIC_DRIVER_SMOKING) 
        TRAFFIC_DRIVER_CALLING = 0x0000013A,                       // Driver call event(Corresponding to NET_DEV_EVENT_TRAFFIC_DRIVER_CALLING) 
        TRAFFIC_PEDESTRAINRUNREDLIGHT = 0x0000013B,                       // Pedestrain red light(Corresponding to NET_DEV_EVENT_TRAFFIC_PEDESTRAINRUNREDLIGHT_INFO)
        TRAFFIC_PASSNOTINORDER = 0x0000013C,                       // Pass not in order(corresponding NET_DEV_EVENT_TRAFFIC_PASSNOTINORDER_INFO)
        OBJECT_DETECTION = 0x00000141,                       // Object feature detection event(Corresponding to NET_DEV_EVENT_TRAFFIC_OBJECT_DETECTION) 
        ALARM_ANALOGALARM = 0x00000150,                       // Analog alarm channel?ˉs alarm event(corresponding NET_DEV_EVENT_ALARM_ANALOGALRM_INFO)
        CROSSLINEDETECTION_EX = 0x00000151,                       // Warning lineexpansion event(Corresponding to NET_DEV_EVENT_CROSSLINE_INFO_EX) 
        ALARM_COMMON = 0x00000152,                       // Normal Record
        ALARM_VIDEOBLIND = 0x00000153,                       // Video tampering event(Corresponding to NET_DEV_EVENT_ALARM_VIDEOBLIND)
        ALARM_VIDEOLOSS = 0x00000154,                       // Video loss event
        GETOUTBEDDETECTION = 0x00000155,		                // Event of getting out bed detection(Corresponding to NET_DEV_EVENT_GETOUTBED_INFO)
        PATROLDETECTION = 0x00000156,		                // Event of patrol detection(Corresponding to NET_DEV_EVENT_PATROL_INFO)
        ONDUTYDETECTION = 0x00000157,		                // Event of on duty detection(Corresponding to NET_DEV_EVENT_ONDUTY_INFO)
        NOANSWERCALL = 0x00000158,                       // Event of VTO do not answer calling request
        STORAGENOTEXIST = 0x00000159,                       // Event of storage do not exist
        STORAGELOWSPACE = 0x0000015A,                       // Event of storage space low
        STORAGEFAILURE = 0x0000015B,                       // Event of storage failure
        PROFILEALARMTRANSMIT = 0x0000015C,                       // Event of profile alarm transmit
        VIDEOSTATIC = 0x0000015D,                       // Event of static video detect(corresponding NET_DEV_EVENT_ALARM_VIDEOSTATIC_INFO)
        VIDEOTIMING = 0x0000015E,                       // Event of video timing detect(corresponding NET_DEV_EVENT_ALARM_VIDEOTIMING_INFO)
        HEATMAP = 0x0000015F,                       // Heat map (Corresponding to )
        CITIZENIDCARD = 0x00000160,                       // ID info reading event (Corresponding to NET_DEV_EVENT_ALARM_CITIZENIDCARD_INFO)
        PICINFO = 0x00000161,                       // Image info event(Corresponding to NET_DEV_EVENT_ALARM_PIC_INFO)
        NETPLAYCHECK = 0x00000162,		                // NetPlayCheck event(corresponding NET_DEV_EVENT_ALARM_NETPLAYCHECK_INFO)
        TRAFFIC_JAM_FORBID_INTO = 0x00000163,		                // Jam Forbid into  event(corresponding NET_DEV_EVENT_ALARM_JAMFORBIDINTO_INFO)
        SNAPBYTIME = 0x00000164,                       // Snap by time event(corresponding NET_DEV_EVENT_SNAPBYTIME)
        PTZ_PRESET = 0x00000165,                       // PTZ turn to preset event(corresponding to NET_DEV_EVENT_ALARM_PTZ_PRESET_INFO)
        RFID_INFO = 0x00000166,                       // Event of infrared detect info(corresponding to NET_DEV_EVENT_ALARM_RFID_INFO)
        STANDUPDETECTION = 0X00000167,		                // Event of standing up detection
        QSYTRAFFICCARWEIGHT = 0x00000168,		                // Event of QSYTrafficCarWeight (corresponding to NET_DEV_EVENT_QSYTRAFFICCARWEIGHT_INFO)
        TRAFFIC_COMPAREPLATE = 0x00000169,		                // Event of compare plate(corresponding to NET_DEV_EVENT_TRAFFIC_COMPAREPLATE_INFO)
        SHOOTINGSCORERECOGNITION = 0x0000016A,		                // Event of shooting score recognition(corresponding to NET_CFG_IVS_SHOOTINGSCORERECOGNITION_INFO)
        TRAFFIC_ANALYSE_PRESNAP = 0x00000170,                       // Event of presnap analyse(corresponding to NET_DEV_EVENT_TRAFFIC_ANALYSE_PRESNAP_INFO)

        TRAFFIC_ALL = 0x000001FF,                       // All event start with [TRAFFIC]
        // EVENT_IVS_TRAFFICCONTROL -> EVENT_TRAFFICSNAPSHOT
        // EVENT_IVS_TRAFFIC_RUNREDLIGHT -> EVENT_IVS_TRAFFIC_UNDERSPEED
        VIDEOANALYSE = 0x00000200,                       // All IVS events 
        LINKSD = 0x00000201,                       // LinkSD events(Corresponding to NET_DEV_EVENT_LINK_SD)
        VEHICLEANALYSE = 0x00000202,		                // Vehicle Analyse (Corresponding to NET_DEV_EVENT_VEHICLEANALYSE)

        FLOWRATE = 0x00000203,		                // Flow rate events(Corresponding to NET_DEV_EVENT_FLOWRATE_INFO)
    }
}
