@@ -64,7 +64,7 @@ impl Default for State {
64
64
}
65
65
}
66
66
67
- #[ derive( Debug , Clone , Serialize , Deserialize ) ]
67
+ #[ derive( Debug , Clone , Serialize , Deserialize , PartialEq ) ]
68
68
enum Phase {
69
69
Idle , // Doing nothing
70
70
Pass , // Passing a job from input to output
@@ -174,7 +174,11 @@ impl ExclusiveGateway {
174
174
175
175
impl AsModel for ExclusiveGateway {
176
176
fn status ( & self ) -> String {
177
- String :: from ( "Active" )
177
+ match self . state . phase {
178
+ Phase :: Idle => String :: from ( "Idle" ) ,
179
+ Phase :: Pass => format ! [ "Passing {}" , self . state. jobs[ 0 ] . content] ,
180
+ Phase :: Respond => String :: from ( "Fetching records" ) ,
181
+ }
178
182
}
179
183
180
184
fn events_ext (
@@ -196,8 +200,10 @@ impl AsModel for ExclusiveGateway {
196
200
&& self . store_records
197
201
{
198
202
self . store_job ( incoming_message, services) ?;
199
- } else {
203
+ } else if self . ports_in . records == incoming_message . port_name {
200
204
self . records_request ( ) ?;
205
+ } else {
206
+ return Err ( SimulationError :: InvalidModelState ) ;
201
207
}
202
208
Ok ( Vec :: new ( ) )
203
209
}
@@ -206,12 +212,12 @@ impl AsModel for ExclusiveGateway {
206
212
& mut self ,
207
213
_services : & mut Services ,
208
214
) -> Result < Vec < ModelMessage > , SimulationError > {
209
- if let Phase :: Pass = self . state . phase {
215
+ if Phase :: Pass = = self . state . phase {
210
216
self . send_jobs ( )
211
- } else if let Phase :: Respond = self . state . phase {
217
+ } else if Phase :: Respond = = self . state . phase {
212
218
self . send_records ( )
213
219
} else {
214
- Ok ( Vec :: new ( ) )
220
+ Err ( SimulationError :: InvalidModelState )
215
221
}
216
222
}
217
223
0 commit comments