Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

build fixes for current zoom-cache #1

Merged
merged 2 commits into from

2 participants

Conrad Parker Alex Lang
Conrad Parker

I'm preparing a new zoom-cache release but want to check it doesn't break too much stuff first ....

Alex Lang alang9 merged commit 3cf6215 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 12 additions and 27 deletions.
  1. +3 −8 Data/ZoomCache/Gnuplot.hs
  2. +9 −19 tools/zoom-cache-gnuplot.hs
11 Data/ZoomCache/Gnuplot.hs
View
@@ -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))
28 tools/zoom-cache-gnuplot.hs
View
@@ -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)
Something went wrong with that request. Please try again.