-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSysMLBlock.java
More file actions
1065 lines (1019 loc) · 40.7 KB
/
Copy pathSysMLBlock.java
File metadata and controls
1065 lines (1019 loc) · 40.7 KB
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
* Copyright 2021 SysMLinJava.com.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package sysmlinjava.blocks;
import java.util.Optional;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import sysmlinjava.annotations.statemachines.StateMachine;
import sysmlinjava.common.SysMLClass;
import sysmlinjava.events.SysMLEvent;
import sysmlinjava.statemachine.SysMLStateMachine;
/**
* SysMLinJava's represention of the SysML block
* <h2>The block in SysMLinJava</h2>{@code SysMLBlock} is an abstract class that
* provides a base class for for all SysML block representations. Extensions of
* the {@code SysMLBlock} class declare fields and methods that represent SysML
* block properties and operations such as values, flows, references, parts,
* ports, constraints, and constraint blocks as well as operations and
* receptions. They also declare fields that represent connectors of the block's
* parts and ports.
* <h3>Optional behavioral state machine</h3> The {@code SysMLBlock} also
* contains an optional state machine. This state machine is the SysMLinJava
* representation of the state machine/chart/diagram in standard SysML. If
* declared, it is defined in terms of a class that extends the
* {@code SysMLStateMachine} abstract base class. This extension class defines
* the state machine in terms of associated SysMLinJava classes for states,
* transitions, guards, effects, events, etc. The {@code SysMLStateMachine} also
* contains a {@code Runnable} that is optionally executed in a concurrent
* execution thread. Use of this runnable allows the state machine to execute
* asynchronously from other model elements therefore enabling more precise
* modeling through multi-threaded model executions.
* <p>
* The {@code SysMLBlock}'s thread-based state machine execution begins with
* invocation of the block's {@code start()} operation. This operation starts
* the state machine runnable in its own thread while the block's {@code stop()}
* method stops the state machine thread. The
* {@code acceptEvent(SysMLEvent event)} method enqueues the specified event to
* the state machine for action as specified by the declared
* {@code SysMLStateMachine}.
* <h3>Optional parent context block</h3> The {@code SysMLBlock} base class also
* provides for an optional context block property which may be used by declared
* operations and activities to access the properties and behaviors of a
* <i>parent</i> block.
* <h3>Thread pool</h3> Also included in this base class for the block is a
* {@code ScheduledThreadPoolExecutor}. This concurrency object is used to "run"
* the declared {@code SysMLStateMachine} instance, but it also provides a
* thread pool for controlled execution of any other concurrent threads of
* execution that might be needed by specializations of the {@code SysMLBlock}.
* Use of the thread pool further enhances SysMLinJava's support for more
* precise modeling through multi-threaded model executions. *
* <h3>Create/initialize methods</h3> Finally, the {@code SysMLBlock} provides a
* series of overrideable method calls to create all the properties (the java
* fields and methods) of the represented SysML block (a java class). The
* {@code SysMLBlock} constructor automatically invokes methods to
* create/initialize the values, flows, references, parts, ports, constraints,
* comments, requirements, etc - any SysML type that can be declared in a SysML
* block. This automatice invocation of methods allows extensions to the
* {@code SysMLBlock} to simply override the {@code createXxxx()} methods for
* the applicable properties (fields) declared in the block (class) and perform
* the creations/initializations in the methods. This ensures the properties are
* created/initialized in the correct and complete sequence needed. The
* overridable {@code createXxxx()} methods provide a "reminder" to create and
* initialize the block's properties as well as a framework for their complete
* definition.
* <p>
* A simplified example of code for a block model follows:
*
* <pre>
public class ElectricMotor extends SysMLBlock
{
@FullPort
public ElectricalPowerReceivePort electricalLine;
@FullPort
public MotorTorqueTransmitPort wheelMotorDisc;
@FullPort
public MechanicalForceTransmitPort suspensionMount;
@Flow
public PowerWatts electricalPowerIn;
@Flow
public TorqueNewtonMeters mechanicalTorqueOut;
@Flow
public ForceNewtons weightOnSuspensionOut;
@Value
public TorqueNewtonMetersPerKilowatt torqueNmPerKw;
@Value
public RevolutionsPerMinute revolutionsPerMinute;
@Value
public Percent motorEfficiency;
@Constraint
public SysMLConstraint mechanicalTorqueCalculation;
public ElectricMotor(MotorInWheelSystem motorInWheelSystem, String name, Long id)
{
super(motorInWheelSystem, name, id);
}
@Operation
public void transmitWeight()
{
suspensionMount.transmit(weightOnSuspensionOut);
}
@Reception
public void onElectricalPower(PowerWatts powerWatts)
{
logger.info(powerWatts.toString());
electricalPowerIn.setValue(powerWatts.value);
mechanicalTorqueCalculation.apply();
wheelMotorDisc.transmit(mechanicalTorqueOut);
}
@Override
protected void createStateMachine()
{
stateMachine = Optional.of(new ElectricMotorStateMachine(this));
}
@Override
protected void createValues()
{
torqueNmPerKw = new TorqueNewtonMetersPerKilowatt(5);
revolutionsPerMinute = new RevolutionsPerMinute(240);
motorEfficiency = new Percent(95);
}
@Override
protected void createFlows()
{
electricalPowerIn = new PowerWatts(0);
mechanicalTorqueOut = new TorqueNewtonMeters(0);
weightOnSuspensionOut = new ForceNewtons(25, Math.toRadians(180));
}
@Override
protected void createFullPorts()
{
electricalLine = new ElectricalPowerReceivePort(this, this, 0);
wheelMotorDisc = new MotorTorqueTransmitPort(this, 0);
suspensionMount = new MechanicalForceTransmitPort(this, 0);
}
@Override
protected void createConstraints()
{
mechanicalTorqueCalculation = () ->
{
mechanicalTorqueOut.value = torqueNmPerKw.value(electricalPowerIn.value / 1000)motorEfficiency.asFraction(); // (60 / (2Math.PI))(electricalPowerIn.value /
// revolutionsPerMinute.value) //(motorEfficiency.value / 100);
};
}
}
* </pre>
*
* @see sysmlinjava.statemachine.SysMLStateMachine
* @see java.util.concurrent.ScheduledThreadPoolExecutor
* @see java.lang.Runnable
*
* @author ModelerOne
*
*/
public abstract class SysMLBlock extends SysMLClass
{
/**
* Optional SysML state machine for this SysML block. The
* {@code SysMLStateMachine} may be declared as "asynchronous" in which case
* it's {@code Runnable} will be automatically executed in one of the threads
* provided by the {@code concurrentExecutionThreads} declared below. Note the
* {@code StateMachine} annotation is used by SysMLinJava tools to identify this
* field as the block's state machine declaration.
*/
@StateMachine
public Optional<? extends SysMLStateMachine> stateMachine;
/**
* Optional SysML block that serves as the block "context" in which this block
* resides. The contextBlock may be used by other block properties, such as
* operations and parts, for access to parent block properties.
*/
public Optional<? extends SysMLBlock> contextBlock;
/**
* Instance of the Java API's {@code ScheduledThreadPoolExecutor} used to "run"
* the optional state machine's {@code Runnable}. It is also available to
* {@code SysMLBlock} extensions to execute other threads of execution that
* might be declared for the block.
*/
public ScheduledThreadPoolExecutor concurrentExecutionThreads;
/**
* Constructor initialized with no state machine, no context block, default name
* and ID
*/
public SysMLBlock()
{
super();
stateMachine = Optional.empty();
contextBlock = Optional.empty();
concurrentExecutionThreads = new ScheduledThreadPoolExecutor(10);
preCreate();
createProperties();
}
/**
* Constructor initialized with no state machine, no context block, specified
* name and ID
*
* @param name name to be associated with the block
* @param id unique identifier for this block
*/
public SysMLBlock(String name, Long id)
{
super(name, id);
stateMachine = Optional.empty();
this.contextBlock = Optional.empty();
concurrentExecutionThreads = new ScheduledThreadPoolExecutor(10);
preCreate();
createProperties();
}
/**
* Constructor initialized with no state machine, specified context block, name
* and ID
*
* @param contextBlock the {@code SysMLBlock} in whose context this
* {@code SysMLBlock} is to operate, i.e. optional parent
* block
* @param name name to be associated with the block
* @param id unique long integer identifier for this block
*/
public SysMLBlock(SysMLBlock contextBlock, String name, Long id)
{
super(name, id);
stateMachine = Optional.empty();
this.contextBlock = Optional.of(contextBlock);
concurrentExecutionThreads = new ScheduledThreadPoolExecutor(10);
preCreate();
createProperties();
}
/**
* Creates/initializes properties as necessary prior to their
* creation/initialization during the {@code createProperties} operation.
* Creations/initializations typically include collection creation prior to
* creation of collection members. An example {@code preCreate()} operation for
* some example properties is as follows.
*
* <pre>
* {@code
* List<ProtocolPort> commsPorts;
* List<Point2D> mountPoints;
*
* @Override
* protected void preCreate()
* {
* commsPorts = new LinkedList<>();
* mountPoints = new ArrayList<>();
* }
* }
* </pre>
*/
protected void preCreate()
{
}
/**
* Creates/initializes the properties of a {@code SysMLBlock} that are declared
* by the fields in classes that extend the {@code SysMLBlock} class. Property
* creation/initialization is performed by overriding and implementing any or
* all of the operations invoked by this operation in accordance with the
* specification of the operations below.
* <p>
* <b>Note:</b> Usage of these creation operations to create/initialize the
* block properties (fields) promotes standardized creation of block properties
* and ensures their correct sequence of construction - all in preparation for
* correct model execution and for use by SysMLinJava tools to correctly
* interpret the Java code as a SysML model. Modelers should ensure that object
* creations are compatible and consistent with the sequence of "create...()"
* calls invoked by this operation. If a different sequence of model
* creation/initialization is required, then this operation may be overridden
* and used to invoke a custom creation/initialization of the block's
* properties. It should be noted, hwever, that SysMLinJava tools use the
* specified {@code create...()} operations to perform their tasks, so using any
* different named operations may void the capabilities of these tools.
*/
protected void createProperties()
{
createClasses();
createValues();
createFlows();
createSignals();
createEvents();
createParts();
createFullPorts();
createProxyPorts();
createActivities();
createConstraints();
createStateMachine();
createRequirements();
createConstraintBlocks();
createReferences();
createConstraintParameterConnectorFunctions();
createConstraintParameterConnectors();
createConnectorFunctions();
createConnectors();
createDependencies();
createElementGroups();
enableInteractionMessageTransmissions();
}
/**
* Starts the block's state machine behavior, if a state machine is present. The
* operation submits an {@code InitialEvent} to the state machine's event queue
* to thereby start its execution thread. The state machine will execute in
* accordance with the states and transitions that are defined in the class that
* extends the {@code SysMLStateMachine}.
*
*/
public void start()
{
if (stateMachine.isPresent())
stateMachine.get().start();
else
logger.warning(getClass().getSimpleName() + ": no state machine to start");
}
/**
* Accepts and queues a specified event into the state machine's event queue.
* Whereas the event queue is a thread safe object, this method can be called to
* inject an event into the state machine from any thread.
*
* @param event event to be queued to the state machine
*/
public void acceptEvent(SysMLEvent event)
{
if (stateMachine.isPresent())
stateMachine.get().queueEvent(event);
else
logger.warning(getClass().getSimpleName() + ": no state machine to accept event: " + event.getClass().getSimpleName());
}
/**
* Stops the block's state machine-based behavior, if a state machine is present
* in the block. The operation simply stops the state machine execution. Note if
* this block's state machine is asynchronous, i.e. executes in its own thread,
* then this operation imposes a "hard stop" where the thread is canceled
* regardless of what state it's in. If the block's state machine is
* synchronous, this operation can only queue up a {@code FinalEvent} to the
* event queue, on the assumption that the state machine is capable of handling
* the {@code FinalEvent} at the point in which the {@code stop()} method is
* invoked. Therefore, if a block is synchronous and this stop method is used,
* it's state machine should be modeled to handle the {@code FinalEvent}
* accordingly.
*/
public void stop()
{
if (stateMachine.isPresent())
stateMachine.get().stop();
else
logger.warning(getClass().getSimpleName() + ": no state machine to stop");
}
/**
* Delays the calling thread (sleeps) for the specified seconds of time.
*
* @param seconds time to sleep in seconds. Use up to 3 decimal places for
* fractions of a second, i.e. the delay is capable of the
* milliseconds precision provided by java's
* {@code Thread.sleep(<millis>)} operation.
*/
public void delay(double seconds)
{
try
{
Thread.sleep((long)(seconds * 1000));
} catch (InterruptedException e)
{
e.printStackTrace();
}
}
/**
* Overridable operation that creates and initializes the block's values.
* <p>
* Code format:
*
* <pre>
myFirstValue = new ValueTypeA(<initializer>);
myNextValue = new ValueTypeB(<initializer>);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Value} annotation and {@code ValueTypeX} is a constructor of
* one of the {@code SysMLValueType} classes, i.e. values are declared by
* {@code SysMLValueType}s. Initializers for Real or Int value types, or for
* extensions of the Real or Int value types, usually include an integer or
* double number as the first argument(s). These numbers should be formatted in
* decimal format. Use of the underscore (e.g. 10_000.01) can be used for
* thousands demarcation which will be converted to comma (10,000.01) by
* SysMLinJava tools for value displays.
*
* @see sysmlinjava.valuetypes.SysMLValueType
*/
protected void createValues()
{
}
/**
* Overridable operation that creates and initializes the block's flows.
* <p>
* Code format:<br>
*
* <pre>
myFirstFlowInOut = new FlowTypeA(<initializer>);
myNextFlowOut = new FlowTypeB(<initializer>);
myNextFlowIn = new FlowTypeB(<initializer>);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Flow} annotation and {@code FlowTypeX} is a constructor of
* one of the {@code SysMLValueType}s, i.e. flows are declared by
* {@code SysMLValueType}s
* <p>
* <b>Note:</b> The name of the flow may/should end with the flow's
* {@code SysMLFlowDirectionKind} string value. If the field annotation does not
* include an annotation member/value pair for the
* {@code SysMLFlowDirectionKind} and the {@code SysMLFlowDirectionKind} string
* value is at the end of the flow variable name, then the string value
* ({@code In, Out, or InOut})will be used as the flow direction.
*
* @see sysmlinjava.valuetypes.SysMLValueType
* @see sysmlinjava.annotations.Flow
* @see sysmlinjava.kinds.SysMLFlowDirectionKind
*/
protected void createFlows()
{
}
/**
* Overridable operation that creates and initializes the block's parts.
* <p>
* Code format:<br>
*
* <pre>
myFirstPart = new PartTypeA(<initializer>);
myNextPart = new PartTypeB(<initializer>);
* </pre>
*
* where the the target of the assignment operation is the name of a field with
* the {@code @Part} annotation and {@code PartTypeX} is a constructor of
* one any class that extends the {@code SysMLBlock} class.
*
* @see sysmlinjava.blocks.SysMLBlock
*/
protected void createParts()
{
}
/**
* Overridable operation that creates and initializes the block's full ports.
* <p>
* Code format:<br>
*
* <pre>
myFirstFullPort = new FullPortTypeA(<initializer>);
myNextFullPort = new FullPortTypeB(<initializer>);
* </pre>
*
* where the the target of the assignment operation is the name of a field with
* the {@code @FullPort} annotation and {@code FullPortTypeX} is a
* constructor of one any class that extends the {@code SysMLFullPort} class.
*
* @see sysmlinjava.ports.SysMLFullPort
*/
protected void createFullPorts()
{
}
/**
* Overridable operation that creates and initializes the block's proxy ports.
* <p>
* Code format:<br>
*
* <pre>
myFirstProxyPort = new ProxyPortTypeA(<initializer>);
myNextProxyPort = new ProxyPortTypeB(<initializer>);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @ProxyPort} annotation and {@code ProxyPortTypeX} is a
* constructor of one any class that implements an extension of the
* {@code SysMLProxyPort} interface.
*
* @see sysmlinjava.ports.SysMLProxyPort
*/
protected void createProxyPorts()
{
}
/**
* Overridable operation that creates and initializes the block's activities.
* <p>
* Code format:
*
* <pre>
myFirstActivity = (<params>) -> <lamda expression/block statement>;
myNextActivity = (<params>) -> <lamda expression/block statement>;
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Activity} annotation and lambda expression/block statement is
* a block statement that corresponds to lambda expression that is an
* implementation of the {@code SysMLActivity} functional interface.
*
* @see sysmlinjava.common.SysMLActivity
*/
protected void createActivities()
{
}
/**
* Overridable operation that creates and initializes the block's connector
* functions, i.e. the code that performs part and port connections.
*
* <pre>
myFirstConnectorFunction = () -> <lamda expression/block statement>;
myNextConnectorFunction = () -> <lamda expression/block statement>;
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @ConnectorFunction} annotation and lambda expression/block
* statement is a block statement that corresponds to a lambda expression that
* is an implementation of the {@code SysMLAssociationBlockConnectorFunction}
* functional interface.<br>
* <b>Note:</b>Connectors in SysMLinJava are declared as
* {@code SysMLAssociationBlockConnector}s, i.e. all connectors must be based on
* defined associations. Hence, the connector function is the code that performs
* the connections that are defined by the association, i.e. the participants of
* the association as defined in the association block.
*
* @see sysmlinjava.connectors.SysMLAssociationBlockConnectorFunction
* @see sysmlinjava.connectors.SysMLAssociationBlockConnector
*/
protected void createConnectorFunctions()
{
}
/**
* Overridable operation that creates and initializes the block's connectors.
* <p>
* Code format:
*
* <pre>
myFirstConnector = new SysMLAssociationBlock(<initializer>participants0>, <initializer>participants1>, <initializer>connectorFunction>);
myNextConnector = new SysMLAssociationBlock(<initializer>participants0>, <initializer>participants1>, <connectorFunction>);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Connector} annotation and
* {@code SysMLAssociationBlockConnector} is a constructor of the
* SysMLAssociationBlockConnector class.<br>
* <b>Note:</b>Connectors in SysMLinJava are declared as
* SysMLAssociationBlocksConnector, i.e. all connectors must be based on defined
* associations. Therefore, the connectorFunction is one of the
* {@code SysMLAssociationBlockConnectorFunction}s that were created in the
* {@code createConnectorFunctions()} operations above. The
* {@code createConnectorFunctions()} operation will be invoked during the
* SysMLAssociationBlockConnector constructor execution to actually "connect"
* the participating elements. The {@code createConnectorFunctions()} operation
* will be invoked before the {@code createConnectors()} operation, thereby
* ensuring that the connector functions are defined before they are executed.
*
* @see sysmlinjava.connectors.SysMLAssociationBlockConnectorFunction
* @see sysmlinjava.connectors.SysMLAssociationBlockConnector
*/
protected void createConnectors()
{
}
/**
* Overridable operation that creates and initializes the block's constraints.
* <p>
* Code format:
*
* <pre>
myFirstConstraint = () -> <lamda expression/block statement>;
myNextConstraint = () -> <lamda expression/block statement>;
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Constraint} annotation and lambda expression/block statement
* is a block statement that corresponds to a lambda expression that is an
* implementation of the {@code SysMLConstraint} functional interface.<br>
* <b>Note:</b>Implementation of this creation operation is very similar to that
* of the {@code createActivities()} operation.
*
* @see sysmlinjava.common.SysMLConstraint
*/
protected void createConstraints()
{
}
/**
* Overridable operation that creates and initializes the block's constraint
* blocks.
* <p>
* Code format:<br>
*
* <pre>
myFirstConstraintBlock = new ConstraintBlockA(<parent>;);
myNextConstraintBlock = new ConstraingBlockB(<parent>;);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @ConstraintBlock} annotation and {@code ConstraintBlockX} is a
* constructor of a class that is an extension of the
* {@code SysMLConstraintBlock} class.<br>
* <b>Note:</b>Constraint blocks in SysMLinJava are extensions of the block,
* just as they are ins standard SysML. While all the features of the block are
* inherited by the {@code SysMLConstraintBlock}, there are a number of features
* that are added by the extended constraint block.
*
* @see sysmlinjava.constraintblocks.SysMLConstraintBlock
*/
protected void createConstraintBlocks()
{
}
/**
* Overridable operation that creates/initializes the constraint block's
* constraint parameter connector functions. An example follows:
*
* <pre>
* aConstraintParameterConnectorFunction = () ->
* {
* SysMLConstraintParameterPort aParameterPort = myConstraintBlock.paramPorts.get("aConstraintParameterID");
* aParameterPort.parameterContextBlock = myBlock;
* aValue.addValueChangeObserver(aParameterPort);
*
* SysMLConstraintParameterPort bParameterPort = myConstraintBlock.paramPorts.get("bConstraintParameterID");
* bParameterPort.parameterContextBlock = myBlock;
* bValue.addValueChangeObserver(vParameterPort);
* };
* </pre>
*
* where the function consists of two parameter connections<br>
* <ul>
* <li>first that binds/connects the {@code aValue} value in {@code myBlock} to
* the {@code aParameterPort} port in the {@code myConstraintBlock} constraint
* block</li>
* <li>second that binds/connects the {@code bValue} value in {@code myBlock} to
* the {@code bParameterPort} port in the {@code myConstraintBlock} constraint
* block</li>
* </ul>
* <b>Note:</b>Constraint blocks in SysMLinJava are extensions of the block,
* just as they are in standard SysML. While all the features of the block are
* inherited by the {@code SysMLConstraintBlock}, there are a number of
* features, such as the constraint parameter port, that are added by the
* extended constraint block.
*
* @see sysmlinjava.connectors.SysMLBindingConnector
* @see sysmlinjava.connectors.SysMLBindingConnectorFunction
* @see sysmlinjava.constraintblocks.SysMLConstraintBlock
* @see sysmlinjava.ports.SysMLConstraintParameterPort
* @see sysmlinjava.ports.SysMLConstraintParameterPortFunction
*/
protected void createConstraintParameterConnectorFunctions()
{
}
/**
* Overridable operation that creates and initializes the constraint block's
* constraint parameter connectors. An example follows:
*
* <pre>
* aConstraintParameterConnector = new SysMLBindingConnector(myParamsBlock, myConstraintBlock, aConstraintParameterConnectorFunction);
* </pre>
*
* where the statement initializes the constraint parameter connector with the
* block that contains the value that is to be "bound" to the port in the
* constraint block.<br>
* <b>Note:</b>Constraint blocks in SysMLinJava are extensions of the block,
* just as they are ins standard SysML. While all the features of the block are
* inherited by the SysMLConstraintBlock, there are a number of features, such
* as the parameter port, that are added by the extended constraint block.
*
* @see sysmlinjava.connectors.SysMLBindingConnector
* @see sysmlinjava.connectors.SysMLBindingConnectorFunction
* @see sysmlinjava.constraintblocks.SysMLConstraintBlock
* @see sysmlinjava.ports.SysMLConstraintParameterPort
* @see sysmlinjava.ports.SysMLConstraintParameterPortFunction
*/
protected void createConstraintParameterConnectors()
{
}
/**
* Overridable operation that creates and initializes the block's declared
* events.
* <p>
* Code format:<br>
*
* <pre>
myTimeEvent = new SysMLTimeEvent(<initializer>);
myCallEvent = new MyCallEvent(<initializer>);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Event} annotation and {@code new SysMLTimeEvent} and
* {@code MyCallEvent} are constructors of a specific time event and an
* extended/specialized call event, respectively.
* <p>
* <b>Note</b> this operation is likely seldom used as events are typically
* instantiated when the event occurs rather than as part of block construction
* - the exception being the {@code SysMLTimeEvent}, which is used to start
* timers as well as to indicate timer expiration.
*
* @see sysmlinjava.events.SysMLEvent
* @see sysmlinjava.events.SysMLCallEvent
* @see sysmlinjava.events.SysMLChangeEvent
* @see sysmlinjava.events.SysMLCompletionEvent
* @see sysmlinjava.events.SysMLSignalEvent
* @see sysmlinjava.events.SysMLTimeEvent
*/
protected void createEvents()
{
}
/**
* Overridable operation that creates and initializes the block's declared
* signals.
* <p>
* Code format:<br>
*
* <pre>
myControlSignal = new ControlSignal(<initializer>);
myMonitorSignal = new MonitorSignal(<initializer>);
* </pre>
* <p>
* where the the target of the assignment operation is the name of a field with
* the {@code @Signal} annotation and {@code new ControlSignal} and
* {@code new MonitorSignal} are constructors of a specific extended/specialized
* type of signal.
* <p>
* <b>Note</b> this operation is likely seldom used as signals are typically
* instantiated when the signal is transmitted rather than as part of block
* construction.
*
*/
protected void createSignals()
{
}
/**
* Overridable operation that creates and initializes the block's declared class
* objects.
* <p>
* Code format:<br>
*
* <pre>
myClassObject = new MyClassObject(<initializer>);
anotherClassObject = new AnotherClassObject(<initializer>);
* </pre>
*
* where the the target of the assignment operation is the name of a field with
* the {@code @Classs} annotation of type {@code SysMClass} extension and
* {@code new MyClassObject} and {@code new AnotherCLassObject} are constructors
* of a specific type of {@code SysMLClass}.
*
* @see sysmlinjava.common.SysMLClass
*/
protected void createClasses()
{
}
/**
* Overridable operation that should create the block's state machine. An
* example follows:
*
* <pre>
* stateMachine = new MyBlocksStateMachine(this);
* </pre>
*
* where {@code stateMachine} is the optional variable that represents the
* blocks state machine and {@code MyBlocksStateMachine} is a class that is an
* extension of the {@code SysMLStateMachine} class.
*
* @see sysmlinjava.statemachine.SysMLStateMachine
*/
protected void createStateMachine()
{
}
/**
* Overridable operation that initializes the block's references.
* <p>
* Code format:<br>
*
* <pre>
* myFirstRef = SomeClass.someObject;
* myNextRef = AnotherClass.anotherObject;
* </pre>
*
* where the the target of the assignment operation is the name of a field with
* the {@code @Reference} annotation and {@code SomeClass.someObject} is a
* reference to an object ({@code static} field) in another {@code SysMLBlock}
* or {@code SysMLClass}.
*
* @see sysmlinjava.common.SysMLClass
*/
protected void createReferences()
{
}
/**
* Overridable operation that initializes the block's requirements. An example
* follows:
*
* <pre>
* myFirstRequirement = MySysMLRequirements.firstSysMLRequirement;
* myNextRequirement = MySysMLRequirements.nextSysMLRequirement;
* </pre>
*
* where the the target of the assignment operation is the name of a field with
* the {@code @Requirement} annotation and
* {@code MySysMLRequirements.firstSysMLRequirement} is a reference to an
* instance of a {@code SysMLRequirement} in an extension/specialization of the
* {@code SysMLRequirements} class.
* <p>
* <b>Note</b> that block requirements should be declared as described above,
* i.e. as references to instantiations of {@code SysMLRequirement}s declared
* and initialized in classes that extend/specialize the
* {@code SysMLRequirements} class. Requirements should <b>not</b> be
* declared/initialized in the block itself. Requirement specifications in the
* typical SysML model are collected in a model package where they can be easily
* queried and managed. The SysMLinJava approach of collecting requirements in a
* single class emulates this method.
*
* @see sysmlinjava.requirements.SysMLRequirements
*/
protected void createRequirements()
{
}
/**
* Overridable operation that creates the dependencies for this block. Overrides
* of this operation should perform initializations of variables annotated as
* dependencies. Whereas dependencies are type of association, each dependency
* should be defined by a field annotated as a
*
* <pre>
* @Dependency
* public APartBlock aPartDependency;
* </pre>
*
* and initialized by an object reference For example:
*
* <pre>
* aPartDependency = ((ParentBlock)contextBlock).bPartBlock;
* </pre>
*
* where {@code aDependency} is the name of a variable that represents a
* dependency (trace, usage, etc} of this block on another model element. Note
* the assignment value should be a reference to another model element, and not
* to a "new" object (constructor).
*/
protected void createDependencies()
{
}
/**
* Overridable operation to enable the transmission from the simulation (model
* execution) to an interaction sequence (sequence diagram) display of the
* interaction messages that occur during the simulation. This operation enables
* a grapical display of the real-time sequence diagram of the interactions
* between the specified parts of the model throughout the simulation.
* <p>
* Interaction messages are representations of the information that is
* transmitted from one full-port to another. By enabling the interaction
* message transmissions here, the information that is transmitted from the
* fullport, i.e. message time, message source block, signal or operation call
* (message), and message destination block, is transmitted to a specified UDP
* port for possible display in a sequence diagram or other representation.
* <p>
* Specifically, interaction message transmissions for a full-port are enabled
* by assigning an instance of the {@code InteractionMessageTransmitters} to the
* {@code messageUtility} variable of the full-port. An example of how to use
* this method to enable transmission of interaction messages for four specific
* full-ports is as follows.
*
* <pre>
* protected void enableInteractionMessageTransmissions()
* {
* InteractionMessageTransmitter transmitter = new InteractionMessageTransmitter(InteractionMessageSequenceDisplay.udpPort);
* InteractionMessageTransmitters interactionMessageTransmitters = new InteractionMessageTransmitters(transmitter);
*
* vehicle.brakeLeftFront.messageUtility = Optional.of(interactionMessageTransmitters);
* vehicle.brakeRightFront.messageUtility = Optional.of(interactionMessageTransmitters);
* vehicle.brakeLeftRear.messageUtility = Optional.of(interactionMessageTransmitters);
* vehicle.brakeRightRear.messageUtility = Optional.of(interactionMessageTransmitters);
* }
* </pre>
*
* @see sysmlinjava.ports.SysMLFullPort
* @see sysmlinjava.ports.SysMLProxyPort
* @see sysmlinjava.ports.InteractionMessageUtility
* @see sysmlinjava.analysis.interactionmessagetransmitter.InteractionMessageTransmitters
* @see sysmlinjava.analysis.interactionsequence.InteractionMessageTransmitter
*/
protected void enableInteractionMessageTransmissions()
{
}
/**
* Name of state machine variable, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String stateMachineVariableName = "stateMachine";
/**
* Name of field for block's state machine, used by SysMLinJava tools, typically
* not needed for modeling
*/
public static final String stateMachineFieldName = "stateMachine";
/**
* Name of method to create state machine, used by SysMLinJava tools, typically
* not needed for modeling
*/
public static final String createStateMachineMethodName = "createStateMachine";
/**
* Name of method to create values, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createValuesMethodName = "createValues";
/**
* Name of method to create flows, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createFlowsMethodName = "createFlows";
/**
* Name of method to create references, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createReferencesMethodName = "createReferences";
/**
* Name of method to create parts, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createPartsMethodName = "createParts";
/**
* Name of method to create full ports, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createFullPortsMethodName = "createFullPorts";
/**
* Name of method to create full ports, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createProxyPortsMethodName = "createProxyPorts";
/**
* Name of method to create activities, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createActivitiesMethodName = "createActivities";
/**
* Name of method to create events, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createEventsMethodName = "createEvents";
/**
* Name of method to create signals, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createSignalsMethodName = "createSignals";
/**
* Name of method to create classes, used by SysMLinJava tools, typically not
* needed for modeling
*/
public static final String createClassesMethodName = "createClasses";
/**
* Name of method to create connector functions, used by SysMLinJava tools,
* typically not needed for modeling
*/
public static final String createConnectorFunctionsMethodName = "createConnectorFunctions";
/**