예제 #1
0
        public void EVENT_T_MV3toString(EVENT_T_MV3 mv3event)
        {
            DateTime eventSTime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((int)mv3event.StartTime);
            DateTime eventETime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((int)mv3event.EndTime);

            mv3EventString.uiEventID   = mv3event.uiEventID.ToString();
            mv3EventString.uiEventType = Enum.Parse(typeof(EventType), mv3event.uiEventType.ToString()).ToString();
            if (mv3event.uiEventType == 13)//for power_on no ch display
            {
                mv3EventString.uiExt = "";
            }
            else
            {
                mv3EventString.uiExt = (mv3event.uiExt + 1).ToString();
            }
            mv3EventString.uiblock_start  = mv3event.uiblock_start.ToString();
            mv3EventString.uiFragID       = mv3event.uiFragID.ToString();
            mv3EventString.StartTime      = eventSTime.ToString("yyyy/M/d HH:mm:ss tt");
            mv3EventString.EndTime        = eventETime.ToString("yyyy/M/d HH:mm:ss tt");
            mv3EventString.speed          = mv3event.speed.ToString();
            mv3EventString.acc            = mv3event.acc.ToString();
            mv3EventString.course         = mv3event.course.ToString();
            mv3EventString.lat            = mv3event.lat.ToString();
            mv3EventString.lon            = mv3event.lon.ToString();
            mv3EventString.lat_sn         = mv3event.lat_sn.ToString();
            mv3EventString.lon_ew         = mv3event.lon_ew.ToString();
            mv3EventString.priority       = mv3event.priority.ToString();
            mv3EventString.a_index        = mv3event.a_index.ToString();
            mv3EventString.v_index        = mv3event.v_index.ToString();
            mv3EventString.ucPre          = mv3event.ucPre.ToString();
            mv3EventString.ucPost         = mv3event.ucPost.ToString();
            mv3EventString.Offset         = mv3event.offset.ToString();
            mv3EventString.DayLightSaving = mv3event.dst.ToString();
            mv3EventString.chmap          = mv3event.chnmap.ToString();
            mv3EventString.szEventMsg     = mv3event.szEventMsg.ToString();
            mv3EventString.eventName      = GetStringFromBytes(mv3event.eventName);
        }
