{-# LANGUAGE FlexibleInstances, MultiParamTypeClasses #-}

-- |
-- Module     : Simulation.Aivika.Trans.GPSS.Results
-- Copyright  : Copyright (c) 2017, David Sorokin <david.sorokin@gmail.com>
-- License    : BSD3
-- Maintainer : David Sorokin <david.sorokin@gmail.com>
-- Stability  : experimental
-- Tested with: GHC 8.0.2
--
-- The module allows exporting the simulation results from the model.
--
module Simulation.Aivika.Trans.GPSS.Results () where

import Control.Monad
import Control.Monad.Trans

import Simulation.Aivika.Trans

import qualified Simulation.Aivika.Trans.GPSS.Queue as Q
import Simulation.Aivika.Trans.GPSS.Facility
import Simulation.Aivika.Trans.GPSS.Storage
import Simulation.Aivika.Trans.GPSS.Results.Locale
  
-- | Return a source by the specified queue.
queueResultSource :: MonadDES m
                     => ResultContainer (Q.Queue m) m
                     -- ^ the queue container
                     -> ResultSource m
queueResultSource :: forall (m :: * -> *).
MonadDES m =>
ResultContainer (Queue m) m -> ResultSource m
queueResultSource ResultContainer (Queue m) m
c =
  forall (m :: * -> *). ResultObject m -> ResultSource m
ResultObjectSource forall a b. (a -> b) -> a -> b
$
  ResultObject {
    resultObjectName :: ResultName
resultObjectName = forall e (m :: * -> *). ResultContainer e m -> ResultName
resultContainerName ResultContainer (Queue m) m
c,
    resultObjectId :: ResultId
resultObjectId = forall e (m :: * -> *). ResultContainer e m -> ResultId
resultContainerId ResultContainer (Queue m) m
c,
    resultObjectTypeId :: ResultId
resultObjectTypeId = ResultId
queueId,
    resultObjectSignal :: ResultSignal m
resultObjectSignal = forall e (m :: * -> *). ResultContainer e m -> ResultSignal m
resultContainerSignal ResultContainer (Queue m) m
c,
    resultObjectSummary :: ResultSource m
resultObjectSummary = forall (m :: * -> *).
MonadDES m =>
ResultContainer (Queue m) m -> ResultSource m
queueResultSummary ResultContainer (Queue m) m
c,
    resultObjectProperties :: [ResultProperty m]
resultObjectProperties = [
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueNull" ResultId
queueNullId forall (m :: * -> *). MonadDES m => Queue m -> Event m Bool
Q.queueNull forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueNullChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueContent" ResultId
queueContentId forall (m :: * -> *). MonadDES m => Queue m -> Event m Int
Q.queueContent forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueContentStats" ResultId
queueContentStatsId forall (m :: * -> *).
MonadDES m =>
Queue m -> Event m (TimingStats Int)
Q.queueContentStats forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"enqueueCount" ResultId
enqueueCountId forall (m :: * -> *). MonadDES m => Queue m -> Event m Int
Q.enqueueCount forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.enqueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"enqueueZeroEntryCount" ResultId
enqueueZeroEntryCountId forall (m :: * -> *). MonadDES m => Queue m -> Event m Int
Q.enqueueZeroEntryCount forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.enqueueZeroEntryCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueWaitTime" ResultId
queueWaitTimeId forall (m :: * -> *).
MonadDES m =>
Queue m -> Event m (SamplingStats Double)
Q.queueWaitTime forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueNonZeroEntryWaitTime" ResultId
queueNonZeroEntryWaitTimeId forall (m :: * -> *).
MonadDES m =>
Queue m -> Event m (SamplingStats Double)
Q.queueNonZeroEntryWaitTime forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueNonZeroEntryWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueRate" ResultId
queueRateId forall (m :: * -> *). MonadDES m => Queue m -> Event m Double
Q.queueRate forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueRateChanged_ ] }

-- | Return the summary by the specified queue.
queueResultSummary :: MonadDES m =>
                      ResultContainer (Q.Queue m) m
                      -- ^ the queue container
                      -> ResultSource m
queueResultSummary :: forall (m :: * -> *).
MonadDES m =>
ResultContainer (Queue m) m -> ResultSource m
queueResultSummary ResultContainer (Queue m) m
c =
  forall (m :: * -> *). ResultObject m -> ResultSource m
ResultObjectSource forall a b. (a -> b) -> a -> b
$
  ResultObject {
    resultObjectName :: ResultName
resultObjectName = forall e (m :: * -> *). ResultContainer e m -> ResultName
resultContainerName ResultContainer (Queue m) m
c,
    resultObjectId :: ResultId
resultObjectId = forall e (m :: * -> *). ResultContainer e m -> ResultId
resultContainerId ResultContainer (Queue m) m
c,
    resultObjectTypeId :: ResultId
resultObjectTypeId = ResultId
queueId,
    resultObjectSignal :: ResultSignal m
resultObjectSignal = forall e (m :: * -> *). ResultContainer e m -> ResultSignal m
resultContainerSignal ResultContainer (Queue m) m
c,
    resultObjectSummary :: ResultSource m
resultObjectSummary = forall (m :: * -> *).
MonadDES m =>
ResultContainer (Queue m) m -> ResultSource m
queueResultSummary ResultContainer (Queue m) m
c,
    resultObjectProperties :: [ResultProperty m]
resultObjectProperties = [
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueContentStats" ResultId
queueContentStatsId forall (m :: * -> *).
MonadDES m =>
Queue m -> Event m (TimingStats Int)
Q.queueContentStats forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"enqueueCount" ResultId
enqueueCountId forall (m :: * -> *). MonadDES m => Queue m -> Event m Int
Q.enqueueCount forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.enqueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"enqueueZeroEntryCount" ResultId
enqueueZeroEntryCountId forall (m :: * -> *). MonadDES m => Queue m -> Event m Int
Q.enqueueZeroEntryCount forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.enqueueZeroEntryCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueWaitTime" ResultId
queueWaitTimeId forall (m :: * -> *).
MonadDES m =>
Queue m -> Event m (SamplingStats Double)
Q.queueWaitTime forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueNonZeroEntryWaitTime" ResultId
queueNonZeroEntryWaitTimeId forall (m :: * -> *).
MonadDES m =>
Queue m -> Event m (SamplingStats Double)
Q.queueNonZeroEntryWaitTime forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueNonZeroEntryWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Queue m) m
c ResultName
"queueRate" ResultId
queueRateId forall (m :: * -> *). MonadDES m => Queue m -> Event m Double
Q.queueRate forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueRateChanged_ ] }

