Skip to content
Browse files

Merge pull request #1 from kfish/master

build fixes for current zoom-cache

This version of zoom-cache is not yet on Hackage
  • Loading branch information...
2 parents 40570fc + d504292 commit 3cf62158b7292576ecf7a9d0a2a1a064f740f245 @alang9 committed
Showing with 12 additions and 27 deletions.
  1. +3 −8 Data/ZoomCache/Gnuplot.hs
  2. +9 −19 tools/zoom-cache-gnuplot.hs
View
11 Data/ZoomCache/Gnuplot.hs
@@ -69,12 +69,8 @@ avgPlot zsums = Plot.list Graph.lines avgs
----------------------------------------------------------------------
-linePlot :: [Packet] -> Plot.T Z.TimeStamp Double
-linePlot = Plot.list Graph.lines . concat . map pToTD
- where
- pToTD (Packet _ _ _ _ pData pTS) = zip pTS $ extract pData
- extract :: ZoomRaw -> [Double]
- extract (ZoomRaw l) = mapMaybe cast l
+linePlot :: [(Z.TimeStamp, Double)] -> Plot.T Z.TimeStamp Double
+linePlot = Plot.list Graph.lines
----------------------------------------------------------------------
@@ -214,7 +210,7 @@ bollingerPlot zsums = mavg `mappend` upperBB `mappend` lowerBB
getStreams :: FilePath -> Z.TrackNo -> IO [Z.Stream]
getStreams fp tn =
flip I.fileDriverRandom fp $
- (I.joinI $ (enumCacheFile standardIdentifiers :: I.Enumeratee ByteString Stream IO [Stream]) I.getChunks)
+ (I.joinI $ (enumCacheFile standardIdentifiers :: I.Enumeratee ByteString [Stream] IO [Stream]) I.stream2stream)
-- As things stand, we are doing too much processing after running the
-- iteratee. Most of it can be moved before.
@@ -225,7 +221,6 @@ maybeSummaryLevel lvl (StreamSummary file tn zs@(ZoomSummary s)) =
case Z.summaryLevel s == lvl of
True -> Just zs
False -> Nothing
-maybeSummaryLevel _ Z.StreamNull = Nothing
getSummaryCandleVals :: ZoomSummary
-> Maybe (Z.TimeStamp, (Double, Double, Double, Double))
View
28 tools/zoom-cache-gnuplot.hs
@@ -15,11 +15,10 @@ import System.Console.GetOpt
import System.Environment (getArgs)
import System.Exit (exitWith)
import System.FilePath.Posix
-
import qualified Data.Iteratee as I
-import Data.Iteratee (Iteratee(..), getChunks, fileDriverRandom)
+import Data.Iteratee (Iteratee(..), stream2stream, fileDriverRandom)
import Data.Iteratee.ZoomCache (Stream)
-import Data.ZoomCache
+import Data.ZoomCache.Numeric
import Data.ZoomCache.Gnuplot
import qualified Graphics.Gnuplot.Advanced as Plot
@@ -145,7 +144,7 @@ candleProcess (fp, tn, lvl) = fileDriverRandom iter fp
where
iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
- streams <- mapMaybe (isSumLvl tn lvl) <$> getChunks
+ streams <- mapMaybe (isSumLvl tn lvl) <$> stream2stream
let cData = candlePlotData streams
return $ candlePlot cData
@@ -154,7 +153,7 @@ avgProcess (fp, tn, lvl) = fileDriverRandom iter fp
where
iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
- streams <- mapMaybe (isSumLvl tn lvl) <$> getChunks
+ streams <- mapMaybe (isSumLvl tn lvl) <$> stream2stream
return $ avgPlot streams
mavgProcess :: (FilePath, TrackNo, Int) -> IO (Plot.T TimeStamp Double)
@@ -162,7 +161,7 @@ mavgProcess (fp, tn, lvl) = fileDriverRandom iter fp
where
iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
- streams <- mapMaybe (isSumLvl tn lvl) <$> getChunks
+ streams <- mapMaybe (isSumLvl tn lvl) <$> stream2stream
return $ mavgPlot streams
bollingerProcess :: (FilePath, TrackNo, Int) -> IO (Plot.T TimeStamp Double)
@@ -170,33 +169,24 @@ bollingerProcess (fp, tn, lvl) = fileDriverRandom iter fp
where
iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
- streams <- mapMaybe (isSumLvl tn lvl) <$> getChunks
+ streams <- mapMaybe (isSumLvl tn lvl) <$> stream2stream
return $ bollingerPlot streams
lineProcess :: (FilePath, TrackNo) -> IO (Plot.T TimeStamp Double)
lineProcess (fp, tn) = fileDriverRandom iter fp
where
iter :: Iteratee ByteString IO (Plot.T TimeStamp Double)
- iter = I.joinI . (enumCacheFile standardIdentifiers) $ do
- streams <- mapMaybe (isPacket tn) <$> getChunks
- return $ linePlot streams
+ iter = I.joinI . enumCacheFile standardIdentifiers $
+ (I.joinI . filterTracks [tn] .
+ I.joinI . enumDouble $ (linePlot <$> stream2stream))
isSumLvl :: TrackNo -> Int -> Stream -> Maybe ZoomSummary
isSumLvl tn lvl str =
case str of
StreamPacket{} -> Nothing
- StreamNull -> Nothing
StreamSummary _ tn' zsum@(ZoomSummary sum) ->
if tn == tn' && summaryLevel sum == lvl then Just zsum else Nothing
-isPacket :: TrackNo -> Stream -> Maybe Packet
-isPacket tn str =
- case str of
- StreamSummary{} -> Nothing
- StreamNull -> Nothing
- StreamPacket _ tn' p ->
- if tn == tn' then Just p else Nothing
-
data UnrecognisedFormatException = UnrecognisedFormatException
deriving (Show, Typeable)

0 comments on commit 3cf6215

Please sign in to comment.
Something went wrong with that request. Please try again.