-
Notifications
You must be signed in to change notification settings - Fork 0
/
TimerSchedulingExampleIsHere.cs
99 lines (82 loc) · 2.25 KB
/
TimerSchedulingExampleIsHere.cs
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
using System;
using System.Collections.Generic;
using System.Text;
using CPE_Lib;
using System.Threading;
namespace DPE_Sto_Cfg_Loaders
{
public class CPE_Clasters_Module_Config
{
private double updaterate = 10000;
public double UpdateRate
{
get { return updaterate; }
set { updaterate = value; }
}
private bool calc_on_start = true;
public bool CalcOnStart
{
get { return calc_on_start; }
set { calc_on_start = value; }
}
}
public class CPE_Clasters_Module: SliceProcessing
{
public override void Config(CPE_Clasters_Module_Config cfg)
{
this.cfg = cfg;
}
private CPE_Clasters_Module_Config cfg;
double updaterate = 100000;
public override void Init()
{
this.th = new Thread(new ThreadStart(this.ClasterizationThread));
this.th.Start();
this.timer = new System.Timers.Timer(this.updaterate);
this.timer.Elapsed += new System.Timers.ElapsedEventHandler(timer_Elapsed);
this.timer.AutoReset = true;
}
public void Activate()
{
this.timer.Start();
if (this.cfg.CalcOnStart) this.sem.Release();
}
void timer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{
this.sem.Release();
}
Thread th;
Semaphore sem = new Semaphore(0, 10000);
System.Timers.Timer timer;
bool deinit = false;
void ClasterizationThread()
{
while (!this.deinit)
{
bool res = sem.WaitOne();
if (!this.deinit)
{
this.CalcClusters();
}
}
}
void CalcClusters()
{
}
public override void DeInit()
{
this.deinit = true;
}
public override bool Process(Slice input)
{
//this.class_rt.CalcRT(input);
//this.class_hist.StoreHistory(input);
}
}
//public class HistoryCollector
//{
// public virtual Process(Slice input)
// {
// }
//}
}