Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 42 lines (30 sloc) 1.361 kb
d636587 Lee Pike Moving examples over from sub-packages.
authored
1 --------------------------------------------------------------------------------
2 -- Copyright © 2011 National Institute of Aerospace / Galois, Inc.
3 --------------------------------------------------------------------------------
4
5 {-# LANGUAGE RebindableSyntax #-}
6
77885d8 Lee Pike Major update of examples, fixing them up. Not done!
authored
7 module EngineExample ( engineExample ) where
d636587 Lee Pike Moving examples over from sub-packages.
authored
8
9 import Language.Copilot
abcdc2f Lee Pike Documentation updates.
authored
10 import qualified Prelude as P
77885d8 Lee Pike Major update of examples, fixing them up. Not done!
authored
11 --import qualified Copilot.Compile.SBV as S
d636587 Lee Pike Moving examples over from sub-packages.
authored
12
13 {-
14 "If the majority of the engine temperature probes exeeds 250 degrees, then the
15 cooler is engaged and remains engaged until the majority of the engine
abcdc2f Lee Pike Documentation updates.
authored
16 temperature probes drop to 250 or below. Otherwise, trigger an immediate
17 shutdown of the engine." -}
d636587 Lee Pike Moving examples over from sub-packages.
authored
18
19 engineMonitor :: Spec
20 engineMonitor = do
abcdc2f Lee Pike Documentation updates.
authored
21 trigger "shutoff" (not ok) [arg maj]
77885d8 Lee Pike Major update of examples, fixing them up. Not done!
authored
22
d636587 Lee Pike Moving examples over from sub-packages.
authored
23 where
77885d8 Lee Pike Major update of examples, fixing them up. Not done!
authored
24 vals = [ externW8 "tmp_probe_0" two51
25 , externW8 "tmp_probe_1" two51
26 , externW8 "tmp_probe_2" zero]
abcdc2f Lee Pike Documentation updates.
authored
27 exceed = map (> 250) vals
d636587 Lee Pike Moving examples over from sub-packages.
authored
28 maj = majority exceed
29 checkMaj = aMajority exceed maj
77885d8 Lee Pike Major update of examples, fixing them up. Not done!
authored
30 ok = alwaysBeen ((maj && checkMaj) ==> extern "cooler" cooler)
31
32 two51 = Just $ [251, 251] P.++ repeat (250 :: Word8)
33 zero = Just $ repeat (0 :: Word8)
34 cooler = Just $ [True, True] P.++ repeat False
35
36 engineExample :: IO ()
37 engineExample = interpret 10 engineMonitor
abcdc2f Lee Pike Documentation updates.
authored
38
39 -- reify engineMonitor >>= S.compile (S.Params { S.prefix = Just "engine" })
d636587 Lee Pike Moving examples over from sub-packages.
authored
40
41
Something went wrong with that request. Please try again.