⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 threshold.hs

📁 Cores are generated from Confluence a modern logic design language. Confluence is a simple, yet high
💻 HS
字号:
-- | Time integrated threshold functions typically used in condition monitoring.module Language.Atom.Common.Threshold  ( boolThreshold  , floatingThreshold  ) whereimport Language.Atom-- | Boolean thresholding over time.  Output is set when internal counter hits limit, and cleared when counter is 0.boolThreshold :: Name -> Int -> Bool -> Term Bool -> System (Term Bool)boolThreshold name num init input = scope name $ do  assert "positiveNumber" $ num >= 0  state <- bool "state" init  count <- int  "count" (if init then num else 0)  rule "update" $ do    when $ value count >. 0 &&. value count <. num    count <== value count + mux input 1 (-1)  rule "low" $ do    when $ value count ==. 0    state <== false  rule "high" $ do    when $ value count ==. intC num    state <== true  return $ value state-- | Integrating threshold.  Output is set with integral reaches limit, and cleared when integral reaches 0.doubleThreshold :: Name -> Double -> Term Double -> System (Term Bool)doubleThreshold name lim input = scope name $ do  assert "positiveLimit" $ lim >= 0  state <- bool "state" False  sum <- double "sum" 0  (high,low) <- priority    rule "update"    sum <== value sum + input    low  rule "clear" $ do    when $ value sum <=. 0    state <== false    sum <== 0    high  rule "set" $ do    when $ value sum >=. doubleC lim    state <== true    sum <== doubleC lim    high  return  $ value state

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -