module Simulation.Aivika.Experiment.ExperimentSpecsWriter
(ExperimentSpecsWriter(..),
defaultExperimentSpecsWriter) where
import Simulation.Aivika
import Simulation.Aivika.Experiment.Types
import Simulation.Aivika.Experiment.HtmlWriter
data ExperimentSpecsWriter =
ExperimentSpecsWriter { experimentSpecsWidth :: Int,
experimentSpecsNameText :: String,
experimentSpecsStartTimeText :: String,
experimentSpecsStopTimeText :: String,
experimentSpecsDTText :: String,
experimentSpecsRunCountText :: String,
experimentSpecsIntegMethodText :: String,
experimentSpecsEulerText :: String,
experimentSpecsRungeKutta2Text :: String,
experimentSpecsRungeKutta4Text :: String,
experimentSpecsFormatter :: ShowS,
experimentSpecsWrite :: ExperimentSpecsWriter
-> Experiment
-> HtmlWriter ()
}
defaultExperimentSpecsWriter :: ExperimentSpecsWriter
defaultExperimentSpecsWriter =
ExperimentSpecsWriter {
experimentSpecsWidth = 400,
experimentSpecsNameText = "Experiment Specs",
experimentSpecsStartTimeText = "start time",
experimentSpecsStopTimeText = "stop time",
experimentSpecsDTText = "time step",
experimentSpecsRunCountText = "run count",
experimentSpecsIntegMethodText = "integration method",
experimentSpecsEulerText = "Euler's",
experimentSpecsRungeKutta2Text = "the 2-nd order Runge-Kutta",
experimentSpecsRungeKutta4Text = "the 4-th order Runge-Kutta",
experimentSpecsFormatter = id,
experimentSpecsWrite = \writer exp ->
do let format x = experimentSpecsFormatter writer x
writeHtml "<p>"
writeHtml "<table frame='border' cellspacing='4' width='"
writeHtml $ show $ experimentSpecsWidth writer
writeHtml "'>"
writeHtml "<tr>"
writeHtml "<td colspan='2'>"
writeHtml "<p align='center'>"
writeHtmlText $ experimentSpecsNameText writer
writeHtml "</p>"
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ experimentSpecsStartTimeText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ spcStartTime $ experimentSpecs exp
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ experimentSpecsStopTimeText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ spcStopTime $ experimentSpecs exp
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ experimentSpecsDTText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ spcDT $ experimentSpecs exp
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ experimentSpecsRunCountText writer
writeHtml "</td>"
writeHtml "<td>"
writeHtmlText $ format $ show $ experimentRunCount exp
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "<tr>"
writeHtml "<td>"
writeHtmlText $ experimentSpecsIntegMethodText writer
writeHtml "</td>"
writeHtml "<td>"
let method = spcMethod $ experimentSpecs exp
writeHtml $ methodName method writer
writeHtml "</td>"
writeHtml "</tr>"
writeHtml "</table>"
writeHtml "</p>"
}
methodName :: Method -> ExperimentSpecsWriter -> String
methodName Euler = experimentSpecsEulerText
methodName RungeKutta2 = experimentSpecsRungeKutta2Text
methodName RungeKutta4 = experimentSpecsRungeKutta4Text