module Drasil.GlassBR.Requirements (funcReqs, funcReqsTables, inReqDesc, nonfuncReqs) where
import Control.Lens ((^.))
import Language.Drasil
import Drasil.DocLang (inReq, mkQRTuple, mkQRTupleRef, mkValsSourceTable)
import Drasil.DocLang.SRS (datCon, propCorSol)
import Theory.Drasil (DataDefinition)
import Language.Drasil.Chunk.Concept.NamedCombinators
import qualified Language.Drasil.NounPhrase.Combinators as NP
import qualified Language.Drasil.Sentence.Combinators as S
import Data.Drasil.Concepts.Computation (inValue)
import Data.Drasil.Concepts.Documentation (assumption, characteristic, code,
condition, datumConstraint, environment, funcReqDom, likelyChg, message, mg,
mis, module_, nonFuncReqDom, output_, property, requirement, srs, system,
traceyMatrix, type_, unlikelyChg, value, vavPlan)
import Data.Drasil.Concepts.Math (calculation)
import Data.Drasil.Concepts.PhysicalProperties (dimension)
import Data.Drasil.Concepts.Software (errMsg)
import Data.Drasil.TheoryConcepts (dataDefn, genDefn, inModel, thModel)
import Drasil.GlassBR.Assumptions (assumpSV, assumpGL, assumptionConstants)
import Drasil.GlassBR.Concepts (glass)
import Drasil.GlassBR.DataDefs (aspRat, dimLL, glaTyFac, hFromt, loadDF, nonFL,
risk, standOffDis, strDisFac, tolPre, tolStrDisFac)
import Drasil.GlassBR.IMods (iMods)
import Drasil.GlassBR.TMods (lrIsSafe, pbIsSafe)
import Drasil.GlassBR.Unitals (blast, isSafeLR, isSafePb, loadSF, notSafe,
pbTolfail, safeMessage)
funcReqs :: [ConceptInstance]
funcReqs :: [ConceptInstance]
funcReqs = [ConceptInstance
sysSetValsFollowingAssumps, ConceptInstance
checkInputWithDataCons,
ConceptInstance
outputValsAndKnownValues, ConceptInstance
checkGlassSafety, ConceptInstance
outputValues]
funcReqsTables :: [LabelledContent]
funcReqsTables :: [LabelledContent]
funcReqsTables = [LabelledContent
sysSetValsFollowingAssumpsTable, LabelledContent
outputValuesTable]
sysSetValsFollowingAssumps, checkInputWithDataCons,
outputValsAndKnownValues, checkGlassSafety, outputValues :: ConceptInstance
sysSetValsFollowingAssumps :: ConceptInstance
sysSetValsFollowingAssumps = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "sysSetValsFollowingAssumps" Sentence
sysSetValsFollowingAssumpsDesc "System-Set-Values-Following-Assumptions" ConceptChunk
funcReqDom
checkInputWithDataCons :: ConceptInstance
checkInputWithDataCons = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "checkInputWithDataCons" Sentence
checkInputWithDataConsDesc "Check-Input-with-Data_Constraints" ConceptChunk
funcReqDom
outputValsAndKnownValues :: ConceptInstance
outputValsAndKnownValues = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "outputValsAndKnownValues" Sentence
outputValsAndKnownValuesDesc "Output-Values-and-Known-Values" ConceptChunk
funcReqDom
checkGlassSafety :: ConceptInstance
checkGlassSafety = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "checkGlassSafety" Sentence
checkGlassSafetyDesc "Check-Glass-Safety" ConceptChunk
funcReqDom
outputValues :: ConceptInstance
outputValues = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "outputValues" Sentence
outputValuesDesc "Output-Values" ConceptChunk
funcReqDom
inReqDesc, sysSetValsFollowingAssumpsDesc, checkInputWithDataConsDesc, outputValsAndKnownValuesDesc, checkGlassSafetyDesc :: Sentence
inReqDesc :: Sentence
inReqDesc = SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List [NP -> Sentence
forall n. NounPhrase n => n -> Sentence
pluralNP (NP -> NP
NP.the (NamedChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
combineNINI NamedChunk
glass ConceptChunk
dimension)),
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
phraseNP (NamedChunk
type_ NamedChunk -> NamedChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`of_` NamedChunk
glass), ConstrainedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase ConstrainedChunk
pbTolfail, NP -> Sentence
forall n. NounPhrase n => n -> Sentence
pluralNP (NamedChunk
characteristic NamedChunk -> ConceptChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`the_ofThePS` ConceptChunk
blast)]
sysSetValsFollowingAssumpsDesc :: Sentence
sysSetValsFollowingAssumpsDesc = [Sentence] -> Sentence
foldlSent [NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
system), String -> Sentence
S "shall set the known",
NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
value, String -> Sentence
S "as described in the table for", LabelledContent -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef LabelledContent
sysSetValsFollowingAssumpsTable (String -> Sentence
S "Required Assignments")]
sysSetValsFollowingAssumpsTable :: LabelledContent
sysSetValsFollowingAssumpsTable :: LabelledContent
sysSetValsFollowingAssumpsTable = [(QuantityDict, Sentence)] -> String -> Sentence -> LabelledContent
forall i.
(Quantity i, MayHaveUnit i) =>
[(i, Sentence)] -> String -> Sentence -> LabelledContent
mkValsSourceTable ([QuantityDict] -> [ConceptInstance] -> [(QuantityDict, Sentence)]
forall i r.
(Quantity i, MayHaveUnit i, HasShortName r, Referable r) =>
[i] -> [r] -> [(QuantityDict, Sentence)]
mkQRTupleRef [QuantityDict]
r2AQs [ConceptInstance]
r2ARs [(QuantityDict, Sentence)]
-> [(QuantityDict, Sentence)] -> [(QuantityDict, Sentence)]
forall a. [a] -> [a] -> [a]
++ [DataDefinition] -> [(QuantityDict, Sentence)]
forall i.
(Quantity i, MayHaveUnit i, HasShortName i, Referable i) =>
[i] -> [(QuantityDict, Sentence)]
mkQRTuple [DataDefinition]
r2DDs) "ReqAssignments"
(String -> Sentence
S "Required Assignments" Sentence -> ConceptInstance -> Sentence
forall r.
(Referable r, HasShortName r) =>
Sentence -> r -> Sentence
`follows` ConceptInstance
sysSetValsFollowingAssumps)
where
r2AQs :: [QuantityDict]
r2AQs = DefinedQuantityDict -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw DefinedQuantityDict
loadSF QuantityDict -> [QuantityDict] -> [QuantityDict]
forall a. a -> [a] -> [a]
: (ConstQDef -> QuantityDict) -> [ConstQDef] -> [QuantityDict]
forall a b. (a -> b) -> [a] -> [b]
map ConstQDef -> QuantityDict
forall q. (Quantity q, MayHaveUnit q) => q -> QuantityDict
qw (Int -> [ConstQDef] -> [ConstQDef]
forall a. Int -> [a] -> [a]
take 4 [ConstQDef]
assumptionConstants)
r2ARs :: [ConceptInstance]
r2ARs = ConceptInstance
assumpGL ConceptInstance -> [ConceptInstance] -> [ConceptInstance]
forall a. a -> [a] -> [a]
: Int -> ConceptInstance -> [ConceptInstance]
forall a. Int -> a -> [a]
replicate 4 ConceptInstance
assumpSV
r2DDs :: [DataDefinition]
r2DDs = [DataDefinition
loadDF, DataDefinition
hFromt, DataDefinition
glaTyFac, DataDefinition
standOffDis, DataDefinition
aspRat]
checkInputWithDataConsDesc :: Sentence
checkInputWithDataConsDesc = [Sentence] -> Sentence
foldlSent [NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
system), String -> Sentence
S "shall check the entered",
NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
inValue, String -> Sentence
S "to ensure that they do not exceed the" Sentence -> Sentence -> Sentence
+:+. Section -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef ([Contents] -> [Section] -> Section
datCon [] []) (NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
datumConstraint),
String -> Sentence
S "If any" Sentence -> Sentence -> Sentence
`S.ofThe` NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
inValue, String -> Sentence
S "are out" Sentence -> Sentence -> Sentence
`S.of_` String -> Sentence
S "bounds" Sentence -> Sentence -> Sentence
`sC`
String -> Sentence
S "an", ConceptChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase ConceptChunk
errMsg, String -> Sentence
S "is displayed" Sentence -> Sentence -> Sentence
`S.andThe` ConceptChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural ConceptChunk
calculation, String -> Sentence
S "stop"]
outputValsAndKnownValuesDesc :: Sentence
outputValsAndKnownValuesDesc = [Sentence] -> Sentence
foldlSent [NamedChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize NamedChunk
output_, NP -> Sentence
forall n. NounPhrase n => n -> Sentence
pluralNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
inValue),
String -> Sentence
S "from", ConceptInstance -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS (Sentence -> ConceptInstance
inReq Sentence
EmptyS) Sentence -> Sentence -> Sentence
`S.andThe` String -> Sentence
S "known", NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
value,
String -> Sentence
S "from", ConceptInstance -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS ConceptInstance
sysSetValsFollowingAssumps]
checkGlassSafetyDesc :: Sentence
checkGlassSafetyDesc = [Sentence] -> Sentence
foldlSent_ [String -> Sentence
S "If", ModelExpr -> Sentence
eS (ModelExpr -> Sentence) -> ModelExpr -> Sentence
forall a b. (a -> b) -> a -> b
$ QuantityDict -> ModelExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
isSafePb ModelExpr -> ModelExpr -> ModelExpr
forall r. ExprC r => r -> r -> r
$&& QuantityDict -> ModelExpr
forall r c. (ExprC r, HasUID c, HasSymbol c) => c -> r
sy QuantityDict
isSafeLR,
Sentence -> Sentence
sParen (String -> Sentence
S "from" Sentence -> Sentence -> Sentence
+:+ TheoryModel -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS TheoryModel
pbIsSafe Sentence -> Sentence -> Sentence
`S.and_` TheoryModel -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS TheoryModel
lrIsSafe) Sentence -> Sentence -> Sentence
`sC`
NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase NamedChunk
output_, NP -> Sentence
forall n. NounPhrase n => n -> Sentence
phraseNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
message), Sentence -> Sentence
Quote (ConceptChunk
safeMessage ConceptChunk -> Getting Sentence ConceptChunk Sentence -> Sentence
forall s a. s -> Getting a s a -> a
^. Getting Sentence ConceptChunk Sentence
forall c. Definition c => Lens' c Sentence
defn),
String -> Sentence
S "If the", NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase NamedChunk
condition, String -> Sentence
S "is false, then", NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase NamedChunk
output_,
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
phraseNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
message), Sentence -> Sentence
Quote (ConceptChunk
notSafe ConceptChunk -> Getting Sentence ConceptChunk Sentence -> Sentence
forall s a. s -> Getting a s a -> a
^. Getting Sentence ConceptChunk Sentence
forall c. Definition c => Lens' c Sentence
defn)]
outputValuesDesc :: Sentence
outputValuesDesc :: Sentence
outputValuesDesc = [Sentence] -> Sentence
foldlSent [NamedChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize NamedChunk
output_, NP -> Sentence
forall n. NounPhrase n => n -> Sentence
pluralNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
value), String -> Sentence
S "from the table for", LabelledContent -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef LabelledContent
outputValuesTable (String -> Sentence
S "Required Outputs")]
outputValuesTable :: LabelledContent
outputValuesTable :: LabelledContent
outputValuesTable = [(QuantityDict, Sentence)] -> String -> Sentence -> LabelledContent
forall i.
(Quantity i, MayHaveUnit i) =>
[(i, Sentence)] -> String -> Sentence -> LabelledContent
mkValsSourceTable ([InstanceModel] -> [(QuantityDict, Sentence)]
forall i.
(Quantity i, MayHaveUnit i, HasShortName i, Referable i) =>
[i] -> [(QuantityDict, Sentence)]
mkQRTuple [InstanceModel]
iMods [(QuantityDict, Sentence)]
-> [(QuantityDict, Sentence)] -> [(QuantityDict, Sentence)]
forall a. [a] -> [a] -> [a]
++ [DataDefinition] -> [(QuantityDict, Sentence)]
forall i.
(Quantity i, MayHaveUnit i, HasShortName i, Referable i) =>
[i] -> [(QuantityDict, Sentence)]
mkQRTuple [DataDefinition]
r6DDs) "ReqOutputs"
(String -> Sentence
S "Required" Sentence -> Sentence -> Sentence
+:+ NamedChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize' NamedChunk
output_ Sentence -> ConceptInstance -> Sentence
forall r.
(Referable r, HasShortName r) =>
Sentence -> r -> Sentence
`follows` ConceptInstance
outputValues)
where
r6DDs :: [DataDefinition]
r6DDs :: [DataDefinition]
r6DDs = [DataDefinition
risk, DataDefinition
strDisFac, DataDefinition
nonFL, DataDefinition
glaTyFac, DataDefinition
dimLL, DataDefinition
tolPre, DataDefinition
tolStrDisFac, DataDefinition
hFromt, DataDefinition
aspRat]
nonfuncReqs :: [ConceptInstance]
nonfuncReqs :: [ConceptInstance]
nonfuncReqs = [ConceptInstance
correct, ConceptInstance
verifiable, ConceptInstance
understandable, ConceptInstance
reusable, ConceptInstance
maintainable, ConceptInstance
portable]
correct :: ConceptInstance
correct :: ConceptInstance
correct = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "correct" ([Sentence] -> Sentence
foldlSent [
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP' (NamedChunk
output_ NamedChunk -> NamedChunk -> NP
forall c d. (NamedIdea c, NamedIdea d) => c -> d -> NP
`the_ofThePS` NamedChunk
code), String -> Sentence
S "have the",
NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
property, String -> Sentence
S "described in", Section -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence
refS ([Contents] -> [Section] -> Section
propCorSol [] [])
]) "Correct" ConceptChunk
nonFuncReqDom
verifiable :: ConceptInstance
verifiable :: ConceptInstance
verifiable = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "verifiable" ([Sentence] -> Sentence
foldlSent [
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
code), String -> Sentence
S "is tested with complete",
NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase NamedChunk
vavPlan]) "Verifiable" ConceptChunk
nonFuncReqDom
understandable :: ConceptInstance
understandable :: ConceptInstance
understandable = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "understandable" ([Sentence] -> Sentence
foldlSent [
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
code), String -> Sentence
S "is modularized with complete",
CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase CI
mg Sentence -> Sentence -> Sentence
`S.and_` CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase CI
mis]) "Understandable" ConceptChunk
nonFuncReqDom
reusable :: ConceptInstance
reusable :: ConceptInstance
reusable = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "reusable" ([Sentence] -> Sentence
foldlSent [
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
code), String -> Sentence
S "is modularized"]) "Reusable" ConceptChunk
nonFuncReqDom
maintainable :: ConceptInstance
maintainable :: ConceptInstance
maintainable = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "maintainable" ([Sentence] -> Sentence
foldlSent [
String -> Sentence
S "The traceability between", SepType -> FoldType -> [Sentence] -> Sentence
foldlList SepType
Comma FoldType
List [CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
requirement,
CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
assumption, CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
thModel, CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
genDefn, CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
dataDefn, CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
inModel,
CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
likelyChg, CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural CI
unlikelyChg, NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
module_], String -> Sentence
S "is completely recorded in",
NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
traceyMatrix Sentence -> Sentence -> Sentence
`S.inThe` CI -> Sentence
getAcc CI
srs Sentence -> Sentence -> Sentence
`S.and_` CI -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
phrase CI
mg]) "Maintainable" ConceptChunk
nonFuncReqDom
portable :: ConceptInstance
portable :: ConceptInstance
portable = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic "portable" ([Sentence] -> Sentence
foldlSent [
NP -> Sentence
forall n. NounPhrase n => n -> Sentence
atStartNP (NamedChunk -> NP
forall t. NamedIdea t => t -> NP
the NamedChunk
code), String -> Sentence
S "is able to be run in different", NamedChunk -> Sentence
forall n. (HasUID n, NamedIdea n) => n -> Sentence
plural NamedChunk
environment])
"Portable" ConceptChunk
nonFuncReqDom