-
Notifications
You must be signed in to change notification settings - Fork 26
/
Body.hs
297 lines (249 loc) · 11.3 KB
/
Body.hs
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
module Drasil.Projectile.Body (printSetting, si, srs, projectileTitle, fullSI) where
import Language.Drasil
import Drasil.SRSDocument
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Language.Drasil.NounPhrase.Combinators as NP
import qualified Language.Drasil.Sentence.Combinators as S
import qualified Drasil.DocLang.SRS as SRS
import Data.Drasil.Concepts.Computation (inValue, algorithm, inDatum, compcon)
import Data.Drasil.Concepts.Documentation (analysis, doccon, doccon', physics,
problem, srsDomains, assumption, goalStmt, physSyst, sysCont, software, user,
requirement, refBy, refName, typUnc, example, softwareSys, system, environment,
product_, interface, condition, physical, datum, input_, softwareConstraint,
output_, endUser)
import qualified Data.Drasil.Concepts.Documentation as Doc (srs, physics, variable)
import Data.Drasil.Concepts.Math (cartesian, mathcon)
import Data.Drasil.Concepts.PhysicalProperties (mass)
import Data.Drasil.Concepts.Physics (gravity, physicCon, physicCon',
rectilinear, oneD, twoD, motion)
import Data.Drasil.Concepts.Software (errMsg, program)
import Data.Drasil.Software.Products (sciCompS)
import Data.Drasil.Quantities.Math (pi_, piConst)
import Data.Drasil.Quantities.Physics (acceleration, constAccel,
gravitationalAccelConst, iPos, iSpeed, iVel, ixPos, iyPos, ixVel, iyVel,
position, scalarPos, time, velocity, xAccel, xConstAccel, xPos,
xVel, yAccel, yConstAccel, yPos, yVel, physicscon)
import Data.Drasil.People (brooks, samCrawford, spencerSmith)
import Data.Drasil.SI_Units (metre, radian, second)
import Data.Drasil.Theories.Physics (accelerationTM, velocityTM)
import Data.Drasil.TheoryConcepts (dataDefn, genDefn, inModel, thModel)
import Data.Drasil.Concepts.Education(calculus, educon, undergraduate,
highSchoolPhysics, highSchoolCalculus)
import Drasil.Projectile.Assumptions (assumptions)
import Drasil.Projectile.Concepts (concepts, launcher, projectile, target)
import Drasil.Projectile.DataDefs (dataDefs)
import Drasil.Projectile.Figures (figLaunch, sysCtxFig1)
import Drasil.Projectile.GenDefs (genDefns)
import Drasil.Projectile.Goals (goals)
import Drasil.Projectile.IMods (iMods)
import Drasil.Projectile.References (citations)
import Drasil.Projectile.Requirements (funcReqs, nonfuncReqs)
import Drasil.Projectile.Unitals
import Theory.Drasil (TheoryModel)
srs :: Document
srs = mkDoc mkSRS (S.forGen titleize phrase) si
fullSI :: SystemInformation
fullSI = fillcdbSRS mkSRS si
printSetting :: PrintingInformation
printSetting = piSys fullSI Equational defaultConfiguration
mkSRS :: SRSDecl
mkSRS = [TableOfContents,
RefSec $
RefProg intro
[ TUnits
, tsymb [TSPurpose, TypogConvention [Vector Bold], SymbOrder, VectorUnits]
, TAandA
],
IntroSec $
IntroProg justification (phrase projectileTitle)
[ IPurpose $ purpDoc projectileTitle Verbose
, IScope scope
, IChar [] charsOfReader []
, IOrgSec inModel (SRS.inModel [] []) EmptyS],
GSDSec $
GSDProg
[ SysCntxt [sysCtxIntro, LlC sysCtxFig1, sysCtxDesc, sysCtxList]
, UsrChars [userCharacteristicsIntro]
, SystCons [] []],
SSDSec $
SSDProg
[ SSDProblem $ PDProg purp []
[ TermsAndDefs Nothing terms
, PhySysDesc projectileTitle physSystParts figLaunch []
, Goals [(phrase iVel +:+ S "vector") `S.the_ofThe` phrase projectile,
S "geometric layout" `S.the_ofThe` phrase launcher `S.and_` phrase target]]
, SSDSolChSpec $ SCSProg
[ Assumptions
, TMs [] (Label : stdFields)
, GDs [] ([Label, Units] ++ stdFields) ShowDerivation
, DDs [] ([Label, Symbol, Units] ++ stdFields) ShowDerivation
, IMs [] ([Label, Input, Output, InConstraints, OutConstraints] ++ stdFields) ShowDerivation
, Constraints EmptyS inConstraints
, CorrSolnPpties outConstraints []
]
],
ReqrmntSec $
ReqsProg
[ FReqsSub EmptyS []
, NonFReqsSub
],
TraceabilitySec $ TraceabilityProg $ traceMatStandard si,
AuxConstntSec $
AuxConsProg projectileTitle constants,
Bibliography
]
justification, scope :: Sentence
justification = foldlSent [atStart projectile, phrase motion, S "is a common" +:+.
phraseNP (problem `in_` physics), S "Therefore, it is useful to have a",
phrase program, S "to solve and model these types of" +:+. plural problem,
S "Common", plural example `S.of_` phraseNP (combineNINI projectile motion),
S "include" +:+. foldlList Comma List projectileExamples,
atStartNP (the program), S "documented here is called", phrase projectileTitle]
scope = foldlSent_ [phraseNP (NP.the (analysis `ofA` twoD)),
sParen (getAcc twoD), phraseNP (combineNINI projectile motion), phrase problem,
S "with", phrase constAccel]
projectileExamples :: [Sentence]
projectileExamples = [S "ballistics" +:+ plural problem +:+ sParen (S "missiles" `sC`
S "bullets" `sC` S "etc."), S "the flight" `S.of_` S "balls" `S.in_`
S "various sports" +:+ sParen (S "baseball" `sC` S "golf" `sC` S "football" `sC`
S "etc.")]
projectileTitle :: CI
projectileTitle = commonIdea "projectileTitle" (pn "Projectile") "Projectile" []
si :: SystemInformation
si = SI {
_sys = projectileTitle,
_kind = Doc.srs,
_authors = [samCrawford, brooks, spencerSmith],
_purpose = [purp],
_background = [],
_quants = symbols,
_concepts = [] :: [DefinedQuantityDict],
_instModels = iMods,
_datadefs = dataDefs,
_configFiles = [],
_inputs = inputs,
_outputs = outputs,
_defSequence = [] :: [Block SimpleQDef],
_constraints = map cnstrw constrained,
_constants = constants,
_sysinfodb = symbMap,
_usedinfodb = usedDB,
refdb = refDB
}
purp :: Sentence
purp = foldlSent_ [S "predict whether a launched", phrase projectile, S "hits its", phrase target]
tMods :: [TheoryModel]
tMods = [accelerationTM, velocityTM]
symbMap :: ChunkDB
symbMap = cdb (qw pi_ : map qw physicscon ++ unitalQuants ++ symbols)
(nw projectileTitle : nw mass : nw inValue : [nw errMsg, nw program] ++
map nw doccon ++ map nw doccon' ++ map nw physicCon ++ map nw physicCon' ++
map nw physicscon ++ map nw mathcon ++ [nw algorithm] ++ concepts ++
[nw sciCompS] ++ unitalIdeas ++ map nw acronyms ++ map nw symbols ++
map nw educon ++ map nw [metre, radian, second] ++ map nw compcon)
(cw pi_ : map cw constrained ++ srsDomains) (map unitWrapper [metre, radian, second])
dataDefs iMods genDefns tMods concIns [] [] []
usedDB :: ChunkDB
usedDB = cdb ([] :: [QuantityDict]) (nw pi_ : map nw acronyms ++ map nw symbols)
(cw pi_ : srsDomains) ([] :: [UnitDefn]) [] [] [] [] [] [] [] ([] :: [Reference])
stdFields :: Fields
stdFields = [DefiningEquation, Description Verbose IncludeUnits, Notes, Source, RefBy]
refDB :: ReferenceDB
refDB = rdb citations concIns
concIns :: [ConceptInstance]
concIns = assumptions ++ funcReqs ++ goals ++ nonfuncReqs
----------------------------------------
-- Characteristics of Intended Reader --
----------------------------------------
charsOfReader :: [Sentence]
charsOfReader = [phrase undergraduate +:+ S "level 1" +:+ phrase Doc.physics,
phrase undergraduate +:+ S "level 1" +:+ phrase calculus]
-----------------
--SystemContext--
-----------------
sysCtxIntro :: Contents
sysCtxIntro = foldlSP
[refS sysCtxFig1, S "shows the" +:+. phrase sysCont,
S "A circle represents an entity external" `S.toThe` phrase software
`sC` phraseNP (the user), S "in this case. A rectangle represents the",
phrase softwareSys, S "itself" +:+. sParen (short projectileTitle),
S "Arrows are used to show the data flow between the", phraseNP (system
`andIts` environment)]
sysCtxDesc :: Contents
sysCtxDesc = foldlSPCol [S "The interaction between the", phraseNP (product_
`andThe` user), S "is through an application programming" +:+.
phrase interface, S "responsibilities" `S.the_ofTheC` phraseNP (user
`andThe` system), S "are as follows"]
sysCtxUsrResp :: [Sentence]
sysCtxUsrResp = map foldlSent [[S "Provide initial", pluralNP (condition `ofThePS`
physical), S "state" `S.ofThe` phrase motion `S.andThe` plural inDatum, S "related" `S.toThe`
phrase projectileTitle `sC` S "ensuring no errors" `S.inThe` plural datum, S "entry"],
[S "Ensure that consistent units are used for", pluralNP (combineNINI input_ Doc.variable)],
[S "Ensure required", namedRef (SRS.assumpt ([]::[Contents]) ([]::[Section]))
(phrase software +:+ plural assumption), S "are appropriate for any particular",
phrase problem, phrase input_ `S.toThe` phrase software]]
sysCtxSysResp :: [Sentence]
sysCtxSysResp = map foldlSent [[S "Detect data type mismatch, such as a string of characters",
phrase input_, S "instead of a floating point number"],
[S "Determine if the", plural input_, S "satisfy the required",
pluralNP (physical `and_` softwareConstraint)],
[S "Calculate the required", plural output_]]
sysCtxResp :: [Sentence]
sysCtxResp = map (\x -> x +:+ S "Responsibilities")
[titleize user, short projectileTitle]
sysCtxList :: Contents
sysCtxList = UlC $ ulcc $ Enumeration $ bulletNested sysCtxResp $
map bulletFlat [sysCtxUsrResp, sysCtxSysResp]
-------------------------
--User Characteristics --
-------------------------
userCharacteristicsIntro :: Contents
userCharacteristicsIntro = foldlSP
[S "The", phrase endUser `S.of_` short projectileTitle,
S "should have an understanding of",
phrase highSchoolPhysics `S.and_` phrase highSchoolCalculus]
-------------------------
-- Problem Description --
-------------------------
-- The text for the problem description is the same as that of the purpose of
-- this example.
---------------------------------
-- Terminology and Definitions --
---------------------------------
terms :: [ConceptChunk]
terms = [launcher, projectile, target, gravity, cartesian, rectilinear]
---------------------------------
-- Physical System Description --
---------------------------------
physSystParts :: [Sentence]
physSystParts = map (!.)
[atStartNP (the launcher),
atStartNP (the projectile) +:+ sParen (S "with" +:+ getTandS iVel `S.and_` getTandS launAngle),
atStartNP (the target)]
----------------------------------------------------
-- Various gathered data that should be automated --
----------------------------------------------------
symbols :: [QuantityDict]
symbols = qw gravitationalAccelConst : unitalQuants ++ map qw constants ++
map qw [acceleration, constAccel, iPos, iSpeed, iVel, ixPos,
iyPos, ixVel, iyVel, position, scalarPos, projPos, projSpeed, time, velocity, xAccel,
xConstAccel, xPos, xVel, yAccel, yConstAccel, yPos, yVel]
constants :: [ConstQDef]
constants = [gravitationalAccelConst, piConst, tol]
inputs :: [QuantityDict]
inputs = map qw [launSpeed, launAngle, targPos]
outputs :: [QuantityDict]
outputs = [message, qw offset, qw flightDur]
unitalQuants :: [QuantityDict]
unitalQuants = message : map qw constrained
unitalIdeas :: [IdeaDict]
unitalIdeas = nw message : map nw constrained
inConstraints :: [UncertQ]
inConstraints = [launAngleUnc, launSpeedUnc, targPosUnc]
outConstraints :: [UncertQ]
outConstraints = [landPosUnc, offsetUnc, flightDurUnc]
constrained :: [ConstrConcept]
constrained = [flightDur, landPos, launAngle, launSpeed, offset, targPos]
acronyms :: [CI]
acronyms = [oneD, twoD, assumption, dataDefn, genDefn, goalStmt, inModel,
physSyst, requirement, Doc.srs, refBy, refName, thModel, typUnc]