Skip to content

Instantly share code, notes, and snippets.

@bewest
Last active May 24, 2016 04:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bewest/484f8c69737d57907224 to your computer and use it in GitHub Desktop.
Save bewest/484f8c69737d57907224 to your computer and use it in GitHub Desktop.
stpa loops control, dpic

stpa loops in .pic

That's right! Good old dpic!

man pic or man dpic for more details.cat fig.pic | dpic -g | ~/.cabal/bin/pandoc --filter ~/src/pandocfilters/examples/tikz.py -o fig.pdf

cat fig.pic | dpic -g | ~/.cabal/bin/pandoc --filter ~/src/pandocfilters/examples/tikz.py -o fig.pdf

.PS
down
PAN: [
Sensor: circle "Sensor"
move
Receiver: circle "Receiver"
move
Uploader: circle "Android Uploader"
{
arrow from Sensor to Receiver chop
arrow from Receiver to Uploader chop
}
]
move
Cloud: [
right
Mongo: circle "MongoDB://"
move
S: [
down
MQTT: circle "mqtt://"
move
Web: circle "https://"
]
{
arrow from S.MQTT to S.Web chop
arrow from S.Web to Mongo chop
}
] with .s at PAN.se + (.0, -1.75)
move
{
arrow from PAN.Uploader to Cloud.Mongo chop
arrow from PAN.Uploader to Cloud.S.MQTT chop
arrow from PAN.Uploader to Cloud.S.Web chop
}
WebApp: [
right
box "Web App"
]
move
Viewers: [
right
Pebble: box "Pebble"
move
WebApp: box "Browser"
move
Others: box "Widgets"
]
{
arrow from Cloud.Mongo to WebApp chop
arrow from WebApp.s to Viewers.Pebble.n
arrow from WebApp.s to Viewers.WebApp.n
arrow from WebApp.s to Viewers.Others.n
}
move
Followers: circle "Followers"
{
arrow from Viewers.Pebble.s to Followers chop
arrow from Viewers.WebApp.s to Followers chop
arrow from Viewers.Others.s to Followers chop
}
.PE
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
.PS
\definecolor{puce}{rgb}{0.8,0.53,0.6}%
down
m=.5
define surround {
box dashed ht ($1.ht) + m wid $1.wid + m at $1;
}
linethick=.4
define labeled_box {
box thick 0.25 ht ($1.ht) + m wid $1.wid + m/2 at $1 + (0, m/4);
$2 at last box.n above
move to last [ ].s
}
Human: [
right
CAG: [ B: box "inconsistent, incorrect" "or delayed" ht boxht * 5/3 wid boxwid*2
Sides: [ box invis ht B.ht/2 wid B.wid ] with .c at B.c;
Top: [ box invis wid B.wid/8 ht B.ht ] with .c at B.w + (B.wid/8, 0);
]
move right
MPTR: [
boxht=boxht * 2/3;
boxwid=boxwid * 6/3;
down
Models: [ B: box "inconsistent, incomplete" "or incorrect"
Sides: [ box invis ht B.ht/2 wid B.wid ] with .c at B.c;
]
move .25
M: box "inconsistent, incomplete" "or incorrect"
]
"\large {Model of Controller}" above at MPTR.Models.n
"\large {Model of Physiology}" above at MPTR.M.n
# arrow from MPTR.M.w + (0, boxht * .25) to CAG.e - (0, boxht * .5) ;
# arrow from MPTR.Models.w - (0, boxht * .25) to CAG.e + (0, boxht * .5) ;
]
# surround(Human)
labeled_box(Human, "\Large {Human Controller}");
# box ht boxht * 1/2
# move to last [ ].s;
# move .5
Actuators: [
right;
Frame: [ box invis wid boxwid * 19/3 ht boxht * 2]
Buttons: [ box "Buttons" ht boxht*.5
IN: last box.n - (boxwid * 1/3, 0)
OUT: last box.s - (boxwid * 1/3, 0)
] with .w at Frame.w;
box invis
box invis
UI: box "Displays and Alarms" wid boxwid*7/4 ht boxht*.5
Right: box invis wid boxwid * 1.2
]
box invis ht boxht * 1/2
AIController: [
right;
box invis
CAG: [ B: box "Inadequate (Flaws in" "creation, Process changes," "Incorrect modification or adaptation" wid boxwid*3
Hook: box invis wid boxwid/3 at B.w
]
move right;
PTR: [
down
Models: box "inconsistent, incomplete" "or incorrect" wid boxwid * 6/3
]
CTL: CAG.w + (0, CAG.ht * 1/3)
CBR: CAG.e - (0, CAG.ht * 1/3)
"\large {Controller Algorithm}" above at CAG.n
"\large {Model of Physiology}" above at PTR.Models.n
# circle with .c at CTL
Inner: box invis ht CAG.ht wid PTR.wid + CAG.wid + (boxwid * 2/3) with .w at CAG.B.w;
Thirds: box invis ht (CAG.B.ht * 2/3) with .w at CAG.B.w
]
labeled_box(AIController.Inner, "\Large {Automated Controller}");
box ht boxht * .5 invis
# move .5
SenseFrame: [
right
Left: box invis
box invis;
Mid: box wid 3/3 invis
Right: box wid boxwid * 1/2 invis
box wid boxwid * 1/2 invis
box invis
box invis
box invis
]
Sensors: [
right;
# move -1.5;
B: [ box invis wid 5.5 ] at SenseFrame.Left.w;
Pump: box "Insulin Pump" ht boxht*.5 wid 1.25 with .w at B.w;
Glucose: box "Glucose Sensor(s)" wid boxwid*2 ht boxht*.5 with .e at SenseFrame.Mid.c;
Right: box invis wid boxwid * 4/3;
] with .c at SenseFrame.c;
box invis ht boxht * .5
Body: [
Organs: box "Organ failure" "Changes over time" wid 1.25;
"\Large Human Body" above at Organs.n;
move to Organs.s;
]
P: arrow from Body.e - (0, Body.ht * 1/3) right;
line <- from Body.w - (0, Body.ht * 1/3) left;
# move to Body.e + (0, Body.ht * 1/3)
# data from body observed by sensors
UB: arrow from Body.e + (0, Body.ht * 1/3) right then to (P.e, Sensors.Glucose.s);
line <- from Body.w - (0, Body.ht * 1/3) left left;
line <- from Body.s down .25;
arrow from Sensors.Pump.s down to (Sensors.Pump.s, UB.w) then to (Body.w, UB.w) - (0.03, 0)
arrow from Sensors.Glucose.w left to (AIController.s, Sensors.Glucose.w) then to AIController.s;
arrow dashed from Sensors.Glucose.e to Sensors.Right.e then up;
continue to (Here, Human.MPTR.Models.Sides.ne) then to Human.MPTR.Models.Sides.ne;
arrow from AIController.Thirds.sw to (Actuators.Buttons.OUT, AIController.CBR) then to (Actuators.Buttons.OUT, Sensors.Pump.n);
arrow from (AIController.CBR, AIController.CTL) to (AIController.PTR.Models.w, AIController.CTL)
arrow from (AIController.PTR.Models.w, AIController.CBR) to AIController.CBR
arrow from Actuators.Buttons.OUT to (Actuators.Buttons.OUT, AIController.CTL) then to AIController.Thirds.nw;
arrow from AIController.CAG.Hook.ne up boxht * 1/2 then right boxwid * 1.25;
continue to (Here, Actuators.UI.w) then to Actuators.UI.w;
arrow from (Human.MPTR.M.s, Actuators.UI.n) to Human.MPTR.M.s;
arrow from Actuators.UI.e to Actuators.Right.e then up;
continue to (Here, Human.MPTR.Models.Sides.se ) then to Human.MPTR.Models.Sides.se;
arrow from Human.CAG.Sides.sw to (Actuators.Buttons.n, Human.CAG.Sides.sw) then to Actuators.Buttons.n
arrow dashed from Human.CAG.Sides.nw to (Actuators.Buttons.nw, Human.CAG.Sides.nw) - (boxwid/8, 0);
continue to (Here, Sensors.Pump.nw);
arrow from (Human.MPTR.Models.Sides.w, Human.CAG.Sides.ne) to Human.CAG.Sides.ne;
arrow from (Human.MPTR.M.w, Human.CAG.Sides.se) to Human.CAG.Sides.se;
Environment: [ box invis ht boxht*2.5 wid Human.CAG.Top.wid ] with .s at Human.CAG.Top.n
arrow from Environment.nw to Human.CAG.Top.nw
arrow from Environment.ne to Human.CAG.Top.ne;
[
B: box invis wid boxwid*2
"\large {Written/Trained}" rjust "\large {Procedures}" at B.e rjust below;
"Inadequate or delayed" at B.se rjust below;
# Environment.nw - (0, .25)
] with .ne at Environment.nw - (.1, 0)
[
B: box invis wid boxwid*2
"\large {Environmental}" ljust "\large {Context/Activities/Events}" at B.w ljust below
] with .nw at Environment.ne + (.1, 0)
[
B: box invis
"\large {Control Action}" ljust above "\large {Generation}" ljust at B.w - (-.1, .1)
] with .sw at Human.CAG.Top.ne
.PE
PANDOC=$(shell which pandoc ~/.cabal/bin/pandoc | head -n 1)
all: fig.pdf top_level.pdf
%.pdf: %.pic
cat $< | dpic -g | ${PANDOC} --filter ~/src/pandocfilters/examples/tikz.py -o $@
# cat fig.pic | dpic -g | ~/.cabal/bin/pandoc --filter ~/src/pandocfilters/examples/tikz.py -o fig.pdf
@bewest
Copy link
Author

bewest commented Feb 26, 2016

loop

@bewest
Copy link
Author

bewest commented May 24, 2016

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment