-
Notifications
You must be signed in to change notification settings - Fork 1
/
Calculator.hs
61 lines (46 loc) · 2.04 KB
/
Calculator.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
{-# LANGUAGE DuplicateRecordFields, GADTs #-}
module Enqm.Macroblock.Calculator where
import System.Random
data Linked
data Template
data Published
type SizeInBytes = Integer
type GapInMilliseconds = Integer
type LifeTimeInMilliseconds = Integer
type UniformFromZeroToOne = Double
type ProbFunU a = UniformFromZeroToOne -> a
type PointAtTime = Integer -- Milliseconds
type Cursor = (PointAtTime,[MacroBlock])
data Link = Link { macroblockId :: Int, blockNumber :: Int }
data MacroBlock = MacroBlock { macroblockId :: Int, sequenceOfBlocks :: [Block Published] }
data Block a where
Published :: PointAtTime -> Block Linked -> Block Published
Linked :: [Link] -> Block Template -> Block Linked
BytesUsed :: Int -> Block Template -> Block Template
AnyBlock :: Block Template
data MacroblockGenerator = MG
{ blockMinSize :: SizeInBytes
, blockMaxSize :: SizeInBytes
, probabilityFunctionForBlockSize :: ProbFunU SizeInBytes
, blockMinGapTime :: GapInMilliseconds
, blockMaxGapTime :: GapInMilliseconds
, probabilityFunctionForGapTimeBetweenBlocks :: ProbFunU GapInMilliseconds
, macroblockMinSize :: SizeInBytes
, macroblockMaxSize :: SizeInBytes
, probabilifyFunctionForMacroblockSize :: ProbFunU SizeInBytes
, macroblockMinLifeTime :: LifeTimeInMilliseconds
, macroblockMaxLifeTime :: LifeTimeInMilliseconds
, probabilityFunctionForMacroblockLifeTime :: ProbFunU LifeTimeInMilliseconds
}
{-
getRandom = do
a <- randomRIO (0,2^16)
b <- unsafeInterleaveIO $ getRandom s
return (a:b)
integ (a:b:c) = (a+b) : integ (b:c)
integ _ = []
getRandomPublications = do
rnd <- getRandom
let times = integ rnd
return times
-}