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