-- | Return a source by the specified facility.
facilityResultSource :: MonadDES m =>
                        ResultContainer (Facility m a) m
                        -- ^ the facility container
                        -> ResultSource m
facilityResultSource :: forall (m :: * -> *) a.
MonadDES m =>
ResultContainer (Facility m a) m -> ResultSource m
facilityResultSource ResultContainer (Facility m a) m
c =
  forall (m :: * -> *). ResultObject m -> ResultSource m
ResultObjectSource forall a b. (a -> b) -> a -> b
$
  ResultObject {
    resultObjectName :: ResultName
resultObjectName = forall e (m :: * -> *). ResultContainer e m -> ResultName
resultContainerName ResultContainer (Facility m a) m
c,
    resultObjectId :: ResultId
resultObjectId = forall e (m :: * -> *). ResultContainer e m -> ResultId
resultContainerId ResultContainer (Facility m a) m
c,
    resultObjectTypeId :: ResultId
resultObjectTypeId = ResultId
facilityId,
    resultObjectSignal :: ResultSignal m
resultObjectSignal = forall e (m :: * -> *). ResultContainer e m -> ResultSignal m
resultContainerSignal ResultContainer (Facility m a) m
c,
    resultObjectSummary :: ResultSource m
resultObjectSummary = forall (m :: * -> *) a.
MonadDES m =>
ResultContainer (Facility m a) m -> ResultSource m
facilityResultSummary ResultContainer (Facility m a) m
c,
    resultObjectProperties :: [ResultProperty m]
resultObjectProperties = [
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"queueCount" ResultId
facilityQueueCountId forall (m :: * -> *) a. MonadDES m => Facility m a -> Event m Int
facilityQueueCount forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityQueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"queueCountStats" ResultId
facilityQueueCountStatsId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (TimingStats Int)
facilityQueueCountStats forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityQueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"totalWaitTime" ResultId
facilityTotalWaitTimeId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m Double
facilityTotalWaitTime forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"waitTime" ResultId
facilityWaitTimeId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (SamplingStats Double)
facilityWaitTime forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"totalHoldingTime" ResultId
facilityTotalHoldingTimeId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m Double
facilityTotalHoldingTime forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityHoldingTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"holdingTime" ResultId
facilityHoldingTimeId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (SamplingStats Double)
facilityHoldingTime forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityHoldingTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> Event m b) -> ResultProperty m
resultContainerIntegProperty ResultContainer (Facility m a) m
c ResultName
"interrupted" ResultId
facilityInterruptedId forall (m :: * -> *) a. MonadDES m => Facility m a -> Event m Bool
facilityInterrupted,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"count" ResultId
facilityCountId forall (m :: * -> *) a. MonadDES m => Facility m a -> Event m Int
facilityCount forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"countStats" ResultId
facilityCountStatsId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (TimingStats Int)
facilityCountStats forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"captureCount" ResultId
facilityCaptureCountId forall (m :: * -> *) a. MonadDES m => Facility m a -> Event m Int
facilityCaptureCount forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityCaptureCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"utilisationCount" ResultId
facilityUtilisationCountId forall (m :: * -> *) a. MonadDES m => Facility m a -> Event m Int
facilityUtilisationCount forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityUtilisationCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"utilisationCountStats" ResultId
facilityUtilisationCountStatsId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (TimingStats Int)
facilityUtilisationCountStats forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityUtilisationCountChanged_ ] }

-- | Return a summary by the specified facility.
facilityResultSummary :: MonadDES m =>
                         ResultContainer (Facility m a) m
                         -- ^ the facility container
                         -> ResultSource m
facilityResultSummary :: forall (m :: * -> *) a.
MonadDES m =>
ResultContainer (Facility m a) m -> ResultSource m
facilityResultSummary ResultContainer (Facility m a) m
c =
  forall (m :: * -> *). ResultObject m -> ResultSource m
ResultObjectSource forall a b. (a -> b) -> a -> b
$
  ResultObject {
    resultObjectName :: ResultName
resultObjectName = forall e (m :: * -> *). ResultContainer e m -> ResultName
resultContainerName ResultContainer (Facility m a) m
c,
    resultObjectId :: ResultId
resultObjectId = forall e (m :: * -> *). ResultContainer e m -> ResultId
resultContainerId ResultContainer (Facility m a) m
c,
    resultObjectTypeId :: ResultId
resultObjectTypeId = ResultId
facilityId,
    resultObjectSignal :: ResultSignal m
resultObjectSignal = forall e (m :: * -> *). ResultContainer e m -> ResultSignal m
resultContainerSignal ResultContainer (Facility m a) m
c,
    resultObjectSummary :: ResultSource m
resultObjectSummary = forall (m :: * -> *) a.
MonadDES m =>
ResultContainer (Facility m a) m -> ResultSource m
facilityResultSummary ResultContainer (Facility m a) m
c,
    resultObjectProperties :: [ResultProperty m]
resultObjectProperties = [
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"queueCountStats" ResultId
facilityQueueCountStatsId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (TimingStats Int)
facilityQueueCountStats forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityQueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"waitTime" ResultId
facilityWaitTimeId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (SamplingStats Double)
facilityWaitTime forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"holdingTime" ResultId
facilityHoldingTimeId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (SamplingStats Double)
facilityHoldingTime forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityHoldingTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"countStats" ResultId
facilityCountStatsId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (TimingStats Int)
facilityCountStats forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"captureCount" ResultId
facilityCaptureCountId forall (m :: * -> *) a. MonadDES m => Facility m a -> Event m Int
facilityCaptureCount forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityCaptureCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Facility m a) m
c ResultName
"utilisationCountStats" ResultId
facilityUtilisationCountStatsId forall (m :: * -> *) a.
MonadDES m =>
Facility m a -> Event m (TimingStats Int)
facilityUtilisationCountStats forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityUtilisationCountChanged_ ] }

-- | Return a source by the specified storage.
storageResultSource :: MonadDES m
                       => ResultContainer (Storage m) m
                       -- ^ the storage container
                       -> ResultSource m
storageResultSource :: forall (m :: * -> *).
MonadDES m =>
ResultContainer (Storage m) m -> ResultSource m
storageResultSource ResultContainer (Storage m) m
c =
  forall (m :: * -> *). ResultObject m -> ResultSource m
