Ejemplo n.º 1
0
 public SilenceTimeSection(SilenceTimeSection right)
 {
     sectionType = right.sectionType;
     beginHour   = right.beginHour;
     beginMinute = right.beginMinute;
     endHour     = right.endHour;
     endMinute   = right.endMinute;
     days        = right.days;
     isOn        = right.isOn;
     id          = right.id;
 }
Ejemplo n.º 2
0
        int Comparison(SilenceTimeSection a, SilenceTimeSection b)
        {
            DateTime beginTimeA = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, a.beginHour, a.beginMinute, 0);
            DateTime beginTimeB = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, b.endHour, b.endMinute, 0);

            if (beginTimeA > beginTimeB)
            {
                return(1);
            }
            else if (beginTimeA == beginTimeB)
            {
                return(0);
            }
            return(-1);
        }
Ejemplo n.º 3
0
        private void AddClockItem(SilenceTimeSection section, int dayIndex, bool bBegin)
        {
            ClocksItem newClocksItem = new ClocksItem
            {
                id             = section.id,
                clock_type     = section.GetSectionTypeKey() + (bBegin ? "_begin" : "_end"),
                clock_hour     = bBegin ? section.beginHour : section.endHour,
                clock_min      = bBegin ? section.beginMinute : section.endMinute,
                clock_enable   = section.isOn ? 1 : 0,
                clock_weekdays = (dayIndex).ToString(),
                x_child_sn     = mLocalChildInfoAgent.getChildSN()
            };

            listClocksItemSection.Add(newClocksItem);
        }
Ejemplo n.º 4
0
        void InitialSilenceTimeSection(List <SilenceTimeSection> listSilenceTimeSection)
        {
            Clear();
            foreach (var section in listSilenceTimeSection)
            {
                if (section.isOn)
                {
                    List <SilenceTimeSection>[] listlist = GetSilenceTimeSectionListList(section.sectionType);
                    for (int i = 0; i < 7; ++i)
                    {
                        if (section.IsDayActive(i))
                        {
                            DateTime beginTime = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, section.beginHour, section.beginMinute, 0);
                            DateTime endTime   = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, section.endHour, section.endMinute, 0);
                            if (endTime > beginTime)
                            {
                                section.crossDayType = SilenceTimeSection.CrossDayType.NoCross;
                                listlist[i].Add(section);
                            }
                            else if (endTime == beginTime)
                            {
                                continue;
                            }
                            else
                            {//cross day
                                SilenceTimeSection preDaySection = new SilenceTimeSection(section);
                                preDaySection.endHour      = 0;
                                preDaySection.endMinute    = 0;
                                preDaySection.crossDayType = SilenceTimeSection.CrossDayType.EndCross;
                                listlist[i].Add(preDaySection);

                                SilenceTimeSection nextDaySection = new SilenceTimeSection(section);
                                nextDaySection.beginHour    = 0;
                                nextDaySection.beginMinute  = 0;
                                nextDaySection.crossDayType = SilenceTimeSection.CrossDayType.BeginCross;
                                int nextDayIndex = i + 1;
                                if (nextDayIndex >= 7)
                                {
                                    nextDayIndex = 0;
                                }
                                listlist[nextDayIndex].Add(nextDaySection);
                            }
                        }
                    }
                }
            }
            SortAndMergeSection();
        }
Ejemplo n.º 5
0
        IEnumerator DelayForSilenceTime(int second, SilenceTimeSection timeSection)
        {
            GuLog.Debug("<><ProcessSilenceTime>: WaitForSeconds:" + second + "    type:" + timeSection.sectionType.ToString());

            yield return(new WaitForSeconds(second));

            DateTime time       = DateTime.Now;
            DateTime beginTime  = new DateTime(time.Year, time.Month, time.Day, timeSection.beginHour, timeSection.beginMinute, 0);
            DateTime endTime    = new DateTime(time.Year, time.Month, time.Day, timeSection.endHour, timeSection.endMinute, 0);
            double   escapeTime = (endTime - beginTime).TotalSeconds;

            PushNewState(timeSection, escapeTime, true);
            DateTime oneSecondAfterEndTime = new DateTime(time.Year, time.Month, time.Day, timeSection.endHour, timeSection.endMinute, 0);

            ProcessSilenceTime(timeSection.sectionType, oneSecondAfterEndTime);
        }
