1 package org.opentrafficsim.road.gtu.lane.perception.mental.sdm;
2
3 import org.djunits.value.vdouble.scalar.Duration;
4 import org.djunits.value.vdouble.scalar.Frequency;
5
6
7
8
9
10
11
12
13
14
15
16
17 public enum DefaultDistraction
18 {
19
20 TALKING_CELL_PHONE("1", "Talking on cell phone", freq(100, 0.329), 0.329, dur(92.65), dur(176.29)),
21
22
23 ANSWERING_CELL_PHONE("2", "Answering cell phone", freq(15, 0.157), 0.157, dur(7.86), dur(4.24)),
24
25
26 DIALING_CELL_PHONE("3", "Dialing cell phone", freq(122, 0.357), 0.357, dur(12.85), dur(13.41)),
27
28
29 DRINKING("4", "Drinking", freq(1028, 0.729), 0.729, dur(5.23), dur(7.4)),
30
31
32 MANIPULATING_AUDIO_CONTROLS("5", "Manipulating audio controls", freq(1539, 0.943), 0.943, dur(5.46), dur(8.63)),
33
34
35 SMOKING("6", "Smoking", freq(45, 0.071), 0.071, dur(245.81), dur(162.95)),
36
37
38 READING_WRITING("7", "Reading or writing", freq(303, 0.643), 0.643, dur(18.43), dur(29.7)),
39
40
41 GROOMING("8", "Grooming", freq(229, 0.571), 0.571, dur(11.82), dur(29.77)),
42
43
44 BABY_DISTRACTING("9", "Baby distracting", freq(114, 0.086), 0.086, dur(23.49), dur(28.39)),
45
46
47 CHILD_DISTRACTING("10", "Child distracting", freq(81, 0.143), 0.143, dur(25.76), dur(124.72)),
48
49
50 ADULT_DISTRACTING("11", "Adult distracting", freq(48, 0.257), 0.257, dur(46.32), dur(108.49)),
51
52
53 CONVERSING("12", "Conversing", freq(1558, 0.8), 0.8, dur(74.04), dur(234.5)),
54
55
56 REACHING("13", "Reaching", freq(2246, 1.0), 1.0, dur(7.58), dur(36.7)),
57
58
59 MANIPULATING_VEHICLE_CONTROLS("14", "Manipulating vehicle controls", freq(2095, 1.0), 1.0, dur(4.82), dur(11.53)),
60
61
62 INTERNAL_DISTRACTION("15", "Internal distraction", freq(481, 0.814), 0.814, dur(21.55), dur(46.38)),
63
64
65 EXTERNAL_DISTRACTION("16", "External distraction", freq(659, 0.9), 0.9, dur(26.55), dur(58.78)),
66
67
68 PREPARING_EAT_DRINK("17", "Preparing to eat / drink", freq(1503, 0.614), 0.614, dur(15.4), dur(34.7));
69
70
71 private static final double BASELINE_DURATION_SECONDS = 207.14 * 3600.0;
72
73
74 private final String id;
75
76
77 private final String description;
78
79
80 private final Frequency frequency;
81
82
83 private final double exposure;
84
85
86 private final Duration averageDuration;
87
88
89 private final Duration stdDuration;
90
91
92
93
94
95
96
97
98
99
100 DefaultDistraction(final String id, final String description, final Frequency frequency, final double exposure,
101 final Duration averageDuration, final Duration stdDuration)
102 {
103 this.id = id;
104 this.description = description;
105 this.frequency = frequency;
106 this.exposure = exposure;
107 this.averageDuration = averageDuration;
108 this.stdDuration = stdDuration;
109 }
110
111
112
113
114
115
116
117 private static Frequency freq(final int occurrences, final double exposure)
118 {
119 return Frequency.instantiateSI(occurrences / (BASELINE_DURATION_SECONDS * exposure));
120 }
121
122
123
124
125
126
127 private static Duration dur(final double duration)
128 {
129 return Duration.instantiateSI(duration);
130 }
131
132
133
134
135
136 public String getId()
137 {
138 return this.id;
139 }
140
141
142
143
144
145 public String getDescription()
146 {
147 return this.description;
148 }
149
150
151
152
153
154 public Frequency getFrequency()
155 {
156 return this.frequency;
157 }
158
159
160
161
162
163 public double getExposure()
164 {
165 return this.exposure;
166 }
167
168
169
170
171
172 public Duration getAverageDuration()
173 {
174 return this.averageDuration;
175 }
176
177
178
179
180
181 public Duration getStdDuration()
182 {
183 return this.stdDuration;
184 }
185
186
187
188
189
190
191 public static DefaultDistraction getFromId(final String id)
192 {
193 return values()[Integer.parseInt(id) - 1];
194 }
195
196 }