ResultObjectSource forall a b. (a -> b) -> a -> b
$
  ResultObject {
    resultObjectName :: ResultName
resultObjectName = forall e (m :: * -> *). ResultContainer e m -> ResultName
resultContainerName ResultContainer (Storage m) m
c,
    resultObjectId :: ResultId
resultObjectId = forall e (m :: * -> *). ResultContainer e m -> ResultId
resultContainerId ResultContainer (Storage m) m
c,
    resultObjectTypeId :: ResultId
resultObjectTypeId = ResultId
storageId,
    resultObjectSignal :: ResultSignal m
resultObjectSignal = forall e (m :: * -> *). ResultContainer e m -> ResultSignal m
resultContainerSignal ResultContainer (Storage m) m
c,
    resultObjectSummary :: ResultSource m
resultObjectSummary = forall (m :: * -> *).
MonadDES m =>
ResultContainer (Storage m) m -> ResultSource m
storageResultSummary ResultContainer (Storage m) m
c,
    resultObjectProperties :: [ResultProperty m]
resultObjectProperties = [
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> b) -> ResultProperty m
resultContainerConstProperty ResultContainer (Storage m) m
c ResultName
"capacity" ResultId
storageCapacityId forall (m :: * -> *). Storage m -> Int
storageCapacity,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> Event m b) -> ResultProperty m
resultContainerIntegProperty ResultContainer (Storage m) m
c ResultName
"empty" ResultId
storageEmptyId forall (m :: * -> *). MonadDES m => Storage m -> Event m Bool
storageEmpty,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> Event m b) -> ResultProperty m
resultContainerIntegProperty ResultContainer (Storage m) m
c ResultName
"full" ResultId
storageFullId forall (m :: * -> *). MonadDES m => Storage m -> Event m Bool
storageFull,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"queueCount" ResultId
storageQueueCountId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageQueueCount forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageQueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"queueCountStats" ResultId
storageQueueCountStatsId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (TimingStats Int)
storageQueueCountStats forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageQueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"totalWaitTime" ResultId
storageTotalWaitTimeId forall (m :: * -> *). MonadDES m => Storage m -> Event m Double
storageTotalWaitTime forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"waitTime" ResultId
storageWaitTimeId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (SamplingStats Double)
storageWaitTime forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> Event m b) -> ResultProperty m
resultContainerIntegProperty ResultContainer (Storage m) m
c ResultName
"averageHoldingTime" ResultId
storageAverageHoldingTimeId forall (m :: * -> *). MonadDES m => Storage m -> Event m Double
storageAverageHoldingTime,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"content" ResultId
storageContentId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageContent forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"contentStats" ResultId
storageContentStatsId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (TimingStats Int)
storageContentStats forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"useCount" ResultId
storageUseCountId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageUseCount forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUseCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"usedContent" ResultId
storageUsedContentId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageUsedContent forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUsedContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"utilisationCount" ResultId
storageUtilisationCountId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageUtilisationCount forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUtilisationCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"utilisationCountStats" ResultId
storageUtilisationCountStatsId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (TimingStats Int)
storageUtilisationCountStats forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUtilisationCountChanged_ ] }

-- | Return a summary by the specified storage.
storageResultSummary :: MonadDES m
                        => ResultContainer (Storage m) m
                        -- ^ the storage container
                        -> ResultSource m
storageResultSummary :: forall (m :: * -> *).
MonadDES m =>
ResultContainer (Storage m) m -> ResultSource m
storageResultSummary ResultContainer (Storage m) m
c =
  forall (m :: * -> *). ResultObject m -> ResultSource m
