Skip to content

Commit 9da1687

Browse files
Initial version uploaded
1 parent 0049f6f commit 9da1687

13 files changed

+1653
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
java.exe ^
2+
-Djava.util.logging.config.file=logging.properties ^
3+
-Dfile.encoding=UTF-8 ^
4+
-p ".\bin;..\SysMLinJava\bin" ^
5+
-XX:+ShowCodeDetailsInExceptionMessages ^
6+
-m TrafficSignalControlSystem/trafficcontrolsystem.TrafficControlSystemTest
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
############################################################
2+
# Default Logging Configuration File
3+
#
4+
# You can use a different file by specifying a filename
5+
# with the java.util.logging.config.file system property.
6+
# For example, java -Djava.util.logging.config.file=myfile
7+
############################################################
8+
9+
############################################################
10+
# Global properties
11+
############################################################
12+
13+
# "handlers" specifies a comma-separated list of log Handler
14+
# classes. These handlers will be installed during VM startup.
15+
# Note that these classes must be on the system classpath.
16+
# By default we only configure a ConsoleHandler, which will only
17+
# show messages at the INFO and above levels.
18+
#handlers= java.util.logging.ConsoleHandler
19+
20+
# To also add the FileHandler, use the following line instead.
21+
handlers= java.util.logging.FileHandler, java.util.logging.ConsoleHandler
22+
23+
# Default global logging level.
24+
# This specifies which kinds of events are logged across
25+
# all loggers. For any given facility this global level
26+
# can be overridden by a facility-specific level
27+
# Note that the ConsoleHandler also has a separate level
28+
# setting to limit messages printed to the console.
29+
.level= INFO
30+
31+
############################################################
32+
# Handler specific properties.
33+
# Describes specific configuration info for Handlers.
34+
############################################################
35+
36+
# default file output is in %temp% directory.
37+
java.util.logging.FileHandler.pattern = %t/TaskMaster%u.log
38+
java.util.logging.FileHandler.limit = 50000
39+
java.util.logging.FileHandler.count = 10
40+
# Default number of locks FileHandler can obtain synchronously.
41+
# This specifies maximum number of attempts to obtain lock file by FileHandler
42+
# implemented by incrementing the unique field %u as per FileHandler API documentation.
43+
java.util.logging.FileHandler.maxLocks = 100
44+
java.util.logging.FileHandler.formatter = java.util.logging.SimplerFormatter
45+
46+
# Limit the messages that are printed on the console to INFO and above.
47+
java.util.logging.ConsoleHandler.level = INFO
48+
java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
49+
50+
# Example to customize the SimpleFormatter output format
51+
# to print one-line log message like this:
52+
# <level>: <log message> [<date/time>]
53+
#
54+
java.util.logging.SimpleFormatter.format=%4$s %1$tb %1$td, %1$tY %1$tl:%1$tM:%1$tS %1$Tp %2$s: %5$s%n
55+
56+
############################################################
57+
# Facility-specific properties.
58+
# Provides extra control for each logger.
59+
############################################################
60+
61+
# For example, set the com.xyz.foo logger to only log SEVERE
62+
# messages:
63+
# com.xyz.foo.level = SEVERE
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Module {@code TrafficSignalControlSystem} is a SysMLinJava executable model
3+
* of a small traffic control system that provides a priority response to the
4+
* presence of emergency vehicles. A minimal block diagram of the domain is as
5+
* follows:<br>
6+
* <img src="TrafficSignalControlSystemModel.png" alt="PNG file not available"
7+
* height="400"><br>
8+
* The modeled system consists of four intersection signal systems operating in
9+
* synchrony with the overall traffic control system. The system operates in
10+
* either normal operations mode or emergency mode. The system states consist of
11+
* sub-state machines, one for each intersection, operating in parallel and
12+
* controlled by the compound state. Interfaces between the overall control
13+
* system and the individual intersection signal systems is via simple event
14+
* passing between state machines.
15+
* <p>
16+
* Note that all of the packages in this module are fully exported and opened.
17+
* This "openness" is consistent with this module being a SysMLinJava model, not
18+
* just a software module, whereby all the code is what constitutes the model.
19+
* Exposing all of the model enables its virtually unlimited applications.
20+
*
21+
* @author ModelerOne
22+
*
23+
*/
24+
module TrafficSignalControlSystem
25+
{
26+
exports trafficcontrolsystem;
27+
28+
opens trafficcontrolsystem;
29+
30+
requires transitive sysMLinJava;
31+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
package trafficcontrolsystem;
2+
3+
import java.util.Optional;
4+
import sysmlinjava.events.SysMLChangeEvent;
5+
import sysmlinjava.valuetypes.DirectionDegrees;
6+
7+
/**
8+
* Event for the direction of approach of an emergency vehicle when present
9+
*
10+
* @author ModelerOne
11+
*
12+
*/
13+
public class EmergencyVehicleChangeEvent extends SysMLChangeEvent
14+
{
15+
/**
16+
* Optional direction of approach (cardinal direction) of the emergency vehicle,
17+
* when it is present
18+
*/
19+
public Optional<DirectionDegrees> approachDirection;
20+
21+
/**
22+
* Constructor
23+
*
24+
* @param approachDirection Optional direction of approach (cardinal direction)
25+
* of the emergency vehicle when it is present
26+
*/
27+
public EmergencyVehicleChangeEvent(Optional<DirectionDegrees> approachDirection)
28+
{
29+
super("EmergencyVehicle");
30+
this.approachDirection = approachDirection;
31+
}
32+
33+
@Override
34+
protected void createChangeExpression()
35+
{
36+
changeExpression = "approachDirection";
37+
}
38+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
package trafficcontrolsystem;
2+
3+
import sysmlinjava.annotations.Operation;
4+
import sysmlinjava.annotations.Value;
5+
import sysmlinjava.annotations.statemachines.StateMachine;
6+
import sysmlinjava.blocks.SysMLBlock;
7+
import sysmlinjava.valuetypes.BBoolean;
8+
import sysmlinjava.valuetypes.DirectionDegrees;
9+
import sysmlinjava.valuetypes.DurationSeconds;
10+
11+
/**
12+
* SysMLinJava executable model of an individual intersection's traffic signal
13+
* system that controls signal phases for four approaches to the intersection.
14+
* The signal phases correspond to the system states. The modeled system
15+
* consists of values for the signal colors for each of the four approaches for
16+
* each of the signal phases/states, and a state machine that determines the
17+
* timing of and transitioning between each of the phases/states. The
18+
* intersection signal system operates as a sub-state machine to two of the
19+
* states of the {@code TrafficControlSystem}, i.e. one sub-state machine for
20+
* normal operations and another sub-state machine for emergency operations.
21+
* Normal operations provide each approach with a standard red-green-yellow-red
22+
* cycle, while emergency operations find the intersection providing green to
23+
* the approaching emergency vehicle and red to all other approaches.
24+
* <p>
25+
* The {@code IntersectionSignalSystem} model demonstrates how SysMLinJava can
26+
* be used to model systems that operate in accordance with more complex state
27+
* machines, i.e. state machines with pseudo-states for transition "choices" and
28+
* "junctions" and state machines that operate within states as sub-state
29+
* machines.
30+
*
31+
* @author ModelerOne
32+
*
33+
* @see trafficcontrolsystem.TrafficControlSystem
34+
* @see trafficcontrolsystem.IntersectionSignalSystemNormalStateMachine
35+
* @see trafficcontrolsystem.IntersectionSignalSystemEmergencyStateMachine
36+
*/
37+
public class IntersectionSignalSystem extends SysMLBlock
38+
{
39+
/**
40+
* Value for signal state (red, green, yellow) of the east-bound approach
41+
*/
42+
@Value
43+
public SignalStatesEnum eastBound;
44+
/**
45+
* Value for signal state (red, green, yellow) of the west-bound approach
46+
*/
47+
@Value
48+
public SignalStatesEnum westBound;
49+
/**
50+
* Value for signal state (red, green, yellow) of the north-bound approach
51+
*/
52+
@Value
53+
public SignalStatesEnum northBound;
54+
/**
55+
* Value for signal state (red, green, yellow) of the south-bound approach
56+
*/
57+
@Value
58+
public SignalStatesEnum southBound;
59+
60+
/**
61+
* Value for the duration of the signal phase east/west red, north-south green
62+
*/
63+
@Value
64+
public DurationSeconds EWRedNSGrnDuration;
65+
/**
66+
* Value for the duration of the signal phase east/west yellow or north/south
67+
* yellow
68+
*/
69+
@Value
70+
public DurationSeconds YellowDuration;
71+
/**
72+
* Value for the duration of the signal phase east/west green, north-south red
73+
*/
74+
@Value
75+
public DurationSeconds EWGrnNSRedDuration;
76+
77+
/**
78+
* Value that indicates the presence of an emergency vehicle on an approach
79+
*/
80+
@Value
81+
public BBoolean emergencyVehiclePresent;
82+
/**
83+
* Value for the approach direction of the emergency vehicle, if present
84+
*/
85+
@Value
86+
public DirectionDegrees emergencyVehicleDirection;
87+
88+
/**
89+
* State machine for the signal system during normal operations
90+
*/
91+
@StateMachine
92+
public IntersectionSignalSystemNormalStateMachine stateMachineNormalOps;
93+
/**
94+
* State machine for the signal system during emergency operations
95+
*/
96+
@StateMachine
97+
public IntersectionSignalSystemEmergencyStateMachine stateMachineEmergencyOps;
98+
99+
/**
100+
* Constructor
101+
*
102+
* @param contextBlock block in whose context the system resides
103+
* @param name unique name
104+
* @param id unique ID
105+
*/
106+
public IntersectionSignalSystem(SysMLBlock contextBlock, String name, Long id)
107+
{
108+
super(contextBlock, name, id);
109+
}
110+
111+
/**
112+
* Sets the east-west signals to green, north-south to red
113+
*/
114+
@Operation
115+
public void setEWGrnNSRed()
116+
{
117+
eastBound.setValue(SignalStatesEnum.Green);
118+
westBound.setValue(SignalStatesEnum.Green);
119+
northBound.setValue(SignalStatesEnum.Red);
120+
southBound.setValue(SignalStatesEnum.Red);
121+
}
122+
123+
/**
124+
* Sets the east-west signals to yellow, north-south to red
125+
*/
126+
@Operation
127+
public void setEWYelNSRed()
128+
{
129+
eastBound.setValue(SignalStatesEnum.Yellow);
130+
westBound.setValue(SignalStatesEnum.Yellow);
131+
northBound.setValue(SignalStatesEnum.Red);
132+
southBound.setValue(SignalStatesEnum.Red);
133+
}
134+
135+
/**
136+
* Sets the east signal yellow, west signal to green, north-south to red
137+
*/
138+
@Operation
139+
public void setEYelWGrnNSRed()
140+
{
141+
eastBound.setValue(SignalStatesEnum.Yellow);
142+
westBound.setValue(SignalStatesEnum.Green);
143+
northBound.setValue(SignalStatesEnum.Red);
144+
southBound.setValue(SignalStatesEnum.Red);
145+
}
146+
147+
/**
148+
* Sets the east signal to green, west signal to yellow, north-south to red
149+
*/
150+
@Operation
151+
public void setEGrnWYelNSRed()
152+
{
153+
eastBound.setValue(SignalStatesEnum.Green);
154+
westBound.setValue(SignalStatesEnum.Yellow);
155+
northBound.setValue(SignalStatesEnum.Red);
156+
southBound.setValue(SignalStatesEnum.Red);
157+
}
158+
159+
/**
160+
* Sets the east-west signals to red, north-south to green
161+
*/
162+
@Operation
163+
public void setEWRedNSGreen()
164+
{
165+
eastBound.setValue(SignalStatesEnum.Red);
166+
westBound.setValue(SignalStatesEnum.Red);
167+
northBound.setValue(SignalStatesEnum.Green);
168+
southBound.setValue(SignalStatesEnum.Green);
169+
}
170+
171+
/**
172+
* Sets the east-west signals to red, north-south to yellow
173+
*/
174+
@Operation
175+
public void setEWRedNSYel()
176+
{
177+
eastBound.setValue(SignalStatesEnum.Red);
178+
westBound.setValue(SignalStatesEnum.Red);
179+
northBound.setValue(SignalStatesEnum.Yellow);
180+
southBound.setValue(SignalStatesEnum.Yellow);
181+
}
182+
183+
/**
184+
* Sets the east signal to green, west signal to red, north-south to red
185+
*/
186+
@Operation
187+
public void setEGrnWRedNSRed()
188+
{
189+
eastBound.setValue(SignalStatesEnum.Green);
190+
westBound.setValue(SignalStatesEnum.Red);
191+
northBound.setValue(SignalStatesEnum.Red);
192+
southBound.setValue(SignalStatesEnum.Red);
193+
}
194+
195+
/**
196+
* Sets the east signal to red, west signals to green, north-south to red
197+
*/
198+
@Operation
199+
public void setERedWGrnNSRed()
200+
{
201+
eastBound.setValue(SignalStatesEnum.Red);
202+
westBound.setValue(SignalStatesEnum.Green);
203+
northBound.setValue(SignalStatesEnum.Red);
204+
southBound.setValue(SignalStatesEnum.Red);
205+
}
206+
207+
@Override
208+
protected void createValues()
209+
{
210+
super.createValues();
211+
eastBound = new SignalStatesEnum(SignalStatesEnum.Green);
212+
westBound = new SignalStatesEnum(SignalStatesEnum.Green);
213+
northBound = new SignalStatesEnum(SignalStatesEnum.Red);
214+
southBound = new SignalStatesEnum(SignalStatesEnum.Red);
215+
EWGrnNSRedDuration = new DurationSeconds(20);
216+
EWRedNSGrnDuration = new DurationSeconds(10);
217+
YellowDuration = new DurationSeconds(5);
218+
emergencyVehiclePresent = new BBoolean(false);
219+
emergencyVehicleDirection = new DirectionDegrees(DirectionDegrees.east);
220+
}
221+
}

0 commit comments

Comments
 (0)