예제 #2
0
        public void getSearchData()
        {
            //assign condition and get search data
            int      result = 0;
            IntPtr   iResultType;
            DateTime STime = new DateTime();

            switch (Search_type)
            {
            case EVENT_SEARCH:      //event search

                nConditions += (uint)SearchConditions.SEARCH_COND_EVENT;

                if (int_alarm != 0)    //alarm
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_ALARM;
                }

                if (int_vloss != 0)    //videoloss
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_VLOSS;
                }

                if (int_poweron != 0)    //power on
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_POWER_ON;
                }

                if (int_gs_impact != 0)    //G sensor impact
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_GS_IMPACT;
                }

                if (int_gs_accel != 0)    //G sensor accel
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_GS_ACCEL;
                }

                if (int_SystemFault != 0)
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_SYSTEM_FAULT;
                }

                if (int_J1939 != 0)
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_J1939_TYPE;
                }

                if (videomaskvalue == 0)    //videomaskvalue default 1
                {
                    videomaskvalue = 1;
                }
                //assign start time, end time, Condition, meta_search structure and alarmmask

                //Soya 20110727


                result = SdkShellSearchEventList(ptr, (uint)videomaskvalue, int_starttime, int_endtime, (uint)nConditions, meta_search);    //change by Edward
                if (result < 0)
                {
                    MessageBox.Show(Enum.Parse(typeof(ErrorMessage), result.ToString()).ToString());
                    setCloseForm();
                    return;
                }
                nConditions    = 0;
                videomaskvalue = 0;
                //alarmmaskvalue = 0;
                int_total = SdkShellGetSearchEventCount(ptr);

                //get total event
                if (int_total > 0)
                {
                    int iStartIndex       = 0;
                    int iEndIndex         = 0;
                    int iAmount_per_round = 100;
                    int itemCount         = 0;
                    int itemSize          = Marshal.SizeOf(typeof(EVENT_T_MV3));
                    int index             = 0;
                    while ((m_bStopflag == false) && (int_total > 0))
                    {
                        itemCount   = int_total > iAmount_per_round ? iAmount_per_round : int_total;
                        iResultType = IntPtr.Zero;
                        IntPtr iResult = Marshal.AllocHGlobal(itemSize * itemCount);
                        iEndIndex = iStartIndex + itemCount - 1;
                        int lReturnedAmount = 0;
                        result = SdkShellGetSearchEventItem(ptr, iStartIndex, iEndIndex, out lReturnedAmount, ref iResultType, iResult);


                        for (int i = 0; i < lReturnedAmount; i++)
                        {
                            EVENT_T_MV3 mv3Event = new EVENT_T_MV3();
                            IntPtr      ItemPtr  = new IntPtr(iResult.ToInt32() + itemSize * i);
                            mv3Event = (EVENT_T_MV3)Marshal.PtrToStructure(ItemPtr, typeof(EVENT_T_MV3));

                            //get data to list
                            EVENT_T_MV3toString(mv3Event);
                            ListViewItem lvItem;
                            lvItem = GetEnventSearchListViewItem((index + 1).ToString());

                            object[] inputarg = new object[2];
                            inputarg[0] = lvItem;
                            inputarg[1] = SearchlistView;

                            SearchlistView.BeginInvoke(new AsyncListViewCallBack(ListViewCallBack), inputarg);
                            discover_count++;
                            index++;
                        }

                        Marshal.FreeHGlobal(iResult);
                        int_total   -= lReturnedAmount;
                        iStartIndex += lReturnedAmount;
                    }
                    setStartbtnopen();
                    MessageBox.Show("search complete");
                }
                else
                {
                    setStartbtnopen();
                    MessageBox.Show("No data");
                }

                break;

            case GPS_SEARCH:      //GPS search

                if (videomaskvalue == 0)
                {
                    videomaskvalue = 1;
                }
                //if (MTModalType == ModalType.MV_HDD)
                //{
                //    meta_search.mode = 1;   //GPS Border Type 0:Circle 1:Rectangle
                //    meta_search.range = 2;  //Search Mode 0:Inside 1:Outside
                //    //meta_search.gps_inout = 3;
                //    //meta_search.gps_lat1_sn = 1;
                //    //meta_search.gps_lat2_sn = 1;
                //    //meta_search.gps_lon1_ew = 0;
                //    //meta_search.gps_lon2_ew = 0;
                //}
                //else if (MTModalType == ModalType.MV_DVR)
                //{
                //    meta_search.mode = 1;   //GPS Border Type 0:Circle 1:Rectangle
                //    meta_search.range = 2;  //Search Mode 0:Inside 1:Outside
                //}
                result = SdkShellSearchEventList(ptr, (uint)videomaskvalue, int_starttime, int_endtime, (uint)nConditions, meta_search);
                if (result < 0)
                {
                    MessageBox.Show(Enum.Parse(typeof(ErrorMessage), result.ToString()).ToString());
                    setCloseForm();
                    return;
                }
                int_total = SdkShellGetSearchEventCount(ptr);
                if (int_total > 0)
                {
                    int iStartIndex       = 0;
                    int iEndIndex         = 0;
                    int iAmount_per_round = 100;
                    int itemCount         = 0;
                    int itemSize          = Marshal.SizeOf(typeof(EVENT_T_MV3));
                    int index             = 0;
                    while ((m_bStopflag == false) && (int_total > 0))
                    {
                        itemCount   = int_total > iAmount_per_round ? iAmount_per_round : int_total;
                        iResultType = IntPtr.Zero;
                        IntPtr iResult = Marshal.AllocHGlobal(itemSize * itemCount);
                        iEndIndex = iStartIndex + itemCount - 1;
                        int lReturnedAmount = 0;
                        result = SdkShellGetSearchEventItem(ptr, iStartIndex, iEndIndex, out lReturnedAmount, ref iResultType, iResult);
                        for (int i = 0; i < lReturnedAmount; i++)
                        {
                            EVENT_T_MV3 mv3Event = new EVENT_T_MV3();
                            IntPtr      ItemPtr  = new IntPtr(iResult.ToInt32() + itemSize * i);
                            mv3Event = (EVENT_T_MV3)Marshal.PtrToStructure(ItemPtr, typeof(EVENT_T_MV3));

                            //get data to list
                            EVENT_T_MV3toString(mv3Event);
                            ListViewItem lvItem;
                            lvItem = GetGPSListViewItem((index + 1).ToString());

                            object[] inputarg = new object[2];
                            inputarg[0] = lvItem;
                            inputarg[1] = SearchlistView;

                            SearchlistView.BeginInvoke(new AsyncListViewCallBack(ListViewCallBack), inputarg);
                            discover_count++;
                            index++;
                        }
                        Marshal.FreeHGlobal(iResult);
                        int_total   -= lReturnedAmount;
                        iStartIndex += lReturnedAmount;
                    }
                    setStartbtnopen();
                    MessageBox.Show("search complete");
                }
                else
                {
                    setStartbtnopen();
                    MessageBox.Show("No data");
                }

                break;

            case G_SENSOR_SEARCH:       //G sensor search

                nConditions += (uint)SearchConditions.GSENSOR_MAP;
                if (videomaskvalue == 0)
                {
                    videomaskvalue = 1;
                }

                //HDD Gsensor mata data
                meta_search.g_x_val  = by_g_value1;
                meta_search.g_y_val  = by_g_value2;
                meta_search.g_z_val  = by_g_value3;
                meta_search.g_sensor = 7;    //search X, Y ,Z axis

                //DVR Gsensor mata data
                meta_search.g_value1 = by_g_value1;
                meta_search.g_value2 = by_g_value2;
                meta_search.range    = us_range;

                //assign start time, end time, Condition and meta_search structure
                result = SdkShellSearchEventList(ptr, (uint)videomaskvalue, int_starttime, int_endtime, (uint)nConditions, meta_search);
                if (result < 0)
                {
                    MessageBox.Show(Enum.Parse(typeof(ErrorMessage), result.ToString()).ToString());
                    setCloseForm();
                    return;
                }
                int_total = SdkShellGetSearchEventCount(ptr);
                //get total event
                if (int_total > 0)
                {
                    int iStartIndex       = 0;
                    int iEndIndex         = 0;
                    int iAmount_per_round = 100;
                    int itemCount         = 0;
                    int itemSize          = Marshal.SizeOf(typeof(EVENT_T_P2));
                    int index             = 0;
                    while ((m_bStopflag == false) && (int_total > 0))
                    {
                        itemCount   = int_total > iAmount_per_round ? iAmount_per_round : int_total;
                        iResultType = IntPtr.Zero;
                        IntPtr iResult = Marshal.AllocHGlobal(itemSize * itemCount);
                        iEndIndex = iStartIndex + itemCount - 1;
                        int lReturnedAmount = 0;
                        result = SdkShellGetSearchEventItem(ptr, iStartIndex, iEndIndex, out lReturnedAmount, ref iResultType, iResult);
                        for (int i = 0; i < lReturnedAmount; i++)
                        {
                            EVENT_T_P2 p2Event = new EVENT_T_P2();
                            IntPtr     ItemPtr = new IntPtr(iResult.ToInt32() + itemSize * i);
                            p2Event = (EVENT_T_P2)Marshal.PtrToStructure(ItemPtr, typeof(EVENT_T_P2));

                            STime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((int)p2Event.nStartTime);
                            ListViewItem lvItem;
                            lvItem = GetGSensorListViewItem((index + 1).ToString(), STime.ToString("yyyy/M/d HH:mm:ss tt"), "");

                            object[] inputarg = new object[2];
                            inputarg[0] = lvItem;
                            inputarg[1] = SearchlistView;

                            SearchlistView.BeginInvoke(new AsyncListViewCallBack(ListViewCallBack), inputarg);
                            discover_count++;
                            index++;
                        }
                        Marshal.FreeHGlobal(iResult);
                        int_total   -= lReturnedAmount;
                        iStartIndex += lReturnedAmount;
                    }
                    setStartbtnopen();
                    MessageBox.Show("search complete");
                }
                else
                {
                    setStartbtnopen();
                    MessageBox.Show("No data");
                }

                break;

            case SEGMENT_SEARCH:        //Segment search

                nConditions += (uint)SearchConditions.SEARCH_COND_EVENT;

                if (int_alarm != 0)    //alarm
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_ALARM;
                }
                if (int_vloss != 0)    //videoloss
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_VLOSS;
                }
                if (int_SystemFault != 0)
                {
                    nConditions += (uint)SearchConditions.SEARCH_COND_SYSTEM_FAULT;
                }
                //if (int_poweron != 0)//power on
                //{
                //nConditions += (uint)SearchConditions.POWER_ON;
                //}
                nConditions += (uint)SearchConditions.SEARCH_COND_SEGMENT;

                if (videomaskvalue == 0)    //videomaskvalue default 1
                {
                    videomaskvalue = 1;
                }

                setMV3metesearch();     //assign meta_search

                //assign start time, end time, Condition, meta_search structure and alarmmask

                result = SdkShellSearchEventList(ptr, (uint)videomaskvalue, int_starttime, int_endtime, (uint)nConditions, meta_search);
                if (result < 0)
                {
                    MessageBox.Show(Enum.Parse(typeof(ErrorMessage), result.ToString()).ToString());
                    setCloseForm();
                    return;
                }
                nConditions    = 0;
                videomaskvalue = 0;
                //alarmmaskvalue = 0;
                int_total = SdkShellGetSearchEventCount(ptr);

                //get total event
                if (int_total > 0)
                {
                    int iStartIndex       = 0;
                    int iEndIndex         = 0;
                    int iAmount_per_round = 100;
                    int itemCount         = 0;
                    int itemSize          = Marshal.SizeOf(typeof(EVENT_T_MV3));
                    int index             = 0;
                    while ((m_bStopflag == false) && (int_total > 0))
                    {
                        itemCount   = int_total > iAmount_per_round ? iAmount_per_round : int_total;
                        iResultType = IntPtr.Zero;
                        IntPtr iResult = Marshal.AllocHGlobal(itemSize * itemCount);
                        iEndIndex = iStartIndex + itemCount - 1;
                        int lReturnedAmount = 0;
                        result = SdkShellGetSearchEventItem(ptr, iStartIndex, iEndIndex, out lReturnedAmount, ref iResultType, iResult);


                        for (int i = 0; i < lReturnedAmount; i++)
                        {
                            EVENT_T_MV3 mv3Event = new EVENT_T_MV3();

                            IntPtr ItemPtr = new IntPtr(iResult.ToInt32() + itemSize * i);
                            mv3Event = (EVENT_T_MV3)Marshal.PtrToStructure(ItemPtr, typeof(EVENT_T_MV3));

                            //get data to list
                            EVENT_T_MV3toString(mv3Event);
                            ListViewItem lvItem;
                            //lvItem = GetSegmentListViewItem((index + 1).ToString());
                            lvItem = GetEnventSearchListViewItem((index + 1).ToString());

                            object[] inputarg = new object[2];
                            inputarg[0] = lvItem;
                            inputarg[1] = SearchlistView;

                            SearchlistView.BeginInvoke(new AsyncListViewCallBack(ListViewCallBack), inputarg);
                            discover_count++;
                            index++;
                        }

                        Marshal.FreeHGlobal(iResult);
                        int_total   -= lReturnedAmount;
                        iStartIndex += lReturnedAmount;
                    }
                    setStartbtnopen();
                    MessageBox.Show("search complete");
                }
                else
                {
                    setStartbtnopen();
                    MessageBox.Show("No data");
                }

                break;

            default:

                MessageBox.Show("search fail");
                break;
            }
        }