summaryrefslogtreecommitdiff
path: root/Data/Horloge.cs
blob: c4e6beae611cf50a1b71fca4a469d788eadd2fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IvyBus;

namespace Data
{
    public class Horloge
    {
        private IvyBus.IvyControl TheIvyBus;
        private int hour, minute, second;

        public Horloge(IvyBus.IvyControl TheIvyBus)
        {
            this.TheIvyBus = TheIvyBus;
            hour = 0;
            minute = 0;
            second = 0;
            TheIvyBus.ivy.BindMsg(@"^ClockEvent Time=([0-9]+):([0-9]+):([0-9]+) Rate=.* Bs=.*",
                UpdateClock, null);
        }

        public int getHour()
        {
            return this.hour;
        }

        public int getMinute()
        {
            return this.minute;
        }

        public int getSecond()
        {
            return this.second;
        }
        private void UpdateClock(object sender, IvyMessageEventArgs e)
        {
            int new_hour = Int32.Parse(e[0]);
            int new_minute = Int32.Parse(e[1]);
            int new_second = Int32.Parse(e[2]);
            
            hour = new_hour;
            minute = new_minute;
            second = new_second;
        }
    }
}