Ejemplo n.º 6
0
        public bool InSchoolMode(DateTime dateTime)
        {
            int seconds = 0;
            SilenceTimeSection section = this.GetSilenceTimeFromTime(SilenceTimeSection.SectionType.Study, DateTime.Now, out seconds);

            if (section != null && seconds == 0)
            {
                Debug.LogFormat("----PowerKeyLongPress->InSchoolMode: {0}, {1}, {2}, {3}, {4}, {5}, {6}, {7}----",
                                section.sectionType, section.beginHour, section.beginMinute,
                                section.endHour, section.endMinute, section.days, section.isOn, seconds);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 7
0
 void FillClocksItemList(List <SilenceTimeSection> listTimeSection, int dayIndex)
 {
     for (int i = 0; i < listTimeSection.Count; ++i)
     {
         SilenceTimeSection section = listTimeSection[i];
         if (section != null)
         {
             if (section.crossDayType != SilenceTimeSection.CrossDayType.BeginCross)
             {
                 AddClockItem(section, dayIndex, true);
             }
             if (section.crossDayType != SilenceTimeSection.CrossDayType.EndCross)
             {
                 AddClockItem(section, dayIndex, false);
             }
         }
     }
 }
Ejemplo n.º 8
0
        private void PushNewState(SilenceTimeSection timeSection, double escapeTime, bool bForceStartAni)
        {
            //if (timeSection.endHour == 23 && timeSection.endMinute == 59)
            //{
            //    escapeTime += 60;
            //}

            if (timeSection.sectionType == SilenceTimeSection.SectionType.Study)
            {
                uiState.PushNewState(UIStateEnum.eSchoolMode, (float)escapeTime, bForceStartAni);
            }
            else if (timeSection.sectionType == SilenceTimeSection.SectionType.Sleep)
            {
                uiState.PushNewState(UIStateEnum.eSleepMode, (float)escapeTime, bForceStartAni);
            }
            uiState.PushNewState(UIStateEnum.eRefreshMainByData);
            uiState.PushNewState(UIStateEnum.eStartDailyProcessBar);
        }
Ejemplo n.º 9
0
        void ProcessSilenceTime(SilenceTimeSection.SectionType type, DateTime time)
        {
            int second = 0;
            SilenceTimeSection timeSection = silenceTimeDataManager.GetSilenceTimeFromTime(type, time, out second);

            if (timeSection != null)
            {
                if (second == 0)
                {
                    DateTime endTime = new DateTime(time.Year, time.Month, time.Day, timeSection.endHour, timeSection.endMinute, 0);

                    double escapeTime = (endTime - time).TotalSeconds;
                    PushNewState(timeSection, escapeTime, false);
                }
                //else
                //{
                //    StartCoroutine(DelayForSilenceTime(second, timeSection));
                //}
            }
        }
Ejemplo n.º 10
0
        List <SilenceTimeSection> SortAndMergeSection(List <SilenceTimeSection> list)
        {
            if (list.Count < 2)
            {
                return(list);
            }
            list.Sort(Comparison);
            List <SilenceTimeSection> retList = new List <SilenceTimeSection>();

            for (int i = 0; i < list.Count; ++i)
            {
                int      mergeCount = 0;
                DateTime endTime    = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, list[i].endHour, list[i].endMinute, 0);
                for (int next = i + 1; next < list.Count; ++next)
                {
                    DateTime beginTimeNext = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, list[next].beginHour, list[next].beginMinute, 0);
                    if (beginTimeNext < endTime)
                    {
                        DateTime endTimeNext = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, list[next].endHour, list[next].endMinute, 0);
                        if (endTimeNext > endTime)
                        {
                            endTime = endTimeNext;
                        }
                        ++mergeCount;
                    }
                }
                if (mergeCount > 0)
                {
                    SilenceTimeSection newSection = new SilenceTimeSection(list[i]);
                    newSection.endHour   = endTime.Hour;
                    newSection.endMinute = endTime.Minute;
                    retList.Add(newSection);
                    i += mergeCount;
                }
                else
                {
                    retList.Add(list[i]);
                }
            }
            return(retList);
        }