Title: StateModel Design 1 Data Stucture Diagram DSDEERD
1StateModel Design 1Data Stucture Diagram
(DSD/EERD)
SchemaVersion SV SchemaName VersionNo LastModAutho
r LastModDate
FuncPtr Array (LCP-declared
link-time-updated index initialized in ST)
StateModel SM abbrev name SMdescription
(In BDE draw non-key attributes only primary
and foreign keys are implicit)
ActionRoutine AR ARname ARdescription
//Alternate home for //STs AR attributes
State ST stateName ARname ARptr (FPindex)
STdescription
EventType ET label ETdescription
TBD ES Event Type Signature (Actual Args)
Transition TR EventLabel TRdescription
FormalParam FP (TBD Constraints on actual
args in EI)
Enable EN
- Each table must have a unique two-letter
abbreviation ttabbr - Each TTabbrev produces a primary key (pkey)
attribute - Each 1M relationship produces a foreign key
(fkey) - Attribute formats and descriptions must also be
acquired These are added on this
diagram or directly to file StateModel.sch, which
comprises a Data Dictionary of entities,
classes, relations and attributes. - This state model belongs to the LCP namespace
subschema, which also includes Tables
AC, AI and EI
2StateModel Design 2StateModel.sch File
(incomplete)
- SchemaVersion SV / schema version containing
this state mode / - / SV Attributes name, versionNo,
lastModAuthor, lasModDate/ -
- StateModel SM / State Model for one Active
Class ( TT000001 SM) / -
- SMid NA c8 1 / pkey of this State Model
/ - SVid NA c8 1 / fkey of Schema Version /
- Abbrev NA i4 0 / ttabbrev of Modeled Object?
/ - Name NA t80 0 / Full Name or Description of
SM / -
- State ST / One state or stage of behavior
( TT000002 ST) / -
- STid NA c8 1 / pkey of this STat e /
- SMid NA c8 1 / fkey of parent State
Model / - STname NA c32 0 / a name to identify this
state / - ARname NA c8 0 / Action Routine Name /
- ARptr NA i4 0 / Was pointer, now integer
index since 04s522) / - Descrip NA t80 0 / Full Name or Description of
State / -
3StateModel Design 3Revert to Sparse Diagram
Style
The above diagram is far too cluttered to see the
big picture of inter-class relationship
context, let alone add new nodes and links
this context is the main reason for graphics in
the first place, and practically demands a less
cluttered diagram style. Therefore
(1) Move full class name to a separate table or
list of ltTTabbrev, Entity Namegt pairs (but keep
it on the diagram). (2) Remove all attributes
(primary and foreign keys and non-key attributes)
to a separate schema.sch text file. (3)
Hyperlink from diagram nodes to anchor poins in
the schema.sch file. (Here, we will link to later
.ppt slides) (4) Replace MN relationship links
with associative entities, for which UML.
(Multiplicity almost always defaults to 1..1 to
0.. ) (5) External class and data member
definitions would allow multi-line text in the
description field of StateModel.sch,htm.
(Editing these into the schema.sch file is easy
with an ASCII data format.)
4StateModel Design 4Use of Sparse Diagram
StyleAdd AC, ES (dynamic) AI, EI
Note This .ppt imitates the Data Modeling style
of the Block Diagram Editor (COOL-BDE), a
directed graph of nodes and links. These form the
skeleton of an RDB schema StateModel.sch, which
declares entity classes, relations and
attributes.
NS (TBD)
FunctionArray (Textually declared and
link-time-updated, with index installed in ST)
SV
Indexed, not keyed, in ST or FP.
SM
AC
SA
ET
ST
AI
FP
out
in
TR
ES (TBD)
EI
EN
List of Table Types
NS NameSpace (TBD) SV SchemaVersion SM
StateModel AC ActiveClass AI ActiveInstance ET
EventType
ST State SA StateAction TR Transition EN
Enable EI EventInstance ES EtypeSignature
(TBD) FP FormalParameter (TBD)
5StateModel Design 5TBD Plans for SM Schema
- Two MN associations could relate an EventType
with all allowable sending and receiving
ActiveClasses for this ET. This would be a
class-level constraint on the source and
destination classes that could communicate by
means of any runtime EventType (inter-Class
Collaboration Diagram). - Another pair of MN associations between AI and
ET (not shown) would constrain specific Active
Instances that could communicate by means of this
EventType (object instance wiring diagram). - These constraints are runtime-checkable by the
Event Dispatcher at any site in the system where
an Event Instance que (EI table) is managed (all
such EIs have two ActiveInstance foreign keys
which identify its AIid1_sender and
AIid2_receiver).
ET
Table Types in View AC ActiveClass ET
EventType AI ActiveInstance EI
EventInstance ES EtypeSignature SC
SendingConstraint RC ReceivingConstraint
AC
ES
SC
RC
AI
EI
6StateModel Design - 6 bde2sch Conversion
EERDfile.dat from BDE
BDE
BDE
(HG to SM HN to ST HL to TR)
(SM to HG ST to HN TR to HL)
b2t
t2b
ERDfile.msdat
(Alt. input, using chgen -datinput
t2s
chgen/gencpp
(default input to chgen)
Generated files pr_.c and .h
EERDfile.sch
since v11, chgen meta EERDfile.sch does s2t
7StateModel Design - 7 Schema Tables TT and TA
(Schema as stored in tables TT and TA for
brevity, the attributes of tables FT, SF and SV
are not shown)
TableTypes TT / holds description of each table
type /
PKey TTabb TableName Description TT00000
1 SM StateModel / Model for one Active
Class / TT000002 ST
State / Behavior of this state /
TT000003 TR Transition / Transition STid1 to
STid2 / TT000004 ET EventType / Table
of Event Types /
TT000005 EN EventEnable / associates etent
with transition / TT000007
FT FunctionTable / Table of Acton Routine
Functions / TR000008 SF StateFunction /
asssociates State with its Action / TT000009
SV SchemaVersion / identifies schema and
tracks changes/
TT.TAid_fcp for row 1 of table TT
TableAttributes TA / holds definition of each
attribute /
TAid(Pkey) TTid(parent) Name Alt type is_key
Description TA000001 TT000001 SMid NA
c8 1 / pkey of this State Model /
TA000002 TT000001 Abbrev NA c4 0 / ttabbrev of
Modeled Object? / TA000003 TT000001 Name
NA t80 0 / Full Name or Description of SM /
TA000004 TT000002 STid NA c8 1 / pkey of this
STat e / TA000005 TT000002 SMid NA c8 1 / fkey
of parent State Model/ TA000006 TT000002 ActName
NA c8 0 / Action Routine Name /
TA000007 TT000002 ActFunc NA c8 0 / Action
Routine Function pointer/ TA000008 TT000002 Name
NA t80 0 / Full Name or Description of State/
TA000009 TT000003 TRid NA c8 1 / pkey of this
State Transition/ TA000010 TT000003 STid1 NA c8
1 / Transition Source or 'From' State /
TA000011 TT000003 STid2 NA c8 1 / Transition
Destination or 'To' STate/ TA000012 TT000004 ETid
NA c8 1 / pkey of Event Type
/ TA000013 TT000004 SMid NA c8 1 / State
Model Receiving this ET / TA000014 TT000004 Lab
el NA c32 0 / State Transition label
/ TA000015 TT000004 Descrip NA t80 0 /
Event Type description/ TA000016 TT000005 ENid N
A c8 1 / pkey of ENable relation (ET to TR)/
TA000017 TT000005 ETid NA c8 1 / fkey to Event
Type / TA000018 TT000005 TRid NA c8 1 / fkey
of enabled State Transition/ . . . (attribs of
tables FT, SF and SV) . . .
TT.TAid_fcp for row 5 of table TT
Note that metadata tables TT and TA have the same
format as ordinary tables described by
instances of TT and TA. Therefore, metatables TT
and TA can also be defined and stored
in two rows of TT and eleven rows of TA.
8StateModel Design - 8 Schema Tree (Tables
Depth-First)
(Schema reordered so each TT-row is followed by
its TA children Table keys are consecutive
within Begin/Enb Brackes (BB, EB) BB contains
first pkey and invariant fkey for its block.)
Column Names TT TTabb TableName
Description TA Name NA type is_key
Description
BB TT000001 NS NameSpace / identifies a
namespace scope for pkeys / BB TA000001
TT000001 / 4 attributes of class NS NSId,
NSname, NSowner, NSmodDate / EB
T000004 SV SchemaVersion / identifies schema
and tracks changes/ BB TA000005 TT000002 / 6
attributes of class SV SVid, NSid, name,
version, author, date ) / EB TA000008 SM StateMod
el / Model for one Active Class /
BB TA000009 TT000003 SMid NA
c8 1 / pkey of this State Model / Abbrev NA
c4 0 / ttabbrev of Modeled Object? / Name NA
t80 0 / Full Name or Description of SM / EB
TA000011 ST State / Behavior of this state /
BB TA000012 TT000004 STid NA c8 1
/ pkey of this STat e / SMid NA c8 1 /
fkey of parent State Model/ ActName NA c8 0 /
Action Routine Name / ActFunc NA c8 0 / index
into Action Routine Pointer Array / Name
NA t80 0 / Full Name or Description of State/
EB TA000016 (continued next slide)
9StateModel Design - 8 Schema Tree (Tables
Depth-First)
(Schema reordered so each TT-row is followed by
its TA children
TT-rows TTabb TableName Description TA-rows
Name Alt type is_key Description
TR Transition / links prior and next state
/ BB TA000017 TT000005 . . TRid NA c8 1 /
pkey of this State Transition/ STid1 NA c8 1
/ Transition Source or 'From' State / STid2
NA c8 1 / Transition Destination or 'To'
STate/ EB TA000019 ET EventType / Table of
Event Types / BB TA000020 TT000006
ETid NA c8 1 / pkey of Event Type / SMid
NA c8 1 / State Model Receiving this ET /
Label NA c32 0 / State Transition label
/ Descrip NA t80 0 / Event Type
description/ EB TA000023 EN EventEnable /
Associates event with transition / BB
TA000024 TT000007 ENid NA c8 1 / pkey of ENable
relation (ET to TR)/ ETid NA c8 1 / fkey to
Event Type / TRid NA c8 1 / fkey of enabled
State Transition/ EB TA000026 AR
ActionRoutine / Table of State Acton Routine
Functions / BB TA000027 TT000008 / attributes
of class AR go here / EB TA000027? EB TT000008
10- Note that metadata tables TT and TA have the same
format as ordinary tables described by
instances of TT and TA. - Therefore, metatables TT and TA can also be
defined and stored in two rows of TT and eleven
rows of TA.
11StateModel Design - 6Two-State SM Example
State Model Name TSTwo-State
ET01TSSet
TSS0OFF no-op
TSS1ON no-op
ET02TSReset
This state model has two states, two
transitions, and two event types. Each state has
one incoming transition, one outgoing transition,
and one ActionRoutine named no-op, which is
executed on entry to either state.
- This Diagram can be stored in a SMStateModel.dat
file - File SMStateModel.dat can be generated two ways
- From string constant declarations in a LCP API
code file. - From bde2SM (.bde to .dat file converter)
(TBUpdated)
12StateModel Design - 7(Two-State Model Conversion
to a SM.dat File)
SchemaVersion table entry omitted
EventType.Label field syntax restructured as in
the revised ChkgAcct.ppt case study. (Generate
this file from ST, TR and ET declared as strings.)
State Model Name TSTwo-State
ET01TSSet
TSS0OFF no-op
TSS1ON no-op
ET02TSReset
bde2sch
TwoStateSM.bde
BDE
TwoStateSM.sch
SV000001 TS TwoState / equiv. to an RS
Flipflop / /-------------------- (comment lines
are ignored by pr_load) ----------------/ ST00000
1 SM000001 TSS0Off no-op / Initial
stateoutput0 / ST000002 SM000001 TSS1On
no-op / Alternate stateoutput1/ /-----------
--------------------------------------------------
------------------------------/ TR000001
ST000001 ST000002 / enabled by set event
/ TR000002 ST000002 ST000001 / enabled by
reset event / /-------------------------------
--------------------------------------------------
----------/ ET000001 SM000001 ET01TSSet /
causes ON-to-OFF TR / ET000002 SM000001
ET02TSReset / causes OFF-to-ON TR
/ /---------------------------------------------
----------------------------------------------/ E
N000001 ET000001 TR000001 / TSset enables TR1
ST1-gtST2 / EN000002 ET000002 TR000002 /
TSReset enables TR2 ST2-gtST1 /
13StateModel Schema NameSpace and SchemaVersion
- NameSpace NS / (TBD) permits locally scoped
table types / - / E.g. StateModel, LCP, BDE, ERD, JPsim ,
other apps / - NSName
- lastModAuthor
- lastModDate
- lastModPath
- NSDescription
-
- SchemaVersion SV / schema version containing
this state mode / -
- namespaceName
- schemaVersionNo
- lastModAuthor
- lastModDate
- lastModPath
- SVDescription
14StateModel Design StateModel and STate
- StateModel SM / State Model for some Active
Class method / -
- SMid NA c8 1 / pkey of this State
Model / - SVid NA c8 1 / fkey of Schema
Version / - ACid NA c8 1 / Active Class having this state
model / - Abbrev NA i4 0 / ttabbrev of Modeled
Object? / - SMName NA c32 0 / Name of this state
model / - SMdescription t80 0 / Description of State
Model / -
- State ST / One state or stage of behavior
/ -
- STid NA c8 1 / pkey of this STate /
- SMid NA c8 1 / fkey of parent State
Model / - STname NA c32 0 / a name to identify this
state / - ARname NA c32 0 / Action Routine (func)
Name / - ARptr NA i4 0 / Action Routine (func)
index (04f522)/ - Descrip NA t80 0 / Full Name or Description
of State /
15StateModel Schema - TRansition, EventType, Enable
- Transition TR / Allowable transition STid1
to STid2 / -
- TRid NA c8 1 / pkey of this State
Transition / - STid1 NA c8 1 / Transition Source or 'From'
State / - STid2 NA c8 1 / Transition Destination or 'To'
State / -
- EventType ET / Event Type (asynchronous
message type) / - /TBD M-to-N-Associate ET with sender ACid1,
receiver ACid2 / - ETid NA c8 1 / pkey of Event Type /
- SMid NA c8 1 / State Model target of
EventType / - Label NA c8 0 / Event Type Name
(ltSMgtEltnamegt)/ - Descrip NA t80 0 / Event Type
description / -
- EventEnable EN / Relates Event Types to State
Transitions / -
- ENid NA c8 1 / pkey of ENable relation (ET to
TR) /