Compare commits
9 Commits
feat/parse
...
main
Author | SHA1 | Date | |
---|---|---|---|
19c60c5ecf | |||
df3a2ddf68 | |||
42e8e26aa7 | |||
b33531bef5 | |||
ab1386e721 | |||
1f155063a8 | |||
d986284e4e | |||
a037727edf | |||
b0950f5e68 |
@ -15,7 +15,7 @@ This package lets you render sequence diagrams directly in Typst. The following
|
||||
<td>
|
||||
|
||||
```typst
|
||||
#import "@preview/chronos:0.1.0"
|
||||
#import "@preview/chronos:0.2.0"
|
||||
#chronos.diagram({
|
||||
import chronos: *
|
||||
_par("Alice")
|
||||
|
@ -58,10 +58,12 @@
|
||||
/// - width (auto, int, float, length): Optional fixed width of the column\ If the column's content (e.g. sequence comments) is larger, it will overflow
|
||||
/// - margin (int, float, length): Additional margin to add to the column\ This margin is not included in `width` and `min-width`, but rather added separately
|
||||
/// - min-width (int, float, length): Minimum width of the column\ If set to a larger value than `width`, the latter will be overriden
|
||||
/// - max-width (int, float, length, none): Maximum width of the column\ If set to a lower value than `width`, the latter will be overriden\ If set to `none`, no restriction is applied
|
||||
#let _col(
|
||||
p1,
|
||||
p2,
|
||||
width: auto,
|
||||
margin: 0,
|
||||
min-width: 0
|
||||
min-width: 0,
|
||||
max-width: none
|
||||
) = {}
|
Binary file not shown.
@ -1,689 +0,0 @@
|
||||
#import "../src/lib.typ": from-plantuml
|
||||
|
||||
#set page(width: auto, height: auto)
|
||||
|
||||
#let examples = (
|
||||
(
|
||||
[Basic Examples],
|
||||
```
|
||||
@startuml
|
||||
Alice -> Bob: Authentication Request
|
||||
Bob --> Alice: Authentication Response
|
||||
|
||||
Alice -> Bob: Another authentication Request
|
||||
Alice <-- Bob: Another authentication Response
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Declaring participant],
|
||||
```
|
||||
@startuml
|
||||
participant Participant as Foo
|
||||
actor Actor as Foo1
|
||||
boundary Boundary as Foo2
|
||||
control Control as Foo3
|
||||
entity Entity as Foo4
|
||||
database Database as Foo5
|
||||
collections Collections as Foo6
|
||||
queue Queue as Foo7
|
||||
Foo -> Foo1 : To actor
|
||||
Foo -> Foo2 : To boundary
|
||||
Foo -> Foo3 : To control
|
||||
Foo -> Foo4 : To entity
|
||||
Foo -> Foo5 : To database
|
||||
Foo -> Foo6 : To collections
|
||||
Foo -> Foo7: To queue
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Declaring participant (2)],
|
||||
```
|
||||
@startuml
|
||||
actor Bob #red
|
||||
' The only difference between actor
|
||||
'and participant is the drawing
|
||||
participant Alice
|
||||
participant "I have a really\nlong name" as L #99FF99
|
||||
/' You can also declare:
|
||||
participant L as "I have a really\nlong name" #99FF99
|
||||
'/
|
||||
|
||||
Alice->Bob: Authentication Request
|
||||
Bob->Alice: Authentication Response
|
||||
Bob->L: Log transaction
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Use non-letters in participants],
|
||||
```
|
||||
@startuml
|
||||
Alice -> "Bob()" : Hello
|
||||
"Bob()" -> "This is very\nlong" as Long
|
||||
' You can also declare:
|
||||
' "Bob()" -> Long as "This is very\nlong"
|
||||
Long --> "Bob()" : ok
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Message to Self],
|
||||
```
|
||||
@startuml
|
||||
Alice -> Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Message to Self (2)],
|
||||
```
|
||||
@startuml
|
||||
Alice <- Alice: This is a signal to self.\nIt also demonstrates\nmultiline \ntext
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Change arrow style],
|
||||
```
|
||||
@startuml
|
||||
Bob ->x Alice
|
||||
Bob -> Alice
|
||||
Bob ->> Alice
|
||||
Bob -\ Alice
|
||||
Bob \\- Alice
|
||||
Bob //-- Alice
|
||||
|
||||
Bob ->o Alice
|
||||
Bob o\\-- Alice
|
||||
|
||||
Bob <-> Alice
|
||||
Bob <->o Alice
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Grouping message],
|
||||
```
|
||||
@startuml
|
||||
Alice -> Bob: Authentication Request
|
||||
|
||||
alt successful case
|
||||
|
||||
Bob -> Alice: Authentication Accepted
|
||||
|
||||
else some kind of failure
|
||||
|
||||
Bob -> Alice: Authentication Failure
|
||||
group My own label
|
||||
Alice -> Log : Log attack start
|
||||
loop 1000 times
|
||||
Alice -> Bob: DNS Attack
|
||||
end
|
||||
Alice -> Log : Log attack end
|
||||
end
|
||||
|
||||
else Another type of failure
|
||||
|
||||
Bob -> Alice: Please repeat
|
||||
|
||||
end
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Secondary group label],
|
||||
```
|
||||
@startuml
|
||||
Alice -> Bob: Authentication Request
|
||||
Bob -> Alice: Authentication Failure
|
||||
group My own label [My own label 2]
|
||||
Alice -> Log : Log attack start
|
||||
loop 1000 times
|
||||
Alice -> Bob: DNS Attack
|
||||
end
|
||||
Alice -> Log : Log attack end
|
||||
end
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Notes on messages],
|
||||
```
|
||||
@startuml
|
||||
Alice->Bob : hello
|
||||
note left: this is a first note
|
||||
|
||||
Bob->Alice : ok
|
||||
note right: this is another note
|
||||
|
||||
Bob->Bob : I am thinking
|
||||
note left
|
||||
a note
|
||||
can also be defined
|
||||
on several lines
|
||||
end note
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Some other notes],
|
||||
```
|
||||
@startuml
|
||||
participant Alice
|
||||
participant Bob
|
||||
note left of Alice #aqua
|
||||
This is displayed
|
||||
left of Alice.
|
||||
end note
|
||||
|
||||
note right of Alice: This is displayed right of Alice.
|
||||
|
||||
note over Alice: This is displayed over Alice.
|
||||
|
||||
note over Alice, Bob #FFAAAA: This is displayed\n over Bob and Alice.
|
||||
|
||||
note over Bob, Alice
|
||||
This is yet another
|
||||
example of
|
||||
a long note.
|
||||
end note
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Changing notes shape \[hnote, rnote\]],
|
||||
```
|
||||
@startuml
|
||||
caller -> server : conReq
|
||||
hnote over caller : idle
|
||||
caller <- server : conConf
|
||||
rnote over server
|
||||
"r" as rectangle
|
||||
"h" as hexagon
|
||||
endrnote
|
||||
rnote over server
|
||||
this is
|
||||
on several
|
||||
lines
|
||||
endrnote
|
||||
hnote over caller
|
||||
this is
|
||||
on several
|
||||
lines
|
||||
endhnote
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Note over all participants \[across\]],
|
||||
```
|
||||
@startuml
|
||||
Alice->Bob:m1
|
||||
Bob->Charlie:m2
|
||||
note over Alice, Charlie: Old method for note over all part. with:\n ""note over //FirstPart, LastPart//"".
|
||||
note across: New method with:\n""note across""
|
||||
Bob->Alice
|
||||
hnote across:Note across all part.
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Several notes aligned at the same level \[/\]],
|
||||
```
|
||||
@startuml
|
||||
note over Alice : initial state of Alice
|
||||
note over Bob : initial state of Bob
|
||||
Bob -> Alice : hello
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Several notes aligned at the same level \[/\] (2)],
|
||||
```
|
||||
@startuml
|
||||
note over Alice : initial state of Alice
|
||||
/ note over Bob : initial state of Bob
|
||||
Bob -> Alice : hello
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Divider or separator],
|
||||
```
|
||||
@startuml
|
||||
|
||||
== Initialization ==
|
||||
|
||||
Alice -> Bob: Authentication Request
|
||||
Bob --> Alice: Authentication Response
|
||||
|
||||
== Repetition ==
|
||||
|
||||
Alice -> Bob: Another authentication Request
|
||||
Alice <-- Bob: another authentication Response
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Delay],
|
||||
```
|
||||
@startuml
|
||||
|
||||
Alice -> Bob: Authentication Request
|
||||
...
|
||||
Bob --> Alice: Authentication Response
|
||||
...5 minutes later...
|
||||
Bob --> Alice: Good Bye !
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Space],
|
||||
```
|
||||
@startuml
|
||||
|
||||
Alice -> Bob: message 1
|
||||
Bob --> Alice: ok
|
||||
|||
|
||||
Alice -> Bob: message 2
|
||||
Bob --> Alice: ok
|
||||
||45||
|
||||
Alice -> Bob: message 3
|
||||
Bob --> Alice: ok
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Lifeline Activation and Destruction],
|
||||
```
|
||||
@startuml
|
||||
participant User
|
||||
|
||||
User -> A: DoWork
|
||||
activate A
|
||||
|
||||
A -> B: << createRequest >>
|
||||
activate B
|
||||
|
||||
B -> C: DoWork
|
||||
activate C
|
||||
C --> B: WorkDone
|
||||
destroy C
|
||||
|
||||
B --> A: RequestCreated
|
||||
deactivate B
|
||||
|
||||
A -> User: Done
|
||||
deactivate A
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Lifeline Activation and Destruction (2)],
|
||||
```
|
||||
@startuml
|
||||
participant User
|
||||
|
||||
User -> A: DoWork
|
||||
activate A #FFBBBB
|
||||
|
||||
A -> A: Internal call
|
||||
activate A #DarkSalmon
|
||||
|
||||
A -> B: << createRequest >>
|
||||
activate B
|
||||
|
||||
B --> A: RequestCreated
|
||||
deactivate B
|
||||
deactivate A
|
||||
A -> User: Done
|
||||
deactivate A
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
/*(
|
||||
[Lifeline Activation and Destruction (3)],
|
||||
```
|
||||
@startuml
|
||||
'autoactivate on
|
||||
alice -> bob : hello
|
||||
bob -> bob : self call
|
||||
bill -> bob /'#005500'/ : hello from thread 2
|
||||
bob -> george ** : create
|
||||
return done in thread 2
|
||||
return rc
|
||||
bob -> george !! : delete
|
||||
return success
|
||||
|
||||
@enduml
|
||||
```
|
||||
),*/
|
||||
(
|
||||
[Return],
|
||||
```
|
||||
@startuml
|
||||
Bob -> Alice : hello
|
||||
activate Alice
|
||||
Alice -> Alice : some action
|
||||
return bye
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Participant creation],
|
||||
```
|
||||
@startuml
|
||||
Bob -> Alice : hello
|
||||
|
||||
create Other
|
||||
Alice -> Other : new
|
||||
|
||||
create /'control'/ String
|
||||
Alice -> String
|
||||
note right : You can also put notes!
|
||||
|
||||
Alice --> Bob : ok
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Shortcut syntax for activation, deactivation, creation],
|
||||
```
|
||||
@startuml
|
||||
alice -> bob ++ : hello
|
||||
bob -> bob ++ : self call
|
||||
bob -> bib ++ /' #005500'/ : hello
|
||||
bob -> george ** : create
|
||||
return done
|
||||
return rc
|
||||
bob -> george !! : delete
|
||||
return success
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Shortcut syntax for activation, deactivation, creation (2)],
|
||||
```
|
||||
@startuml
|
||||
alice -> bob ++ : hello1
|
||||
bob -> charlie --++ : hello2
|
||||
charlie --> alice -- : ok
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Shortcut syntax for activation, deactivation, creation (3)],
|
||||
```
|
||||
@startuml
|
||||
alice -> bob ++ /'#gold'/: hello
|
||||
bob -> alice --++ /'#gold'/: you too
|
||||
alice -> bob --: step1
|
||||
alice -> bob : step2
|
||||
@enduml
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Incoming and outgoing messages],
|
||||
```
|
||||
@startuml
|
||||
[-> A: DoWork
|
||||
|
||||
activate A
|
||||
|
||||
A -> A: Internal call
|
||||
activate A
|
||||
|
||||
A ->] : << createRequest >>
|
||||
|
||||
A<--] : RequestCreated
|
||||
deactivate A
|
||||
[<- A: Done
|
||||
deactivate A
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Incoming and outgoing messages (2)],
|
||||
```
|
||||
@startuml
|
||||
participant Alice
|
||||
participant Bob #lightblue
|
||||
Alice -> Bob
|
||||
Bob -> Carol
|
||||
...
|
||||
[-> Bob
|
||||
[o-> Bob
|
||||
[o->o Bob
|
||||
[x-> Bob
|
||||
...
|
||||
[<- Bob
|
||||
[x<- Bob
|
||||
...
|
||||
Bob ->]
|
||||
Bob ->o]
|
||||
Bob o->o]
|
||||
Bob ->x]
|
||||
...
|
||||
Bob <-]
|
||||
Bob x<-]
|
||||
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Short arrows for incoming and outgoing messages],
|
||||
```
|
||||
@startuml
|
||||
?-> Alice : ""?->""\n**short** to actor1
|
||||
[-> Alice : ""[->""\n**from start** to actor1
|
||||
[-> Bob : ""[->""\n**from start** to actor2
|
||||
?-> Bob : ""?->""\n**short** to actor2
|
||||
Alice ->] : ""->]""\nfrom actor1 **to end**
|
||||
Alice ->? : ""->?""\n**short** from actor1
|
||||
Alice -> Bob : ""->"" \nfrom actor1 to actor2
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Normal arrow],
|
||||
```
|
||||
@startuml
|
||||
participant Alice as a
|
||||
participant Bob as b
|
||||
a -> b : ""-> ""
|
||||
a ->> b : ""->> ""
|
||||
a -\ b : ""-\ ""
|
||||
a -\\ b : ""-\\\\""
|
||||
a -/ b : ""-/ ""
|
||||
a -// b : ""-// ""
|
||||
a ->x b : ""->x ""
|
||||
a x-> b : ""x-> ""
|
||||
a o-> b : ""o-> ""
|
||||
a ->o b : ""->o ""
|
||||
a o->o b : ""o->o ""
|
||||
a <-> b : ""<-> ""
|
||||
a o<->o b : ""o<->o""
|
||||
a x<->x b : ""x<->x""
|
||||
a ->>o b : ""->>o ""
|
||||
a -\o b : ""-\o ""
|
||||
a -\\o b : ""-\\\\o""
|
||||
a -/o b : ""-/o ""
|
||||
a -//o b : ""-//o ""
|
||||
a x->o b : ""x->o ""
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Itself arrow],
|
||||
```
|
||||
@startuml
|
||||
participant Alice as a
|
||||
participant Bob as b
|
||||
a -> a : ""-> ""
|
||||
a ->> a : ""->> ""
|
||||
a -\ a : ""-\ ""
|
||||
a -\\ a : ""-\\\\""
|
||||
a -/ a : ""-/ ""
|
||||
a -// a : ""-// ""
|
||||
a ->x a : ""->x ""
|
||||
a x-> a : ""x-> ""
|
||||
a o-> a : ""o-> ""
|
||||
a ->o a : ""->o ""
|
||||
a o->o a : ""o->o ""
|
||||
a <-> a : ""<-> ""
|
||||
a o<->o a : ""o<->o""
|
||||
a x<->x a : ""x<->x""
|
||||
a ->>o a : ""->>o ""
|
||||
a -\o a : ""-\o ""
|
||||
a -\\o a : ""-\\\\o""
|
||||
a -/o a : ""-/o ""
|
||||
a -//o a : ""-//o ""
|
||||
a x->o a : ""x->o ""
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Incoming messages (with '|')],
|
||||
```
|
||||
@startuml
|
||||
participant Alice as a
|
||||
participant Bob as b
|
||||
[-> b : ""[-> ""
|
||||
[->> b : ""[->> ""
|
||||
[-\ b : ""[-\ ""
|
||||
[-\\ b : ""[-\\\\""
|
||||
[-/ b : ""[-/ ""
|
||||
[-// b : ""[-// ""
|
||||
[->x b : ""[->x ""
|
||||
[x-> b : ""[x-> ""
|
||||
[o-> b : ""[o-> ""
|
||||
[->o b : ""[->o ""
|
||||
[o->o b : ""[o->o ""
|
||||
[<-> b : ""[<-> ""
|
||||
[o<->o b : ""[o<->o""
|
||||
[x<->x b : ""[x<->x""
|
||||
[->>o b : ""[->>o ""
|
||||
[-\o b : ""[-\o ""
|
||||
[-\\o b : ""[-\\\\o""
|
||||
[-/o b : ""[-/o ""
|
||||
[-//o b : ""[-//o ""
|
||||
[x->o b : ""[x->o ""
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Outgoing messages (with '|')],
|
||||
```
|
||||
@startuml
|
||||
participant Alice as a
|
||||
participant Bob as b
|
||||
a ->] : ""->] ""
|
||||
a ->>] : ""->>] ""
|
||||
a -\] : ""-\] ""
|
||||
a -\\] : ""-\\\\]""
|
||||
a -/] : ""-/] ""
|
||||
a -//] : ""-//] ""
|
||||
a ->x] : ""->x] ""
|
||||
a x->] : ""x->] ""
|
||||
a o->] : ""o->] ""
|
||||
a ->o] : ""->o] ""
|
||||
a o->o] : ""o->o] ""
|
||||
a <->] : ""<->] ""
|
||||
a o<->o] : ""o<->o]""
|
||||
a x<->x] : ""x<->x]""
|
||||
a ->>o] : ""->>o] ""
|
||||
a -\o] : ""-\o] ""
|
||||
a -\\o] : ""-\\\\o]""
|
||||
a -/o] : ""-/o] ""
|
||||
a -//o] : ""-//o] ""
|
||||
a x->o] : ""x->o] ""
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Short incoming (with '?')],
|
||||
```
|
||||
@startuml
|
||||
participant Alice as a
|
||||
participant Bob as b
|
||||
a -> b : //Long long label//
|
||||
?-> b : ""?-> ""
|
||||
?->> b : ""?->> ""
|
||||
?-\ b : ""?-\ ""
|
||||
?-\\ b : ""?-\\\\""
|
||||
?-/ b : ""?-/ ""
|
||||
?-// b : ""?-// ""
|
||||
?->x b : ""?->x ""
|
||||
?x-> b : ""?x-> ""
|
||||
?o-> b : ""?o-> ""
|
||||
?->o b : ""?->o ""
|
||||
?o->o b : ""?o->o ""
|
||||
?<-> b : ""?<-> ""
|
||||
?o<->o b : ""?o<->o""
|
||||
?x<->x b : ""?x<->x""
|
||||
?->>o b : ""?->>o ""
|
||||
?-\o b : ""?-\o ""
|
||||
?-\\o b : ""?-\\\\o ""
|
||||
?-/o b : ""?-/o ""
|
||||
?-//o b : ""?-//o ""
|
||||
?x->o b : ""?x->o ""
|
||||
@enduml
|
||||
```
|
||||
),
|
||||
(
|
||||
[Short outgoing (with '?')],
|
||||
```
|
||||
@startuml
|
||||
participant Alice as a
|
||||
participant Bob as b
|
||||
a -> b : //Long long label//
|
||||
a ->? : ""->? ""
|
||||
a ->>? : ""->>? ""
|
||||
a -\? : ""-\? ""
|
||||
a -\\? : ""-\\\\?""
|
||||
a -/? : ""-/? ""
|
||||
a -//? : ""-//? ""
|
||||
a ->x? : ""->x? ""
|
||||
a x->? : ""x->? ""
|
||||
a o->? : ""o->? ""
|
||||
a ->o? : ""->o? ""
|
||||
a o->o? : ""o->o? ""
|
||||
a <->? : ""<->? ""
|
||||
a o<->o? : ""o<->o?""
|
||||
a x<->x? : ""x<->x?""
|
||||
a ->>o? : ""->>o? ""
|
||||
a -\o? : ""-\o? ""
|
||||
a -\\o? : ""-\\\\o?""
|
||||
a -/o? : ""-/o? ""
|
||||
a -//o? : ""-//o? ""
|
||||
a x->o? : ""x->o? ""
|
||||
@enduml
|
||||
```
|
||||
)
|
||||
)
|
||||
|
||||
#{
|
||||
for (title, uml) in examples {
|
||||
heading(title)
|
||||
box(
|
||||
stroke: gray,
|
||||
inset: 1em,
|
||||
stack(
|
||||
dir: ltr,
|
||||
spacing: 1em,
|
||||
raw(uml.text, block: true, lang: "plantuml"),
|
||||
from-plantuml(uml)
|
||||
)
|
||||
)
|
||||
pagebreak(weak: true)
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,271 +0,0 @@
|
||||
#import "../src/lib.typ": from-plantuml
|
||||
|
||||
#set page(width: auto, height: auto)
|
||||
|
||||
/*
|
||||
#from-plantuml(```
|
||||
@startuml
|
||||
|
||||
actor User as usr
|
||||
participant can_message as can
|
||||
control kartculator as kc
|
||||
queue XF as xf
|
||||
entity Drive as drive
|
||||
entity Steering as steering
|
||||
|
||||
usr -\ xf : set message "move"
|
||||
xf -> can : new value on joystick
|
||||
|
||||
== If X axis change value ==
|
||||
can -> kc : calculate new position
|
||||
kc -> can : build message
|
||||
can -> steering : set new position
|
||||
|
||||
== If Y axis change value ==
|
||||
can -> kc : calculate new torque
|
||||
kc -> can : build message
|
||||
can -> xf : set message "torque"
|
||||
xf -> drive : set new torque
|
||||
|
||||
@enduml
|
||||
```)
|
||||
|
||||
#pagebreak(weak: true)
|
||||
|
||||
#from-plantuml(```
|
||||
@startuml
|
||||
|
||||
actor CAN_BUS as bus
|
||||
participant interrupt as ISR
|
||||
queue XF as xf
|
||||
participant ecan as ecan
|
||||
participant canInterface as can
|
||||
control canMessageController as msg
|
||||
|
||||
|
||||
bus -\\ ISR ++ : can message
|
||||
ISR -> can : newMsg
|
||||
can -> ecan : read
|
||||
ecan --> can : message
|
||||
can -> xf : POST XF
|
||||
destroy ISR
|
||||
group TICK XF
|
||||
xf o-> can : receiveCan()
|
||||
can -> msg : processIncoming()
|
||||
msg -> can : create message
|
||||
can -> xf : POST XF
|
||||
end
|
||||
group TICK XF
|
||||
xf o-> can : sendCan()
|
||||
can -> ecan : write
|
||||
ecan -\\ bus : can message
|
||||
end
|
||||
|
||||
@enduml
|
||||
```)
|
||||
|
||||
#pagebreak(weak: true)
|
||||
*/
|
||||
|
||||
/*
|
||||
#from-plantuml(```
|
||||
@startuml
|
||||
|
||||
participant "Behavior::StateMachine" as sm
|
||||
participant Dispatcher as d
|
||||
participant TimeoutManager as tm
|
||||
entity "Event::Timeout" as t
|
||||
queue "TimeoutManager::timeouts_" as timeouts
|
||||
|
||||
autoactivate off
|
||||
|||
|
||||
|||
|
||||
== Schedule timeout ==
|
||||
|||
|
||||
sm -> sm++ : scheduleTimeout
|
||||
sm -> d ++: getDispatcher
|
||||
d --> sm --: dispatcher
|
||||
sm -> d --++ : scheduleTimeout
|
||||
d -> tm ++: getTimeoutManager
|
||||
tm --> d --: timeoutManager
|
||||
d -> tm --++ : scheduleTimeout
|
||||
tm -> t ** : new
|
||||
t --> tm
|
||||
tm -> timeouts --++: insert
|
||||
|
||||
|||
|
||||
|||
|
||||
== Decrement timeout (and dispatch) ==
|
||||
|||
|
||||
loop every tickInterval
|
||||
?->> tm ++: tick
|
||||
tm -> timeouts : getFront
|
||||
timeouts -> t ++
|
||||
t --> timeouts
|
||||
timeouts --> tm : timeout
|
||||
tm -> t --: decrement
|
||||
end
|
||||
|||
|
||||
note left t
|
||||
When timeout is 0,
|
||||
dispatch event
|
||||
end note
|
||||
t -> timeouts : pop
|
||||
deactivate timeouts
|
||||
t ->? --: pushEvent
|
||||
|
||||
|||
|
||||
|||
|
||||
== Unschedule timeout ==
|
||||
|||
|
||||
sm -> sm++ : unscheduleTimeout
|
||||
sm -> d ++: getDispatcher
|
||||
d --> sm --: dispatcher
|
||||
sm -> d --++ : unscheduleTimeout
|
||||
d -> tm ++: getTimeoutManager
|
||||
tm --> d --: timeoutManager
|
||||
d -> tm --++ : unscheduleTimeout
|
||||
tm -> timeouts --: erase
|
||||
timeouts -> t !!
|
||||
|
||||
@enduml
|
||||
```)
|
||||
*/
|
||||
|
||||
#pagebreak(weak: true)
|
||||
|
||||
#from-plantuml(```
|
||||
@startuml
|
||||
|
||||
participant Behavior as b
|
||||
participant Dispatcher as d
|
||||
entity Event as e
|
||||
participant EventQueue as eq
|
||||
queue "EventQueue::queue_" as q
|
||||
|
||||
== Create an Event ==
|
||||
|||
|
||||
?->> b ++ : GEN
|
||||
b -> e ** : new
|
||||
b -> b --++ : pushEvent
|
||||
e -> b : getBehavior
|
||||
b --> e ++: setBehavior
|
||||
e --> b --
|
||||
b -> d ++ : getDispatcher
|
||||
d --> b
|
||||
b -> d -- : pushEvent
|
||||
d ->? -- : push
|
||||
|
||||
|
||||
|||
|
||||
|||
|
||||
== Push Event ==
|
||||
|||
|
||||
?->> d ++: pushEvent
|
||||
d -> eq--++: push
|
||||
eq -> q ++
|
||||
q --> eq
|
||||
eq -> q -- : pushEndQueue
|
||||
|
||||
|||
|
||||
|||
|
||||
== Dispatch ==
|
||||
|||
|
||||
?->> d ++: executeOnce
|
||||
d -> q : getFront
|
||||
q -> e ++
|
||||
e --> q
|
||||
q --> d : event
|
||||
d -> q : pop
|
||||
deactivate q
|
||||
d -> d --++ : dispatchEvent
|
||||
d -> b ++ : getBehavior
|
||||
b --> d
|
||||
d -> b -- : process
|
||||
b -> b--: processEvent
|
||||
|
||||
destroy e
|
||||
|
||||
@enduml
|
||||
```)
|
||||
|
||||
#pagebreak(weak: true)
|
||||
|
||||
#from-plantuml(```
|
||||
@startuml
|
||||
'https://plantuml.com/sequence-diagram
|
||||
actor User as usr
|
||||
participant "Pb L" as pbL
|
||||
participant "Pb R" as pbR
|
||||
participant "LED L" as ledL
|
||||
participant "LED R" as ledR
|
||||
|
||||
|
||||
== Single click ==
|
||||
|
||||
group Single click left
|
||||
usr -\ pbL ++: pressButton
|
||||
usr -\ pbL : releaseButton
|
||||
pbL -> ledL --++ : blink
|
||||
usr -\ pbL ++: pressButton
|
||||
usr -\ pbL : releaseButton
|
||||
pbL -> ledL -- : endBlink
|
||||
deactivate ledL
|
||||
end
|
||||
|
||||
group Single click right
|
||||
usr -\ pbR ++: pressButton
|
||||
usr -\ pbR : releaseButton
|
||||
pbR -> ledR --++ : blink
|
||||
usr -\ pbR ++: pressButton
|
||||
usr -\ pbR : releaseButton
|
||||
pbR -> ledR -- : endBlink
|
||||
deactivate ledR
|
||||
end
|
||||
|
||||
== Double click ==
|
||||
|
||||
group Double click left
|
||||
usr -\ pbL ++: pressButton
|
||||
usr -\ pbL : releaseButton
|
||||
usr -\ pbL : pressButton
|
||||
pbL -> ledL --++ : blink
|
||||
note right ledL: blink 3x
|
||||
ledL ->x ledL -- : finished
|
||||
end
|
||||
|
||||
group Double click right
|
||||
usr -\ pbR ++: pressButton
|
||||
usr -\ pbR : releaseButton
|
||||
usr -\ pbR : pressButton
|
||||
pbR -> ledR --++ : blink
|
||||
note right ledR: blink 3x
|
||||
ledR ->x ledR -- : finished
|
||||
end
|
||||
|
||||
== Long click ==
|
||||
|
||||
group Long click left
|
||||
usr -\ pbL ++: pressButton
|
||||
pbL -> ledR--: blink
|
||||
activate ledL
|
||||
activate ledR
|
||||
usr -\ pbL ++: pressButton
|
||||
pbL -> ledR -- : endBlink
|
||||
deactivate ledL
|
||||
deactivate ledR
|
||||
end
|
||||
|
||||
group Long click right
|
||||
usr -\ pbR ++: pressButton
|
||||
pbR -> ledR--: blink
|
||||
activate ledL
|
||||
activate ledR
|
||||
usr -\ pbL ++: pressButton
|
||||
pbL -> ledR -- : endBlink
|
||||
deactivate ledL
|
||||
deactivate ledR
|
||||
end
|
||||
|
||||
@enduml
|
||||
```)
|
Binary file not shown.
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
Binary file not shown.
Before Width: | Height: | Size: 96 KiB After Width: | Height: | Size: 92 KiB |
Binary file not shown.
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 24 KiB |
BIN
manual.pdf
BIN
manual.pdf
Binary file not shown.
@ -30,8 +30,8 @@
|
||||
|
||||
#set page(numbering: "1/1", header: align(right)[chronos #sym.dash.em v#chronos.version])
|
||||
#set page(
|
||||
header: locate(loc => align(left)[chronos #sym.dash.em v#chronos.version]),
|
||||
footer: locate(loc => align(center, counter(page).display("1/1", both: true)))
|
||||
header: align(left)[chronos #sym.dash.em v#chronos.version],
|
||||
footer: context align(center, counter(page).display("1/1", both: true))
|
||||
)
|
||||
|
||||
= Introduction
|
||||
|
@ -19,14 +19,15 @@
|
||||
),)
|
||||
}
|
||||
|
||||
#let _col(p1, p2, width: auto, margin: 0, min-width: 0) = {
|
||||
#let _col(p1, p2, width: auto, margin: 0, min-width: 0, max-width: none) = {
|
||||
return ((
|
||||
type: "col",
|
||||
p1: p1,
|
||||
p2: p2,
|
||||
width: width,
|
||||
margin: margin,
|
||||
min-width: min-width
|
||||
min-width: min-width,
|
||||
max-width: max-width
|
||||
),)
|
||||
}
|
||||
|
||||
@ -240,7 +241,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
set text(font: "Source Sans 3")
|
||||
let canvas = render(participants, elmts)
|
||||
fit-canvas(canvas, width: width)
|
||||
}
|
||||
|
||||
#let from-plantuml(code) = {
|
||||
let code = code.text
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
#import "@preview/cetz:0.2.2": draw
|
||||
#import "@preview/cetz:0.3.1": draw
|
||||
#import "consts.typ": *
|
||||
|
||||
#let _grp(name, desc: none, type: "default", elmts) = {
|
||||
|
@ -1,6 +1,5 @@
|
||||
#let version = version(0, 1, 1)
|
||||
#import "diagram.typ": diagram, _gap, _evt, _col
|
||||
#import "parser.typ": from-plantuml
|
||||
#let version = version(0, 2, 0)
|
||||
#import "diagram.typ": diagram, from-plantuml, _gap, _evt, _col
|
||||
|
||||
#import "sequence.typ": _seq, _ret
|
||||
#import "group.typ": _grp, _loop, _alt, _opt, _break
|
||||
|
@ -1,4 +1,4 @@
|
||||
#import "@preview/cetz:0.2.2": draw
|
||||
#import "@preview/cetz:0.3.1": draw
|
||||
#import "consts.typ": *
|
||||
|
||||
#let SIDES = (
|
||||
|
1036
src/parser.typ
1036
src/parser.typ
File diff suppressed because it is too large
Load Diff
@ -1,4 +1,4 @@
|
||||
#import "@preview/cetz:0.2.2": draw
|
||||
#import "@preview/cetz:0.3.1": draw
|
||||
#import "consts.typ": *
|
||||
|
||||
#let PAR-SPECIALS = "?[]"
|
||||
|
@ -1,4 +1,4 @@
|
||||
#import "@preview/cetz:0.2.2": canvas, draw
|
||||
#import "@preview/cetz:0.3.1": canvas, draw
|
||||
#import "utils.typ": get-participants-i, get-style, normalize-units
|
||||
#import "group.typ"
|
||||
#import "participant.typ"
|
||||
@ -218,10 +218,13 @@
|
||||
if elmt.width != auto {
|
||||
widths.at(i) = normalize-units(elmt.width)
|
||||
}
|
||||
widths.at(i) = calc.max(
|
||||
widths.at(i),
|
||||
normalize-units(elmt.min-width)
|
||||
) + normalize-units(elmt.margin)
|
||||
|
||||
let width = widths.at(i)
|
||||
width = calc.max(width, normalize-units(elmt.min-width))
|
||||
if elmt.max-width != none {
|
||||
width = calc.min(width, normalize-units(elmt.max-width))
|
||||
}
|
||||
widths.at(i) = width + normalize-units(elmt.margin)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#import "@preview/cetz:0.2.2": draw
|
||||
#import "@preview/cetz:0.3.1": draw
|
||||
#import "consts.typ": *
|
||||
|
||||
#let _sep(name) = {
|
||||
|
@ -1,4 +1,4 @@
|
||||
#import "@preview/cetz:0.2.2": draw, vector
|
||||
#import "@preview/cetz:0.3.1": draw, vector
|
||||
#import "consts.typ": *
|
||||
#import "participant.typ"
|
||||
#import "note.typ"
|
||||
@ -100,19 +100,27 @@
|
||||
|
||||
y -= Y-SPACE
|
||||
|
||||
let i1 = pars-i.at(elmt.p1)
|
||||
let i2 = pars-i.at(elmt.p2)
|
||||
let width = calc.abs(x-pos.at(i1) - x-pos.at(i2))
|
||||
|
||||
let h = 0
|
||||
let comment = if elmt.comment == none {none} else {
|
||||
let w = calc.min(width * 1pt, measure(elmt.comment).width)
|
||||
box(
|
||||
width: if i1 == i2 {auto} else {w},
|
||||
elmt.comment
|
||||
)
|
||||
}
|
||||
// Reserve space for comment
|
||||
if elmt.comment != none {
|
||||
h = calc.max(h, measure(box(elmt.comment)).height / 1pt + 6)
|
||||
if comment != none {
|
||||
h = calc.max(h, measure(comment).height / 1pt + 6)
|
||||
}
|
||||
if "linked-note" in elmt {
|
||||
h = calc.max(h, note.get-size(elmt.linked-note).height / 2)
|
||||
}
|
||||
y -= h
|
||||
|
||||
let i1 = pars-i.at(elmt.p1)
|
||||
let i2 = pars-i.at(elmt.p2)
|
||||
|
||||
let start-info = (
|
||||
i: i1,
|
||||
x: x-pos.at(i1),
|
||||
@ -169,7 +177,7 @@
|
||||
let m = measure(box(par.display-name))
|
||||
let f = if i1 > i2 {-1} else {1}
|
||||
end-info.x -= (m.width + PAR-PAD.last() * 2) / 2pt * f
|
||||
shapes += participant.render(x-pos, par, y: end-info.y - CREATE-OFFSET)
|
||||
shapes += participant.render(x-pos, par, y: end-info.y)
|
||||
}
|
||||
|
||||
end-info.ll-lvl = lifelines.at(i2).level * LIFELINE-W / 2
|
||||
@ -244,7 +252,7 @@
|
||||
(x2, end-info.y)
|
||||
)
|
||||
|
||||
if elmt.comment != none {
|
||||
if comment != none {
|
||||
comment-anchor = (
|
||||
start: if x-mid < x1 {"south-east"} else {"south-west"},
|
||||
end: if x-mid < x1 {"south-west"} else {"south-east"},
|
||||
@ -268,7 +276,7 @@
|
||||
(x2, end-info.y)
|
||||
)
|
||||
|
||||
if elmt.comment != none {
|
||||
if comment != none {
|
||||
let start-pt = pts.first()
|
||||
let end-pt = pts.last()
|
||||
if elmt.start-tip != "" {
|
||||
@ -348,27 +356,26 @@
|
||||
|
||||
shapes += draw.line(..pts, ..style)
|
||||
|
||||
if elmt.comment != none {
|
||||
if comment != none {
|
||||
shapes += draw.content(
|
||||
comment-pt,
|
||||
elmt.comment,
|
||||
comment,
|
||||
anchor: comment-anchor,
|
||||
angle: comment-angle,
|
||||
padding: 3pt
|
||||
)
|
||||
}
|
||||
|
||||
if elmt.create-dst {
|
||||
let dst-line = lifelines.at(i2)
|
||||
dst-line.lines.push(("create", end-info.y))
|
||||
lifelines.at(i2) = dst-line
|
||||
}
|
||||
if elmt.enable-dst {
|
||||
let dst-line = lifelines.at(i2)
|
||||
dst-line.lines.push(("enable", end-info.y, elmt.lifeline-style))
|
||||
lifelines.at(i2) = dst-line
|
||||
}
|
||||
if elmt.create-dst {
|
||||
end-info.y -= CREATE-OFFSET
|
||||
let dst-line = lifelines.at(i2)
|
||||
dst-line.lines.push(("create", end-info.y))
|
||||
lifelines.at(i2) = dst-line
|
||||
}
|
||||
|
||||
if "linked-note" in elmt {
|
||||
let m = note.get-size(elmt.linked-note)
|
||||
|
@ -1,7 +1,7 @@
|
||||
[package]
|
||||
name = "chronos"
|
||||
version = "0.1.1"
|
||||
compiler = "0.11.0"
|
||||
version = "0.2.0"
|
||||
compiler = "0.12.0"
|
||||
repository = "https://git.kb28.ch/HEL/chronos"
|
||||
entrypoint = "src/lib.typ"
|
||||
authors = [
|
||||
|
Loading…
Reference in New Issue
Block a user