{-#LANGUAGE PostfixOperators#-}
module Drasil.PDController.Requirements where

import Data.Drasil.Concepts.Documentation (funcReqDom, nonFuncReqDom, datumConstraint)
import Drasil.DocLang.SRS (datCon)
import Drasil.DocLang (mkMaintainableNFR)

import Drasil.PDController.Concepts
import Drasil.PDController.IModel

import Language.Drasil

funcReqs :: [ConceptInstance]
funcReqs :: [ConceptInstance]
funcReqs = [ConceptInstance
verifyInputs, ConceptInstance
calculateValues, ConceptInstance
outputValues]

verifyInputs, calculateValues, outputValues :: ConceptInstance
verifyInputs :: ConceptInstance
verifyInputs
  = forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"verifyInputs" Sentence
verifyInputsDesc String
"Verify-Input-Values" ConceptChunk
funcReqDom
calculateValues :: ConceptInstance
calculateValues
  = forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"calculateValues" Sentence
calculateValuesDesc String
"Calculate-Values" ConceptChunk
funcReqDom
outputValues :: ConceptInstance
outputValues = forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"outputValues" Sentence
outputValuesDesc String
"Output-Values" ConceptChunk
funcReqDom

verifyInputsDesc, calculateValuesDesc, outputValuesDesc :: Sentence

verifyInputsDesc :: Sentence
verifyInputsDesc
  = [Sentence] -> Sentence
foldlSent_
      [String -> Sentence
S String
"Ensure that the input values are within the",
         String -> Sentence
S String
"limits specified in the"
         Sentence -> Sentence -> Sentence
+:+. forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef ([Contents] -> [Section] -> Section
datCon [] []) (forall n. NamedIdea n => n -> Sentence
plural IdeaDict
datumConstraint)]

calculateValuesDesc :: Sentence
calculateValuesDesc
  = [Sentence] -> Sentence
foldlSent
      [String -> Sentence
S String
"Calculate the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
processVariable, forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource InstanceModel
imPD,
         String -> Sentence
S String
"over the simulation time"]

outputValuesDesc :: Sentence
outputValuesDesc
  = [Sentence] -> Sentence
foldlSent
      [String -> Sentence
S String
"Output the", forall n. NamedIdea n => n -> Sentence
phrase ConceptChunk
processVariable, forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource InstanceModel
imPD,
         String -> Sentence
S String
"over the simulation time"]

-----------------------------------------------------------------------------

nonfuncReqs :: [ConceptInstance]
nonfuncReqs :: [ConceptInstance]
nonfuncReqs = [ConceptInstance
portability, ConceptInstance
security, ConceptInstance
maintainability, ConceptInstance
verifiability]

portability :: ConceptInstance
portability :: ConceptInstance
portability
  = forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"portability"
      (String -> Sentence
S String
"The code shall be portable to multiple Operating Systems" !.)
      String
"Portable"
      ConceptChunk
nonFuncReqDom

security :: ConceptInstance
security :: ConceptInstance
security
  = forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"security"
      ([Sentence] -> Sentence
foldlSent
         [String -> Sentence
S String
"The code shall be immune to common security problems such as memory",
            String -> Sentence
S String
"leaks, divide by zero errors, and the square root of negative numbers"])
      String
"Secure"
      ConceptChunk
nonFuncReqDom

maintainability :: ConceptInstance
maintainability :: ConceptInstance
maintainability = String -> Integer -> String -> ConceptInstance
mkMaintainableNFR String
"maintainability" Integer
10 String
"Maintainable"

verifiability :: ConceptInstance
verifiability :: ConceptInstance
verifiability
  = forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"verifiability"
      (String -> Sentence
S String
"The code shall be verifiable against a Verification and Validation plan" !.)
      String
"Verifiable"
      ConceptChunk
nonFuncReqDom