示例#1
0
文件: NewTest.cs 项目: Elpannol/IPR2
        /**
         * This function creates a measurement from a string.
         * AND it sends the measurment to the server.
         */
        public Measurement ParseMeasurement(string inputString)
        {
            // Some string parsing
            text        = inputString;
            inputString = inputString.Trim();
            var splitString      = inputString.Split();
            var simpleTimeString = splitString[6].Split(':');

            splitString[6] = "0";
            int[] list  = { 0, 0, 0, 0, 0, 0, 0, 0, 0 };
            var   index = 0;

            foreach (var s in splitString)
            {
                list[index] = int.Parse(s);
                index++;
            }

            // Create a measurement
            var tempTime = new SimpleTime(
                int.Parse(simpleTimeString[0]),
                int.Parse(simpleTimeString[1]));
            var tempMeasurement = new Measurement(list[7],
                                                  list[0],
                                                  list[1],
                                                  tempTime.Minutes,
                                                  tempTime.Seconds);

            // This is where data is sent to the server.
            if (tempMeasurement.Rondes > 0)
            {
                Login.Handler.AddMeasurement(tempMeasurement, _name);
                Login.Handler.ReadMessage();
                Login.Handler.AddLogEntry(tempMeasurement.ToString(), _name);
                Login.Handler.ReadMessage();
            }

            int minusTime = 0;

            switch (state)
            {
            case TrainingState.REALTEST:
                minusTime = 2;
                break;

            case TrainingState.COOLINGDOWN:
                minusTime = 6;
                break;
            }

            string time = $"{tempMeasurement.Time.Minutes - minusTime:00}:{tempMeasurement.Time.Seconds:00}";

            // Update simply changes the text fields.
            update(tempMeasurement.Weerstand.ToString(),
                   tempMeasurement.Hartslag.ToString(),
                   tempMeasurement.Rondes.ToString(),
                   time);

            return(tempMeasurement);
        }
示例#2
0
    public static void Main()
    {
        SimpleTime time = new SimpleTime(15, 30, 19);

        Console.WriteLine(time.BuildString());

        Console.ReadLine();
    } // end Main
示例#3
0
 public override bool TryStart()
 {
     if (this._workers.Count() == 0)
     {
         return(false);
     }
     this._startedAt = SimpleTime.Now;
     return(base.TryStart());
 }
示例#4
0
 internal PrizeManager(Rank <ArenaInfo> rank, List <ArenaPrizeConfig> prize_rules, SimpleTime prizetime, MailSystem mailsystem)
 {
     m_Rank             = rank;
     m_PrizeRules       = prize_rules;
     m_PrizePresentTime = prizetime;
     m_MailSystem       = mailsystem;
     m_NextPrizeDate    = ArenaSystem.GetNextExcuteDate(m_PrizePresentTime);
     if (m_MailSystem != null)
     {
         m_MailSystem.RegisterModuleMailHandler(ModuleMailTypeEnum.ArenaModule, this);
     }
 }
示例#5
0
        internal static DateTime GetNextExcuteDate(SimpleTime stime)
        {
            DateTime target_date = DateTime.Today;

            target_date = target_date.AddHours(stime.Hour);
            target_date = target_date.AddMinutes(stime.Minutes);
            if (target_date < DateTime.Now)
            {
                target_date = target_date.AddDays(1);
            }
            return(target_date);
        }
示例#6
0
        public Simulator(string name)
        {
            _name = name;
            _time = 0;
            SimpleTime temp = new SimpleTime(_time / 60, _time % 60);

            Measurement = new Measurement(0, 100, 0, temp.Minutes, temp.Seconds);
            InitializeComponent();
            FormClosing += Simulator_FormClosing;

            weerstand.Text = Measurement.Weerstand + "";
            hartslag.Text  = Measurement.Hartslag + "";
            rondes.Text    = Measurement.Rondes + "";
        }
 public bool CompareTo(RuleValue value1, RuleValue value2)
 {
     if (value1.IsTime && value2.IsTimeRange)
     {
         ITimeRange tr = value2.Value as ITimeRange;
         DateTime   dt = Convert.ToDateTime(value1.Value);
         SimpleTime st = SimpleTime.FromDateTime(dt);
         return(tr.ContainsTime(st));
     }
     else
     {
         throw new ArgumentException("CompareTo does not work with the value types provided.");
     }
 }
示例#8
0
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            if (targetType != typeof(string))
            {
                throw new InvalidOperationException("Target of conversion must be string");
            }
            SimpleTime time = value as SimpleTime;

            if (time == null)
            {
                throw new ArgumentException("Value has to be SimpleTime");
            }

            return(time.ToString());
        }
示例#9
0
        public SimpleTime toUTC(int year, int month, int day, int h, int m)
        {
            DateTime dt = new DateTime(year, month, day, h, m, 0, DateTimeKind.Utc);
            long     s  = toSecsSinceEpoch(year, month, day, h, m);
            TZType   t  = getTZ(s);

            dt = dt.AddSeconds(-t.offset);
            SimpleTime ret = new SimpleTime();

            ret.year   = dt.Year;
            ret.month  = dt.Month;
            ret.day    = dt.Day;
            ret.hour   = dt.Hour;
            ret.minute = dt.Minute;
            return(ret);
        }
        private void button10_Click(object sender, EventArgs e)
        {
            //MessageBox.Show((tmpList != null).ToString());
            //MessageBox.Show(tmpList.Count.ToString());
            if (comboBox3.SelectedIndex != -1 && comboBox4.SelectedIndex != -1)
            {
                try
                {
                    //MessageBox.Show(int.Parse((string)comboBox3.SelectedItem).ToString());

                    SimpleTime time = new SimpleTime(int.Parse((string)comboBox3.SelectedItem), int.Parse((string)comboBox4.SelectedItem));

                    foreach (SimpleTime s in tmpList)
                    {
                        if (s.hour == time.hour && s.minute == time.minute)
                        {
                            throw new Exception("Повторяется время!");
                        }
                    }

                    if (tmpTimetable.type == TableType.table)
                    {
                        tmpList.Add(time);
                    }
                    else if (tmpTimetable.type == TableType.periodic && time.minute > 0)
                    {
                        foreach (SimpleTime s in tmpList)
                        {
                            if (s.hour == time.hour)
                            {
                                throw new Exception("Повторяется время!");
                            }
                        }
                        tmpList.Add(time);
                    }

                    listBox7.DataSource = null;
                    listBox7.DataSource = tmpList;
                }
                catch (Exception ex) {
                    MessageBox.Show(ex.Message);
                }
            }
        }
示例#11
0
 public RestartTime(bool enabled, SimpleTime time)
 {
     Enabled = enabled;
     Time    = time;
 }
示例#12
0
 public StopTime(bool enabled, SimpleTime time)
 {
     Enabled = enabled;
     Time    = time;
 }
示例#13
0
 public TimePeriod(Int64 id, SimpleTime begin, SimpleTime end, DayKind dayKind)
 => (Id, Begin, End, DayKind) = (id, begin, end, dayKind);
示例#14
0
文件: ThisTest.cs 项目: Kazempour/src
 public static void Main( string[] args )
 {
     SimpleTime time = new SimpleTime( 15, 30, 19 );
       Console.WriteLine( time.BuildString() );
 }
示例#15
0
    static void Main()
    {
        var time = new SimpleTime(15, 30, 19);

        Console.WriteLine(time.BuildString());
    }
示例#16
0
        static void Main(string[] args)
        {
            SimpleTime what = new SimpleTime(23, 43, 45);

            Console.WriteLine(what.BuildString());
        }