module Drasil.SWHSNoPCM.Requirements (funcReqs, inputInitValsTable) where

import Control.Lens ((^.))

import Language.Drasil
import Drasil.DocLang (mkInputPropsTable)
import Language.Drasil.Chunk.Concept.NamedCombinators
import Theory.Drasil (InstanceModel)

import Data.Drasil.Concepts.Documentation (funcReqDom, input_, value)
import Data.Drasil.Quantities.PhysicalProperties (mass)

import Drasil.SWHS.DataDefs (waterMass, tankVolume, balanceDecayRate)
import Drasil.SWHS.IMods (heatEInWtr)
import Drasil.SWHS.Requirements (calcValues, checkWithPhysConsts,
  findMassConstruct, inReqDesc, oIDQConstruct, outputValues)

import Drasil.SWHSNoPCM.DataDefs (waterVolume)
import Drasil.SWHSNoPCM.IMods (eBalanceOnWtr)
import Drasil.SWHSNoPCM.Unitals (inputs)

--------------------------
--Section 5 : REQUIREMENTS
--------------------------

---------------------------------------
--Section 5.1 : FUNCTIONAL REQUIREMENTS
---------------------------------------

--
inputInitVals :: ConceptInstance
inputInitVals :: ConceptInstance
inputInitVals = String -> Sentence -> String -> ConceptChunk -> ConceptInstance
forall c.
Concept c =>
String -> Sentence -> String -> c -> ConceptInstance
cic String
"inputInitVals" ([Sentence] -> Sentence
foldlSent [
  IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
titleize IdeaDict
input_, String -> Sentence
S String
"the following", IdeaDict -> Sentence
forall n. NamedIdea n => n -> Sentence
plural IdeaDict
value, String -> Sentence
S String
"described in the table for",
  LabelledContent -> Sentence -> Sentence
forall r.
(HasUID r, HasRefAddress r, HasShortName r) =>
r -> Sentence -> Sentence
namedRef LabelledContent
inputInitValsTable (String -> Sentence
S String
"Required Inputs") Sentence -> Sentence -> Sentence
`sC` String -> Sentence
S String
"which define", Sentence
inReqDesc])
  String
"Input-Initial-Values" ConceptChunk
funcReqDom

--
findMass :: ConceptInstance
findMass :: ConceptInstance
findMass = ConceptInstance
-> Sentence
-> [InstanceModel]
-> [DataDefinition]
-> ConceptInstance
forall r s t.
(Referable r, HasShortName r, Referable s, HasShortName s,
 Referable t, HasShortName t) =>
r -> Sentence -> [s] -> [t] -> ConceptInstance
findMassConstruct ConceptInstance
inputInitVals (UnitalChunk -> Sentence
forall n. NamedIdea n => n -> Sentence
phrase UnitalChunk
mass) [InstanceModel
eBalanceOnWtr]
            [DataDefinition
waterMass, DataDefinition
waterVolume, DataDefinition
tankVolume]

--
oIDQVals :: [Sentence]
oIDQVals :: [Sentence]
oIDQVals = ([Sentence] -> Sentence) -> [[Sentence]] -> [Sentence]
forall a b. (a -> b) -> [a] -> [b]
map [Sentence] -> Sentence
foldlSent_ [
  [NP -> Sentence
forall n. NounPhrase n => n -> Sentence
pluralNP (IdeaDict -> NP
forall t. NamedIdea t => t -> NP
the IdeaDict
value), ConceptInstance -> Sentence
forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
inputInitVals],
  [NP -> Sentence
forall n. NounPhrase n => n -> Sentence
phraseNP (UnitalChunk -> NP
forall t. NamedIdea t => t -> NP
the UnitalChunk
mass), ConceptInstance -> Sentence
forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource ConceptInstance
findMass],
  [QuantityDict -> Sentence
forall c. (HasUID c, HasSymbol c) => c -> Sentence
ch (DataDefinition
balanceDecayRate DataDefinition
-> Getting QuantityDict DataDefinition QuantityDict -> QuantityDict
forall s a. s -> Getting a s a -> a
^. Getting QuantityDict DataDefinition QuantityDict
forall d. DefinesQuantity d => Getter d QuantityDict
Getter DataDefinition QuantityDict
defLhs), DataDefinition -> Sentence
forall r. (Referable r, HasShortName r) => r -> Sentence
fromSource DataDefinition
balanceDecayRate]
  ]

inputInitValsTable :: LabelledContent
inputInitValsTable :: LabelledContent
inputInitValsTable = [QuantityDict] -> ConceptInstance -> LabelledContent
forall i r.
(Quantity i, MayHaveUnit i, HasShortName r, Referable r) =>
[i] -> r -> LabelledContent
mkInputPropsTable [QuantityDict]
inputs ConceptInstance
inputInitVals

funcReqs :: [ConceptInstance]
funcReqs :: [ConceptInstance]
funcReqs = [ConceptInstance
inputInitVals, ConceptInstance
findMass, ConceptInstance
checkWithPhysConsts,
  [Sentence] -> ConceptInstance
oIDQConstruct [Sentence]
oIDQVals, [InstanceModel] -> ConceptInstance
calcValues [InstanceModel]
noPCMOutputs, [InstanceModel] -> ConceptInstance
outputValues [InstanceModel]
noPCMOutputs]

noPCMOutputs :: [InstanceModel]
noPCMOutputs :: [InstanceModel]
noPCMOutputs = [InstanceModel
eBalanceOnWtr, InstanceModel
heatEInWtr]

-------------------------------------------
--Section 5.2 : NON-FUNCTIONAL REQUIREMENTS
-------------------------------------------

--imports from SWHS