ResultObjectSource forall a b. (a -> b) -> a -> b
$
  ResultObject {
    resultObjectName :: ResultName
resultObjectName = forall e (m :: * -> *). ResultContainer e m -> ResultName
resultContainerName ResultContainer (Storage m) m
c,
    resultObjectId :: ResultId
resultObjectId = forall e (m :: * -> *). ResultContainer e m -> ResultId
resultContainerId ResultContainer (Storage m) m
c,
    resultObjectTypeId :: ResultId
resultObjectTypeId = ResultId
storageId,
    resultObjectSignal :: ResultSignal m
resultObjectSignal = forall e (m :: * -> *). ResultContainer e m -> ResultSignal m
resultContainerSignal ResultContainer (Storage m) m
c,
    resultObjectSummary :: ResultSource m
resultObjectSummary = forall (m :: * -> *).
MonadDES m =>
ResultContainer (Storage m) m -> ResultSource m
storageResultSummary ResultContainer (Storage m) m
c,
    resultObjectProperties :: [ResultProperty m]
resultObjectProperties = [
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> b) -> ResultProperty m
resultContainerConstProperty ResultContainer (Storage m) m
c ResultName
"capacity" ResultId
storageCapacityId forall (m :: * -> *). Storage m -> Int
storageCapacity,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"queueCountStats" ResultId
storageQueueCountStatsId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (TimingStats Int)
storageQueueCountStats forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageQueueCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"waitTime" ResultId
storageWaitTimeId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (SamplingStats Double)
storageWaitTime forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageWaitTimeChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName -> ResultId -> (a -> Event m b) -> ResultProperty m
resultContainerIntegProperty ResultContainer (Storage m) m
c ResultName
"averageHoldingTime" ResultId
storageAverageHoldingTimeId forall (m :: * -> *). MonadDES m => Storage m -> Event m Double
storageAverageHoldingTime,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"contentStats" ResultId
storageContentStatsId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (TimingStats Int)
storageContentStats forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"useCount" ResultId
storageUseCountId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageUseCount forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUseCountChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"usedContent" ResultId
storageUsedContentId forall (m :: * -> *). MonadDES m => Storage m -> Event m Int
storageUsedContent forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUsedContentChanged_,
      forall (m :: * -> *) b a.
(MonadDES m, ResultItemable (ResultValue b)) =>
ResultContainer a m
-> ResultName
-> ResultId
-> (a -> Event m b)
-> (a -> Signal m ())
-> ResultProperty m
resultContainerProperty ResultContainer (Storage m) m
c ResultName
"utilisationCountStats" ResultId
storageUtilisationCountStatsId forall (m :: * -> *).
MonadDES m =>
Storage m -> Event m (TimingStats Int)
storageUtilisationCountStats forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageUtilisationCountChanged_ ] }

instance MonadDES m => ResultProvider (Q.Queue m) m where

  resultSource' :: ResultName
-> [ResultName]
-> ResultId
-> [ResultId]
-> Queue m
-> ResultSource m
resultSource' ResultName
name [ResultName]
names ResultId
i [ResultId]
is Queue m
m =
    forall (m :: * -> *).
MonadDES m =>
ResultContainer (Queue m) m -> ResultSource m
queueResultSource forall a b. (a -> b) -> a -> b
$ forall e (m :: * -> *).
ResultName
-> [ResultName]
-> ResultId
-> [ResultId]
-> e
-> ResultSignal m
-> ResultContainer e m
ResultContainer ResultName
name [ResultName]
names ResultId
i [ResultId]
is Queue m
m (forall (m :: * -> *). Signal m () -> ResultSignal m
ResultSignal forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadDES m => Queue m -> Signal m ()
Q.queueChanged_ Queue m
m)

instance MonadDES m => ResultProvider (Facility m a) m where

  resultSource' :: ResultName
-> [ResultName]
-> ResultId
-> [ResultId]
-> Facility m a
-> ResultSource m
resultSource' ResultName
name [ResultName]
names ResultId
i [ResultId]
is Facility m a
m =
    forall (m :: * -> *) a.
MonadDES m =>
ResultContainer (Facility m a) m -> ResultSource m
facilityResultSource forall a b. (a -> b) -> a -> b
$ forall e (m :: * -> *).
ResultName
-> [ResultName]
-> ResultId
-> [ResultId]
-> e
-> ResultSignal m
-> ResultContainer e m
ResultContainer ResultName
name [ResultName]
names ResultId
i [ResultId]
is Facility m a
m (forall (m :: * -> *). Signal m () -> ResultSignal m
ResultSignal forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *) a. MonadDES m => Facility m a -> Signal m ()
facilityChanged_ Facility m a
m)

instance MonadDES m => ResultProvider (Storage m) m where

  resultSource' :: ResultName
-> [ResultName]
-> ResultId
-> [ResultId]
-> Storage m
-> ResultSource m
resultSource' ResultName
name [ResultName]
names ResultId
i [ResultId]
is Storage m
m =
    forall (m :: * -> *).
MonadDES m =>
ResultContainer (Storage m) m -> ResultSource m
storageResultSource forall a b. (a -> b) -> a -> b
$ forall e (m :: * -> *).
ResultName
-> [ResultName]
-> ResultId
-> [ResultId]
-> e
-> ResultSignal m
-> ResultContainer e m
ResultContainer ResultName
name [ResultName]
names ResultId
i [ResultId]
is Storage m
m (forall (m :: * -> *). Signal m () -> ResultSignal m
ResultSignal forall a b. (a -> b) -> a -> b
$ forall (m :: * -> *). MonadDES m => Storage m -> Signal m ()
storageChanged_ Storage m
m)