History states have [HS] or [HS*] properties following their names in the state hierarchy. A state with [HS*] property is a deep history state. A state with [HS] property but no [HS*] property has a normal history (or shallow history). When both [HS*] and [HS] are given to a state, [HS] is ignored.
A transition to the (deep or normal) history of a state has [HS] property to distinguish with a transition to the state itself. The property is written behind the TRANSITION descriptor of that transition.
The following is the description of a model with a history state and a deep history state (history1.des):
STATECHART: A [DS] [HS] A1 [DS] A11 [DS] A12 A2 B [HS*] B1 [DS] B11 [DS] B12 B2 TRANSITION: S: A.A1.A11 N: A.A1.A12 E: A11-A12 TRANSITION: [HS] S: A N: B E: A-B TRANSITION: S: B.B1.B11 N: B.B1.B12 E: B11-B12 TRANSITION: [HS] S: B N: A E: B-A
The result of its simulation is:
['A.A1.A11'] > A11-A12 ['A.A1.A12'] > A-B ['B.B1.B11'] > B11-B12 ['B.B1.B12'] > B-A ['A.A1.A11'] > A-B ['B.B1.B12'] > exit
Here, A has a normal history while B has a deep history. The first event A11-A12 changes the model to state A.A1.A12, which is not its default state. The transition triggered by event A-B has [HS] property, so it changes the model to the history of state B. Initially, B's history is empty, so the model transitions to the default substate of B (which is B.B1.B11). Event B11-B12 changes the model to state B.B1.B12. When event B-A is received, the model goes back to the history of A. The history was recorded at the time when the model left state A. At that time, the model was in state A.A1.A12. However, because the history of A is normal history, it only records the child of A that the model was in (A.A1). As a result, the model changes the default substate of A.A1, which is A.A1.A11. When event A-B is received at this time, the model goes to the deep history of B, so the new state before exiting is B.B1.B12.