X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Database%2FRRDtool.hs;h=f588fdb619686b5b5bd5efda0503e018356a63f2;hb=79dfae84547f2148b52c317c40bd672e3e52bd5d;hp=7d4fda9167bc050e80d2657a7c48ba8ba7ddcde8;hpb=33d86e2eb7207ec0fd2a65dc6cd61a4636c45d73;p=hs-rrdtool.git diff --git a/Database/RRDtool.hs b/Database/RRDtool.hs index 7d4fda9..f588fdb 100644 --- a/Database/RRDtool.hs +++ b/Database/RRDtool.hs @@ -10,10 +10,14 @@ module Database.RRDtool , CommonExprSet , Constant(..) + , Variable(..) , CommonUnaryOp(..) , CommonBinaryOp(..) , CommonTrinaryOp(..) , CommonSetOp(..) + , VariableShiftPredictOp(..) + , FixedShiftPredictOp(..) + , CommonValue(..) , IterativeValue(..) , AggregativeUnaryOp(..) @@ -152,21 +156,20 @@ dsTest = COMPUTE { dsName = "foo" -- , dsExpr = Previous :<: Const 100 -- , dsExpr = Var "foo" :<: Const 100 - , dsExpr = Average (Const 100 .*. Const 200 .*. HNil) + , dsExpr = AverageOf (Const 100 .*. Const 200 .*. HNil) } -class Show e => Expr e +class (Show e, Eq e) => Expr e class Expr e => CommonExpr e class Expr e => IterativeExpr e class Expr e => AggregativeExpr e instance CommonExpr e => IterativeExpr e -instance CommonExpr e => AggregativeExpr e -class (Show es, HList es) => ExprSet es +class (Show es, Eq es, HList es) => ExprSet es instance ExprSet HNil instance (Expr e, ExprSet es) => ExprSet (HCons e es) -class (Show es, HList es) => CommonExprSet es +class (Show es, Eq es, HList es) => CommonExprSet es instance CommonExprSet es => ExprSet es instance CommonExprSet HNil instance (CommonExpr e, CommonExprSet es) => CommonExprSet (HCons e es) @@ -175,11 +178,16 @@ instance (CommonExpr e, CommonExprSet es) => CommonExprSet (HCons e es) -- Constants and variable names data Constant = Const !Double - | Var !String deriving (Show, Eq, Ord) instance Expr Constant instance CommonExpr Constant +data Variable + = Var !String + deriving (Show, Eq, Ord) +instance Expr Variable +instance CommonExpr Variable + -- Common operators data CommonUnaryOp a = IsUnknown !a @@ -195,6 +203,8 @@ data CommonUnaryOp a | Deg2Rad !a | Rad2Deg !a | Abs !a + | Trend !Variable !a + | TrendNan !Variable !a deriving (Show, Eq, Ord) instance Expr a => Expr (CommonUnaryOp a) instance CommonExpr a => CommonExpr (CommonUnaryOp a) @@ -234,24 +244,68 @@ instance (CommonExpr a, CommonExpr b, CommonExpr c) -- multiple values onto the stack... data CommonSetOp es - = Average !es + = AverageOf !es deriving (Show, Eq, Ord) instance ExprSet es => Expr (CommonSetOp es) instance CommonExprSet es => CommonExpr (CommonSetOp es) +data VariableShiftPredictOp ss w + = VariableShiftPredictAverage !ss !w !Variable + | VariableShiftPredictSigma !ss !w !Variable + deriving (Show, Eq, Ord) +instance (ExprSet ss, Expr w) + => Expr (VariableShiftPredictOp ss w) +instance (CommonExprSet ss, CommonExpr w) + => CommonExpr (VariableShiftPredictOp ss w) + +data FixedShiftPredictOp sm w + = FixedShiftPredictAverage !sm !w !Variable + | FixedShiftPredictSigma !sm !w !Variable + deriving (Show, Eq, Ord) +instance (Expr sm, Expr w) + => Expr (FixedShiftPredictOp sm w) +instance (CommonExpr sm, CommonExpr w) + => CommonExpr (FixedShiftPredictOp sm w) + +-- Common special values +data CommonValue + = Unknown + | Infinity + | NegativeInfinity + | Now + deriving (Show, Eq, Ord) +instance Expr CommonValue +instance CommonExpr CommonValue + -- Iterative special values data IterativeValue = Previous + | PreviousOf !Variable + | Count + | TakenTime + | TakenLocalTime deriving (Show, Eq, Ord) instance Expr IterativeValue instance IterativeExpr IterativeValue --- Aggregative operators -data AggregativeUnaryOp a - = Maximum !a +-- Aggregative operators (fairly restricted due to rrdtool's +-- restriction) +data AggregativeUnaryOp + = Maximum !Variable + | Minimum !Variable + | Average !Variable + | StandardDeviation !Variable + | First !Variable + | Last !Variable + | Total !Variable + | Percent !Variable !Constant + | PercentNan !Variable !Constant + | LSLSlope !Variable + | LSLInt !Variable + | LSLCorrel !Variable deriving (Show, Eq, Ord) -instance Expr a => Expr (AggregativeUnaryOp a) -instance AggregativeExpr a => AggregativeExpr (AggregativeUnaryOp a) +instance Expr AggregativeUnaryOp +instance AggregativeExpr AggregativeUnaryOp -- |The 'createRRD' function lets you set up new Round Robin Database -- (RRD) files. The file is created at its final, full size and filled