Ejemplo n.º 1
0
        public void GetInformation(dls2_set_t DaylightSavingInformation)
        {
            SMonth.Text  = DaylightSavingInformation.start_mon.ToString();
            SWeek.Text   = DaylightSavingInformation.start_week.ToString();
            SDay.Text    = DaylightSavingInformation.start_weekday.ToString();
            SHour.Text   = DaylightSavingInformation.start_hour.ToString();
            SMinute.Text = DaylightSavingInformation.start_min.ToString();

            EMonth.Text  = DaylightSavingInformation.end_mon.ToString();
            EWeek.Text   = DaylightSavingInformation.end_week.ToString();
            EDay.Text    = DaylightSavingInformation.end_weekday.ToString();
            EHour.Text   = DaylightSavingInformation.end_hour.ToString();
            EMinute.Text = DaylightSavingInformation.end_min.ToString();
        }
Ejemplo n.º 2
0
        /**
         *********************************************************************
         * @fn<Start_alarm_vehicleID_Click>
         * @brief<This part will be used to get vehicle ID and alarm table.>
         *
         * @param[in]
         *    none
         * @param[out]
         *    none
         * @retval
         *    none
         * @return <void>
         *********************************************************************
         */
        private void Start_alarm_vehicleID_Click(object sender, EventArgs e)
        {
            table_listView.Items.Clear();
            int      result = 0;
            DateTime STime  = new DateTime();
            DateTime ETime  = new DateTime();

            IntPtr iResult         = IntPtr.Zero;
            int    lReturnedAmount = 0;

            if (sel_type.SelectedIndex == (int)MV3_TABLE_INFO.MV3_ALARM_TABLE_INFO) //alarm table
            {
                int itemSize = Marshal.SizeOf(typeof(_extra_header_t));
                iResult = Marshal.AllocHGlobal(itemSize * 16);

                result = SdkShellGetTableInfo(ptr, sel_type.SelectedIndex, out lReturnedAmount, iResult);

                for (int i = 0; i < lReturnedAmount; i++)
                {
                    _extra_header_t alarmtable = new _extra_header_t();
                    //MessageBox.Show( Marshal.SizeOf(alarmtable).ToString());
                    IntPtr ItemPtr = new IntPtr(iResult.ToInt32() + itemSize * i);
                    alarmtable = (_extra_header_t)Marshal.PtrToStructure(ItemPtr, typeof(_extra_header_t));

                    bool bEmptyString = false;
                    if (Array.IndexOf(alarmtable.event_name, '\0') == 0)//added by Edward to skip unused vid items
                    {
                        bEmptyString = true;
                    }
                    if (!bEmptyString)
                    {
                        ListViewItem lvItem;
                        lvItem = GetTableListViewItem((i + 1).ToString(), new string(alarmtable.event_name), "", "");

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

                        table_listView.BeginInvoke(new AsyncListViewCallBack(ListViewCallBack), inputarg);
                    }
                }
                Marshal.FreeHGlobal(iResult);
            }
            else if (sel_type.SelectedIndex == (int)MV3_TABLE_INFO.MV3_VEHICLE_TABLE_INFO)  //vehicle table
            {
                int itemSize = Marshal.SizeOf(typeof(_vid_table_t));
                iResult = Marshal.AllocHGlobal(itemSize * 1024);

                result = SdkShellGetTableInfo(ptr, sel_type.SelectedIndex, out lReturnedAmount, iResult);

                for (int i = 0; i < lReturnedAmount; i++)
                {
                    _vid_table_t vidtable = new _vid_table_t();
                    //MessageBox.Show(Marshal.SizeOf(vidtable).ToString());
                    IntPtr ItemPtr = new IntPtr(iResult.ToInt32() + itemSize * i);
                    vidtable = (_vid_table_t)Marshal.PtrToStructure(ItemPtr, typeof(_vid_table_t));

                    bool bEmtpyStructure = false;//added by Edward to skip unused vid items
                    if ((vidtable.start == 0) && (vidtable.end == 0) && (Array.IndexOf(vidtable.name, '\0') == 0) && (vidtable.index == 0))
                    {
                        bEmtpyStructure = true;
                    }
                    if (!bEmtpyStructure)
                    {
                        STime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((int)vidtable.start);
                        ETime = new DateTime(1970, 1, 1, 0, 0, 0, 0).AddSeconds((int)vidtable.end);
                        ListViewItem lvItem;
                        lvItem = GetTableListViewItem(vidtable.index.ToString(), new string(vidtable.name), STime.ToString("yyyy/M/d HH:mm:ss tt"), ETime.ToString("yyyy/M/d HH:mm:ss tt"));

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

                        table_listView.BeginInvoke(new AsyncListViewCallBack(ListViewCallBack), inputarg);
                    }
                }
                Marshal.FreeHGlobal(iResult);
            }

            else if (sel_type.SelectedIndex == (int)MV3_TABLE_INFO.MV3_DayLightSaving_TABLE_INFO)
            {
                int itemSize = Marshal.SizeOf(typeof(dls2_set_t));
                iResult = Marshal.AllocHGlobal(itemSize);

                result = SdkShellGetTableInfo(ptr, sel_type.SelectedIndex, out lReturnedAmount, iResult);

                if (lReturnedAmount == 1)
                {
                    dls2_set_t DayLightSavingTable = new dls2_set_t();
                    DayLightSavingTable = (dls2_set_t)Marshal.PtrToStructure(iResult, typeof(dls2_set_t));
                    DayLightSavingForm.Show();
                    DayLightSavingForm.GetInformation(DayLightSavingTable);
                    Marshal.FreeHGlobal(iResult);
                }
                else
                {
                    Debug.WriteLine("The returnd value of SdkShellGetTableInfo is not 1 in DayLightSaving table");
                }
            }
        }