kcd 0.1.0.0 → 0.2.0.0
raw patch · 6 files changed
+465/−461 lines, 6 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
- Kcd.Parser: Auto :: MessageLength
- Kcd.Parser: BigEndian :: Endianess
- Kcd.Parser: Bus :: [Message] -> Text -> Int -> Bus
- Kcd.Parser: Consumer :: [NodeRef] -> Consumer
- Kcd.Parser: Document :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Text -> Document
- Kcd.Parser: Label :: Int -> Text -> BasicLabelTypeValue -> Label
- Kcd.Parser: LabelGroup :: Text -> Text -> Text -> BasicLabelTypeValue -> LabelGroup
- Kcd.Parser: LabelSet :: [Label] -> [LabelGroup] -> LabelSet
- Kcd.Parser: LengthValue :: Int -> MessageLength
- Kcd.Parser: LittleEndian :: Endianess
- Kcd.Parser: Message :: Maybe Notes -> Maybe Producer -> Maybe Multiplex -> [Signal] -> MessageId -> Text -> MessageLength -> Int -> Bool -> Text -> Bool -> Message
- Kcd.Parser: MessageId :: Int -> MessageId
- Kcd.Parser: Multiplex :: [MuxGroup] -> Maybe Notes -> Maybe Consumer -> Maybe Value -> [Label] -> Endianess -> Int -> Text -> Int -> Multiplex
- Kcd.Parser: MuxGroup :: [Signal] -> Int -> MuxGroup
- Kcd.Parser: NetworkDefinition :: Document -> [Node] -> [Bus] -> NetworkDefinition
- Kcd.Parser: Node :: Text -> Maybe Text -> [Var] -> Node
- Kcd.Parser: NodeRef :: Text -> NodeRef
- Kcd.Parser: Notes :: Text -> Notes
- Kcd.Parser: Producer :: [NodeRef] -> Producer
- Kcd.Parser: Signal :: Maybe Notes -> Maybe Consumer -> Maybe Value -> [LabelSet] -> Endianess -> Int -> Text -> Int -> Signal
- Kcd.Parser: TypeError :: BasicLabelTypeValue
- Kcd.Parser: TypeInvalid :: BasicLabelTypeValue
- Kcd.Parser: TypeValue :: BasicLabelTypeValue
- Kcd.Parser: Value :: Double -> Double -> Double -> Double -> Text -> ValueType -> Value
- Kcd.Parser: ValueTypeDouble :: ValueType
- Kcd.Parser: ValueTypeSigned :: ValueType
- Kcd.Parser: ValueTypeSingle :: ValueType
- Kcd.Parser: ValueTypeUnsigned :: ValueType
- Kcd.Parser: Var :: Value -> Maybe Notes -> Text -> Var
- Kcd.Parser: [_busBaudrate] :: Bus -> Int
- Kcd.Parser: [_busMessages] :: Bus -> [Message]
- Kcd.Parser: [_busName] :: Bus -> Text
- Kcd.Parser: [_consumerNodeRef] :: Consumer -> [NodeRef]
- Kcd.Parser: [_documentAuthor] :: Document -> Maybe Text
- Kcd.Parser: [_documentCompany] :: Document -> Maybe Text
- Kcd.Parser: [_documentContent] :: Document -> Text
- Kcd.Parser: [_documentDate] :: Document -> Maybe Text
- Kcd.Parser: [_documentName] :: Document -> Maybe Text
- Kcd.Parser: [_documentVersion] :: Document -> Maybe Text
- Kcd.Parser: [_labelGroupFrom] :: LabelGroup -> Text
- Kcd.Parser: [_labelGroupName] :: LabelGroup -> Text
- Kcd.Parser: [_labelGroupTo] :: LabelGroup -> Text
- Kcd.Parser: [_labelGroupType] :: LabelGroup -> BasicLabelTypeValue
- Kcd.Parser: [_labelName] :: Label -> Text
- Kcd.Parser: [_labelSetLabelGroup] :: LabelSet -> [LabelGroup]
- Kcd.Parser: [_labelSetLabel] :: LabelSet -> [Label]
- Kcd.Parser: [_labelType] :: Label -> BasicLabelTypeValue
- Kcd.Parser: [_labelValue] :: Label -> Int
- Kcd.Parser: [_messageFormat] :: Message -> Text
- Kcd.Parser: [_messageId] :: Message -> MessageId
- Kcd.Parser: [_messageInterval] :: Message -> Int
- Kcd.Parser: [_messageLength] :: Message -> MessageLength
- Kcd.Parser: [_messageMultiplex] :: Message -> Maybe Multiplex
- Kcd.Parser: [_messageName] :: Message -> Text
- Kcd.Parser: [_messageNotes] :: Message -> Maybe Notes
- Kcd.Parser: [_messageProducer] :: Message -> Maybe Producer
- Kcd.Parser: [_messageRemote] :: Message -> Bool
- Kcd.Parser: [_messageSignals] :: Message -> [Signal]
- Kcd.Parser: [_messageTriggered] :: Message -> Bool
- Kcd.Parser: [_multiplexConsumer] :: Multiplex -> Maybe Consumer
- Kcd.Parser: [_multiplexEndianess] :: Multiplex -> Endianess
- Kcd.Parser: [_multiplexLabels] :: Multiplex -> [Label]
- Kcd.Parser: [_multiplexLength] :: Multiplex -> Int
- Kcd.Parser: [_multiplexMuxGroup] :: Multiplex -> [MuxGroup]
- Kcd.Parser: [_multiplexName] :: Multiplex -> Text
- Kcd.Parser: [_multiplexNotes] :: Multiplex -> Maybe Notes
- Kcd.Parser: [_multiplexOffset] :: Multiplex -> Int
- Kcd.Parser: [_multiplexValue] :: Multiplex -> Maybe Value
- Kcd.Parser: [_muxGroupCount] :: MuxGroup -> Int
- Kcd.Parser: [_muxGroupSignals] :: MuxGroup -> [Signal]
- Kcd.Parser: [_networkDefinitionBuses] :: NetworkDefinition -> [Bus]
- Kcd.Parser: [_networkDefinitionDocument] :: NetworkDefinition -> Document
- Kcd.Parser: [_networkDefinitionNodes] :: NetworkDefinition -> [Node]
- Kcd.Parser: [_nodeId] :: Node -> Text
- Kcd.Parser: [_nodeName] :: Node -> Maybe Text
- Kcd.Parser: [_nodeRefId] :: NodeRef -> Text
- Kcd.Parser: [_nodeVars] :: Node -> [Var]
- Kcd.Parser: [_producerNodeRef] :: Producer -> [NodeRef]
- Kcd.Parser: [_signalConsumer] :: Signal -> Maybe Consumer
- Kcd.Parser: [_signalEndianess] :: Signal -> Endianess
- Kcd.Parser: [_signalLabelSet] :: Signal -> [LabelSet]
- Kcd.Parser: [_signalLength] :: Signal -> Int
- Kcd.Parser: [_signalName] :: Signal -> Text
- Kcd.Parser: [_signalNotes] :: Signal -> Maybe Notes
- Kcd.Parser: [_signalOffset] :: Signal -> Int
- Kcd.Parser: [_signalValue] :: Signal -> Maybe Value
- Kcd.Parser: [_unMessageId] :: MessageId -> Int
- Kcd.Parser: [_valueIntercept] :: Value -> Double
- Kcd.Parser: [_valueMax] :: Value -> Double
- Kcd.Parser: [_valueMin] :: Value -> Double
- Kcd.Parser: [_valueSlope] :: Value -> Double
- Kcd.Parser: [_valueType] :: Value -> ValueType
- Kcd.Parser: [_valueUnit] :: Value -> Text
- Kcd.Parser: [_varName] :: Var -> Text
- Kcd.Parser: [_varNotes] :: Var -> Maybe Notes
- Kcd.Parser: [_varValue] :: Var -> Value
- Kcd.Parser: data BasicLabelTypeValue
- Kcd.Parser: data Bus
- Kcd.Parser: data Consumer
- Kcd.Parser: data Document
- Kcd.Parser: data Endianess
- Kcd.Parser: data Label
- Kcd.Parser: data LabelGroup
- Kcd.Parser: data LabelSet
- Kcd.Parser: data Message
- Kcd.Parser: data MessageLength
- Kcd.Parser: data Multiplex
- Kcd.Parser: data MuxGroup
- Kcd.Parser: data NetworkDefinition
- Kcd.Parser: data Node
- Kcd.Parser: data NodeRef
- Kcd.Parser: data Producer
- Kcd.Parser: data Signal
- Kcd.Parser: data Value
- Kcd.Parser: data ValueType
- Kcd.Parser: data Var
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.BasicLabelTypeValue
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Bus
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Consumer
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Document
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Endianess
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Label
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.LabelGroup
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.LabelSet
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Message
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.MessageId
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.MessageLength
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Multiplex
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.MuxGroup
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.NetworkDefinition
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Node
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.NodeRef
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Notes
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Producer
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Signal
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Value
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.ValueType
- Kcd.Parser: instance GHC.Classes.Eq Kcd.Parser.Var
- Kcd.Parser: instance GHC.Classes.Ord Kcd.Parser.MessageId
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.BasicLabelTypeValue
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Bus
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Consumer
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Document
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Endianess
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Label
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.LabelGroup
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.LabelSet
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Message
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.MessageId
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.MessageLength
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Multiplex
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.MuxGroup
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.NetworkDefinition
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Node
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.NodeRef
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Notes
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Producer
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Signal
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Value
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.ValueType
- Kcd.Parser: instance GHC.Show.Show Kcd.Parser.Var
- Kcd.Parser: newtype MessageId
- Kcd.Parser: newtype Notes
- Kcd.Parser: parseKcdFile :: String -> IO NetworkDefinition
- Kcd.Parser: parseNetworkDefinition :: MonadThrow m => ConduitM Event o m (Maybe NetworkDefinition)
+ Text.Kcd.Parser: Auto :: MessageLength
+ Text.Kcd.Parser: BigEndian :: Endianess
+ Text.Kcd.Parser: Bus :: [Message] -> Text -> Int -> Bus
+ Text.Kcd.Parser: Consumer :: [NodeRef] -> Consumer
+ Text.Kcd.Parser: Document :: Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Text -> Document
+ Text.Kcd.Parser: Label :: Int -> Text -> BasicLabelTypeValue -> Label
+ Text.Kcd.Parser: LabelGroup :: Text -> Text -> Text -> BasicLabelTypeValue -> LabelGroup
+ Text.Kcd.Parser: LabelSet :: [Label] -> [LabelGroup] -> LabelSet
+ Text.Kcd.Parser: LengthValue :: Int -> MessageLength
+ Text.Kcd.Parser: LittleEndian :: Endianess
+ Text.Kcd.Parser: Message :: Maybe Notes -> Maybe Producer -> Maybe Multiplex -> [Signal] -> MessageId -> Text -> MessageLength -> Int -> Bool -> Text -> Bool -> Message
+ Text.Kcd.Parser: MessageId :: Int -> MessageId
+ Text.Kcd.Parser: Multiplex :: [MuxGroup] -> Maybe Notes -> Maybe Consumer -> Maybe Value -> [Label] -> Endianess -> Int -> Text -> Int -> Multiplex
+ Text.Kcd.Parser: MuxGroup :: [Signal] -> Int -> MuxGroup
+ Text.Kcd.Parser: NetworkDefinition :: Document -> [Node] -> [Bus] -> NetworkDefinition
+ Text.Kcd.Parser: Node :: Text -> Maybe Text -> [Var] -> Node
+ Text.Kcd.Parser: NodeRef :: Text -> NodeRef
+ Text.Kcd.Parser: Notes :: Text -> Notes
+ Text.Kcd.Parser: Producer :: [NodeRef] -> Producer
+ Text.Kcd.Parser: Signal :: Maybe Notes -> Maybe Consumer -> Maybe Value -> [LabelSet] -> Endianess -> Int -> Text -> Int -> Signal
+ Text.Kcd.Parser: TypeError :: BasicLabelTypeValue
+ Text.Kcd.Parser: TypeInvalid :: BasicLabelTypeValue
+ Text.Kcd.Parser: TypeValue :: BasicLabelTypeValue
+ Text.Kcd.Parser: Value :: Double -> Double -> Double -> Double -> Text -> ValueType -> Value
+ Text.Kcd.Parser: ValueTypeDouble :: ValueType
+ Text.Kcd.Parser: ValueTypeSigned :: ValueType
+ Text.Kcd.Parser: ValueTypeSingle :: ValueType
+ Text.Kcd.Parser: ValueTypeUnsigned :: ValueType
+ Text.Kcd.Parser: Var :: Value -> Maybe Notes -> Text -> Var
+ Text.Kcd.Parser: [_busBaudrate] :: Bus -> Int
+ Text.Kcd.Parser: [_busMessages] :: Bus -> [Message]
+ Text.Kcd.Parser: [_busName] :: Bus -> Text
+ Text.Kcd.Parser: [_consumerNodeRef] :: Consumer -> [NodeRef]
+ Text.Kcd.Parser: [_documentAuthor] :: Document -> Maybe Text
+ Text.Kcd.Parser: [_documentCompany] :: Document -> Maybe Text
+ Text.Kcd.Parser: [_documentContent] :: Document -> Text
+ Text.Kcd.Parser: [_documentDate] :: Document -> Maybe Text
+ Text.Kcd.Parser: [_documentName] :: Document -> Maybe Text
+ Text.Kcd.Parser: [_documentVersion] :: Document -> Maybe Text
+ Text.Kcd.Parser: [_labelGroupFrom] :: LabelGroup -> Text
+ Text.Kcd.Parser: [_labelGroupName] :: LabelGroup -> Text
+ Text.Kcd.Parser: [_labelGroupTo] :: LabelGroup -> Text
+ Text.Kcd.Parser: [_labelGroupType] :: LabelGroup -> BasicLabelTypeValue
+ Text.Kcd.Parser: [_labelName] :: Label -> Text
+ Text.Kcd.Parser: [_labelSetLabelGroup] :: LabelSet -> [LabelGroup]
+ Text.Kcd.Parser: [_labelSetLabel] :: LabelSet -> [Label]
+ Text.Kcd.Parser: [_labelType] :: Label -> BasicLabelTypeValue
+ Text.Kcd.Parser: [_labelValue] :: Label -> Int
+ Text.Kcd.Parser: [_messageFormat] :: Message -> Text
+ Text.Kcd.Parser: [_messageId] :: Message -> MessageId
+ Text.Kcd.Parser: [_messageInterval] :: Message -> Int
+ Text.Kcd.Parser: [_messageLength] :: Message -> MessageLength
+ Text.Kcd.Parser: [_messageMultiplex] :: Message -> Maybe Multiplex
+ Text.Kcd.Parser: [_messageName] :: Message -> Text
+ Text.Kcd.Parser: [_messageNotes] :: Message -> Maybe Notes
+ Text.Kcd.Parser: [_messageProducer] :: Message -> Maybe Producer
+ Text.Kcd.Parser: [_messageRemote] :: Message -> Bool
+ Text.Kcd.Parser: [_messageSignals] :: Message -> [Signal]
+ Text.Kcd.Parser: [_messageTriggered] :: Message -> Bool
+ Text.Kcd.Parser: [_multiplexConsumer] :: Multiplex -> Maybe Consumer
+ Text.Kcd.Parser: [_multiplexEndianess] :: Multiplex -> Endianess
+ Text.Kcd.Parser: [_multiplexLabels] :: Multiplex -> [Label]
+ Text.Kcd.Parser: [_multiplexLength] :: Multiplex -> Int
+ Text.Kcd.Parser: [_multiplexMuxGroup] :: Multiplex -> [MuxGroup]
+ Text.Kcd.Parser: [_multiplexName] :: Multiplex -> Text
+ Text.Kcd.Parser: [_multiplexNotes] :: Multiplex -> Maybe Notes
+ Text.Kcd.Parser: [_multiplexOffset] :: Multiplex -> Int
+ Text.Kcd.Parser: [_multiplexValue] :: Multiplex -> Maybe Value
+ Text.Kcd.Parser: [_muxGroupCount] :: MuxGroup -> Int
+ Text.Kcd.Parser: [_muxGroupSignals] :: MuxGroup -> [Signal]
+ Text.Kcd.Parser: [_networkDefinitionBuses] :: NetworkDefinition -> [Bus]
+ Text.Kcd.Parser: [_networkDefinitionDocument] :: NetworkDefinition -> Document
+ Text.Kcd.Parser: [_networkDefinitionNodes] :: NetworkDefinition -> [Node]
+ Text.Kcd.Parser: [_nodeId] :: Node -> Text
+ Text.Kcd.Parser: [_nodeName] :: Node -> Maybe Text
+ Text.Kcd.Parser: [_nodeRefId] :: NodeRef -> Text
+ Text.Kcd.Parser: [_nodeVars] :: Node -> [Var]
+ Text.Kcd.Parser: [_producerNodeRef] :: Producer -> [NodeRef]
+ Text.Kcd.Parser: [_signalConsumer] :: Signal -> Maybe Consumer
+ Text.Kcd.Parser: [_signalEndianess] :: Signal -> Endianess
+ Text.Kcd.Parser: [_signalLabelSet] :: Signal -> [LabelSet]
+ Text.Kcd.Parser: [_signalLength] :: Signal -> Int
+ Text.Kcd.Parser: [_signalName] :: Signal -> Text
+ Text.Kcd.Parser: [_signalNotes] :: Signal -> Maybe Notes
+ Text.Kcd.Parser: [_signalOffset] :: Signal -> Int
+ Text.Kcd.Parser: [_signalValue] :: Signal -> Maybe Value
+ Text.Kcd.Parser: [_unMessageId] :: MessageId -> Int
+ Text.Kcd.Parser: [_valueIntercept] :: Value -> Double
+ Text.Kcd.Parser: [_valueMax] :: Value -> Double
+ Text.Kcd.Parser: [_valueMin] :: Value -> Double
+ Text.Kcd.Parser: [_valueSlope] :: Value -> Double
+ Text.Kcd.Parser: [_valueType] :: Value -> ValueType
+ Text.Kcd.Parser: [_valueUnit] :: Value -> Text
+ Text.Kcd.Parser: [_varName] :: Var -> Text
+ Text.Kcd.Parser: [_varNotes] :: Var -> Maybe Notes
+ Text.Kcd.Parser: [_varValue] :: Var -> Value
+ Text.Kcd.Parser: data BasicLabelTypeValue
+ Text.Kcd.Parser: data Bus
+ Text.Kcd.Parser: data Consumer
+ Text.Kcd.Parser: data Document
+ Text.Kcd.Parser: data Endianess
+ Text.Kcd.Parser: data Label
+ Text.Kcd.Parser: data LabelGroup
+ Text.Kcd.Parser: data LabelSet
+ Text.Kcd.Parser: data Message
+ Text.Kcd.Parser: data MessageLength
+ Text.Kcd.Parser: data Multiplex
+ Text.Kcd.Parser: data MuxGroup
+ Text.Kcd.Parser: data NetworkDefinition
+ Text.Kcd.Parser: data Node
+ Text.Kcd.Parser: data NodeRef
+ Text.Kcd.Parser: data Producer
+ Text.Kcd.Parser: data Signal
+ Text.Kcd.Parser: data Value
+ Text.Kcd.Parser: data ValueType
+ Text.Kcd.Parser: data Var
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.BasicLabelTypeValue
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Bus
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Consumer
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Document
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Endianess
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Label
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.LabelGroup
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.LabelSet
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Message
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.MessageId
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.MessageLength
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Multiplex
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.MuxGroup
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.NetworkDefinition
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Node
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.NodeRef
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Notes
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Producer
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Signal
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Value
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.ValueType
+ Text.Kcd.Parser: instance GHC.Classes.Eq Text.Kcd.Parser.Var
+ Text.Kcd.Parser: instance GHC.Classes.Ord Text.Kcd.Parser.MessageId
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.BasicLabelTypeValue
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Bus
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Consumer
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Document
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Endianess
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Label
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.LabelGroup
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.LabelSet
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Message
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.MessageId
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.MessageLength
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Multiplex
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.MuxGroup
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.NetworkDefinition
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Node
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.NodeRef
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Notes
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Producer
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Signal
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Value
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.ValueType
+ Text.Kcd.Parser: instance GHC.Show.Show Text.Kcd.Parser.Var
+ Text.Kcd.Parser: newtype MessageId
+ Text.Kcd.Parser: newtype Notes
+ Text.Kcd.Parser: parseKcdFile :: String -> IO NetworkDefinition
+ Text.Kcd.Parser: parseNetworkDefinition :: MonadThrow m => ConduitM Event o m (Maybe NetworkDefinition)
Files
- ChangeLog.md +6/−2
- kcd.cabal +4/−4
- src/Kcd.hs +0/−5
- src/Kcd/Parser.hs +0/−450
- src/Text/Kcd.hs +5/−0
- src/Text/Kcd/Parser.hs +450/−0
ChangeLog.md view
@@ -1,5 +1,9 @@ # Revision history for kcd-parser -## 0.1.0.0 -- YYYY-mm-dd+## 0.1.0.0 -- 2017-01-13 -* First version. Released on an unsuspecting world.+* First version. Parse Kayak can_definition_sample.kcd.++## 0.2.0.0 -- 2017-01-13++* Move Kcd module to Text
kcd.cabal view
@@ -2,7 +2,7 @@ -- documentation, see http://haskell.org/cabal/users-guide/ name: kcd-version: 0.1.0.0+version: 0.2.0.0 synopsis: Kayak .kcd parsing library. description: Parse Kayak .kcd files. Kcd files list CAN messages details, their signal's and signal details,@@ -12,7 +12,7 @@ author: marcelbuesing maintainer: buesing.marcel@googlemail.com -- copyright:-category: Data+category: Text build-type: Simple extra-source-files: ChangeLog.md cabal-version: >=1.10@@ -20,8 +20,8 @@ bug-reports: https://github.com/marcelbuesing/kcd/issues library- exposed-modules: Kcd- , Kcd.Parser+ exposed-modules: Text.Kcd+ , Text.Kcd.Parser -- other-modules: -- other-extensions: build-depends: base >=4.9 && <4.10
− src/Kcd.hs
@@ -1,5 +0,0 @@-module Kcd (- module Kcd.Parser- ) where--import Kcd.Parser
− src/Kcd/Parser.hs
@@ -1,450 +0,0 @@-{-# LANGUAGE GeneralizedNewtypeDeriving #-}-{-# LANGUAGE OverloadedStrings #-}-{-# LANGUAGE TemplateHaskell #-}---- |--- > import qualified Kcd.Parser as KCD--- > main = do--- > kcd <- KCD.parseKcdFile "example.kcd"--- > print kcd--module Kcd.Parser- (- parseKcdFile- , parseNetworkDefinition- , BasicLabelTypeValue (..)- , Bus (..)- , Consumer (..)- , Document (..)- , Endianess (..)- , Label (..)- , LabelGroup (..)- , LabelSet (..)- , Message (..)- , MessageId (..)- , MessageLength (..)- , Multiplex (..)- , MuxGroup (..)- , NetworkDefinition (..)- , Node (..)- , NodeRef (..)- , Notes (..)- , Producer (..)- , Signal (..)- , Value (..)- , ValueType (..)- , Var (..)- )-where--import Control.Applicative ((<|>))-import Control.Lens.TH (makeLenses)-import Control.Monad (join)-import Control.Monad.Catch (MonadCatch, MonadThrow)-import Control.Monad.Trans.Resource (runResourceT)-import Data.Conduit (($$), ConduitM)-import Data.Maybe (fromMaybe)-import Data.Monoid ((<>))-import Data.Text (Text, pack, unpack)-import Data.Text.Read (Reader, hexadecimal)-import Data.XML.Types (Event, Name(..))-import Text.XML.Stream.Parse---- | Definition of one or more CAN bus networks in one file.-data NetworkDefinition = NetworkDefinition- { _networkDefinitionDocument :: Document- , _networkDefinitionNodes :: [Node]- , _networkDefinitionBuses :: [Bus]- } deriving (Show, Eq)---- | Describes the scope of application e.g. the target vehicle or controlled device.-data Document = Document- { -- | The name of the network definition document.- _documentName :: Maybe Text- -- | The version of the network definition document.- , _documentVersion :: Maybe Text- -- | The owner or author of the network definition document.- , _documentAuthor :: Maybe Text- -- | The owner company of the network definition document.- , _documentCompany :: Maybe Text- -- | The release date of this version of the network definition document.- , _documentDate :: Maybe Text- , _documentContent :: Text- } deriving (Show, Eq)---- | network transport system that transfers the data between several nodes.-data Bus = Bus- { _busMessages :: [Message]- -- | Human-readable name of the bus network (e.g. "Comfort").- , _busName :: Text- -- | Nominal data transfer rate in baud (e.g. 500000, 125000, 100000 or 83333).- , _busBaudrate :: Int- } deriving (Show, Eq)---- | An endpoint connected to the network (e.g. an electronic control unit) that is able to--- | send messages to or receive messages from other endpoints.-data Node = Node- { -- | Unique identifier of the network node.- _nodeId :: Text- -- | Human-readable name of the network node (e.g. "Brake").- , _nodeName :: Maybe Text- , _nodeVars :: [Var]- } deriving (Show, Eq)---- | A variable, a symbolic name associated to a chunk of information (e.g. a string or a value).-data Var = Var- { _varValue :: Value- , _varNotes :: Maybe Notes- -- | Unique name of the variable.- , _varName :: Text- } deriving (Show, Eq)--newtype MessageId = MessageId { _unMessageId :: Int } deriving (Eq, Show, Ord)--data MessageLength =- Auto- | LengthValue Int deriving (Show, Eq)--data Message = Message- { _messageNotes :: Maybe Notes- , _messageProducer :: Maybe Producer- , _messageMultiplex :: Maybe Multiplex- , _messageSignals :: [Signal]- , _messageId :: MessageId- , _messageName :: Text- , _messageLength :: MessageLength- -- | Repetition interval of a cyclic network message in milliseconds- , _messageInterval :: Int- -- | Sending behavior of the network message. True, if message is triggered by signal changes.- , _messageTriggered :: Bool- -- | Frame format of the network message.- , _messageFormat :: Text- -- | True, if message is a remote frame- , _messageRemote :: Bool- } deriving (Show, Eq)---- | A looping counter to make a group of signals (MuxGroup) alternately active at a time.-data Multiplex = Multiplex- { _multiplexMuxGroup :: [MuxGroup]- , _multiplexNotes :: Maybe Notes- , _multiplexConsumer :: Maybe Consumer- , _multiplexValue :: Maybe Value- , _multiplexLabels :: [Label]- , _multiplexEndianess :: Endianess- -- | Bit length of the signal.- , _multiplexLength :: Int- -- | Human readable name of the signal- , _multiplexName :: Text- -- | Least significant bit offset of the signal relative to the least significant bit of the messages data payload- , _multiplexOffset :: Int- } deriving (Show, Eq)---- | A group of signals that is just valid when the count value of the group matches with the looping--- | counter (Multiplex).-data MuxGroup = MuxGroup- { _muxGroupSignals :: [Signal]- -- | count value of the Multiplex when the signals of this group become valid.- , _muxGroupCount :: Int- } deriving (Show, Eq)---- | A discrete part of information contained in the payload of a message.-data Signal = Signal- { -- | Describes the purpose of the signal/variable and/or comments on its usage.- _signalNotes :: Maybe Notes- , _signalConsumer :: Maybe Consumer- , _signalValue :: Maybe Value- -- | A set of label and label groups. Each label describes the meaning of a single raw value by an alias name.- -- | A single value can only belong to a one label or label group.- , _signalLabelSet :: [LabelSet]- -- | Determines if Byteorder is big-endian (Motorola), little-endian (Intel) otherwise.- , _signalEndianess :: Endianess- -- | Bit length of the signal.- , _signalLength :: Int- -- | Human readable name of the signal- , _signalName :: Text- -- | Least significant bit offset of the signal relative to the least significant bit of the messages data payload- , _signalOffset :: Int- } deriving (Show, Eq)--data ValueType =- ValueTypeUnsigned -- Unsigned- | ValueTypeSigned -- Signed- | ValueTypeSingle -- Single- | ValueTypeDouble -- Double- deriving (Show, Eq)---- | Details of how the raw value of the signal/variable shall be interpreted.-data Value = Value- { -- | Lower validity limit of the interpreted value after using the slope/intercept equation.- _valueMin :: Double- -- | Upper validity limit of the interpreted value after using the slope/intercept equation.- , _valueMax :: Double- -- | The slope "m" of a linear equation y = mx + b.- , _valueSlope :: Double- -- | The y-axis intercept "b" of a linear equation y = mx + b.- , _valueIntercept :: Double- -- | Physical unit of the value written as unit term as described in "The Unified Code for Units of Measure"- -- | (http :://unitsofmeasure.org/ucum.html)- , _valueUnit :: Text- -- | Datatype of the value e.g. "unsigned","signed" or IEE754 "single", "double".- , _valueType :: ValueType- } deriving (Show, Eq)---- | Network node that is a user/receiver of the assigned signal.-data Consumer = Consumer- { _consumerNodeRef :: [NodeRef]- } deriving (Show, Eq)---- | Origin network node that is the sender of the assigned message.-data Producer = Producer- { _producerNodeRef :: [NodeRef]- } deriving (Show, Eq)---- | An endpoint connected to the network that is able to send messages to or receive messages from other endpoints.-data NodeRef = NodeRef- { -- | Referencing a network node by its unique identifier.- _nodeRefId :: Text- } deriving (Show, Eq)---- | Descriptive name for a single value e.g. to describe an enumeration, mark special,invalid or error values.-data Label = Label- { -- | Signal raw value that is described here.- _labelValue :: Int- -- | Human readable name of the signal- , _labelName :: Text- , _labelType :: BasicLabelTypeValue- } deriving (Show, Eq)--data LabelGroup = LabelGroup- { -- | Signal raw value the label group is starting with.- _labelGroupFrom :: Text- -- | Signal raw value the label group is ending with.- , _labelGroupTo :: Text- -- | Human-readable name for this value.- , _labelGroupName :: Text- -- | Type of value :: "value", "invalid" or "error"- , _labelGroupType :: BasicLabelTypeValue- } deriving (Show, Eq)--data LabelSet = LabelSet- { _labelSetLabel :: [Label]- , _labelSetLabelGroup :: [LabelGroup]- } deriving (Show, Eq)--data BasicLabelTypeValue =- TypeValue -- Value- | TypeInvalid -- Invalid- | TypeError -- Error- deriving (Show, Eq)--data Endianess =- LittleEndian -- Little- | BigEndian -- Big- deriving (Show, Eq)---- | Describes the purpose of the signal/variable and/or comments on its usage.-newtype Notes = Notes Text deriving (Show, Eq);--parseSettings :: ParseSettings-parseSettings = def { psDecodeEntities = decodeHtmlEntities- , psRetainNamespaces = False }--parseKcdFile :: String -> IO NetworkDefinition-parseKcdFile f = runResourceT $- parseFile parseSettings f $$- force "Missing NetworkDefinition" parseNetworkDefinition--parseNetworkDefinition :: MonadThrow m => ConduitM Event o m (Maybe NetworkDefinition)-parseNetworkDefinition = tagIgnoreAttrs (ns "NetworkDefinition") $ do- document <- force "Missing document" parseDocument- nodes <- many parseNode- buses <- many parseBus- return $ NetworkDefinition document nodes buses--parseDocument :: MonadThrow m => ConduitM Event o m (Maybe Document)-parseDocument = tagName (ns "Document") attrs $ \(name, version, author, company, date) -> do- docContent <- content- return $ Document name version author company date docContent- where attrs = do- name <- attr "name"- version <- attr "version"- author <- attr "author"- company <- attr "company"- date <- attr "date"- return $ (,,,,) name version author company date--parseVar :: MonadThrow m => ConduitM Event o m (Maybe Var)-parseVar = tagName (ns "Var") (requireAttr "name") $ \name -> do- notes <- parseNotes- value <- force "Missing Value" parseValue- return $ Var value notes name--parseBus :: MonadThrow m => ConduitM Event o m (Maybe Bus)-parseBus = tagName (ns "Bus") attrs $ \(name, baudrate)-> do- messages <- many parseMessage- return $ Bus messages name baudrate- where attrs = do- name <- requireAttr "name"- baudrate <- fromMaybe 500000 <$> attrRead "baudrate"- return (name, baudrate)--parseMessageLength :: Text -> MessageLength-parseMessageLength "auto" = Auto-parseMessageLength i = LengthValue $ read $ unpack i--parseMessage :: MonadThrow m => ConduitM Event o m (Maybe Message)-parseMessage = tagName (ns "Message") attrs $ \(id, name, length, interval, triggered, count, format, remote) -> do- notes <- parseNotes- producer <- parseProducer- multiplex <- parseMultiplex- signals <- many parseSignal- return $ Message notes producer multiplex signals id name length interval triggered format remote- where attrs = do- id <- (MessageId . readHexNumber) <$> requireAttr "id"- name <- requireAttr "name"- length <- maybe Auto parseMessageLength <$> attr "length"- interval <- fromMaybe 0 <$> attrRead "interval"- triggered <- fromMaybe False <$> attrRead "triggered"- count <- fromMaybe 0 <$> attrRead "count"- format <- fromMaybe "standard" <$> attr "format"- remote <- fromMaybe False <$> attrRead "remote"- return (id, name, length, interval, triggered, count, format, remote)--readHexNumber :: Text -> Int-readHexNumber s = let (Right (n, _)) = hexadecimal s in n--basicSignalAttrs :: AttrParser (Endianess, Int, Text, Int)-basicSignalAttrs = do- endianess <- (fromMaybe LittleEndian . join . fmap parseEndianess) <$> attr "endianess"- length <- fromMaybe 1 <$> attrRead "length"- name <- requireAttr "name"- offset <- (read . unpack) <$> requireAttr "offset"- return (endianess, length, name, offset)--parseMultiplex :: MonadThrow m => ConduitM Event o m (Maybe Multiplex)-parseMultiplex = tagName (ns "Multiplex") basicSignalAttrs $ \(endianess, length, name, offset) -> do- muxGroup <- many parseMuxGroup- notes <- parseNotes- consumer <- parseConsumer- value <- parseValue- labels <- many parseLabel- return $ Multiplex muxGroup notes consumer value labels endianess length name offset--parseMuxGroup :: MonadThrow m => ConduitM Event o m (Maybe MuxGroup)-parseMuxGroup = tagName (ns "MuxGroup") countAttr $ \count -> do- signals <- many parseSignal- return $ MuxGroup signals count- where countAttr = (read . unpack) <$> requireAttr "count"--parseSignal :: MonadThrow m => ConduitM Event o m (Maybe Signal)-parseSignal = tagName (ns "Signal") basicSignalAttrs $ \(endianess, length, name, offset) -> do- notes <- parseNotes- consumer <- parseConsumer- value <- parseValue- labelSet <- many parseLabelSet- return $ Signal notes consumer value labelSet endianess length name offset--parseValueType :: Text -> Maybe ValueType-parseValueType "unsigned" = Just ValueTypeUnsigned-parseValueType "signed" = Just ValueTypeSigned-parseValueType "single" = Just ValueTypeSingle-parseValueType "double" = Just ValueTypeDouble-parseValueType _ = Nothing--parseValue :: MonadThrow m => ConduitM Event o m (Maybe Value)-parseValue = tagName (ns "Value") attrs $ \value -> return value- where attrs = do- min <- fromMaybe 0.0 <$> attrRead "min"- max <- fromMaybe 0.0 <$> attrRead "max"- slope <- fromMaybe 0.0 <$> attrRead "slope"- intercept <- fromMaybe 0.0 <$> attrRead "intercept"- unit <- fromMaybe "1" <$> attr "unit"- type' <- (fromMaybe ValueTypeUnsigned . join . fmap parseValueType) <$> attr "type"- return $ Value min max slope intercept unit type'--parseConsumer :: MonadThrow m => ConduitM Event o m (Maybe Consumer)-parseConsumer = tagNoAttr (ns "Consumer") $ do- nodeRefs <- many parseNodeRef- return $ Consumer nodeRefs--parseProducer :: MonadThrow m => ConduitM Event o m (Maybe Producer)-parseProducer = tagNoAttr (ns "Producer") $ do- nodeRefs <- many parseNodeRef- return $ Producer nodeRefs--parseNode :: MonadThrow m => ConduitM Event o m (Maybe Node)-parseNode = tagName (ns "Node") attrs $ \(id, name) -> do- vars <- many parseVar- return $ Node id name vars- where attrs = do- id <- requireAttr "id"- name <- attr "name"- return (id, name)--parseNodeRef :: MonadThrow m => ConduitM Event o m (Maybe NodeRef)-parseNodeRef = tagName (ns "NodeRef") (requireAttr "id") $ \id -> return $ NodeRef id--parseLabel :: MonadThrow m => ConduitM Event o m (Maybe Label)-parseLabel = tagName (ns "Label") attrs $ \(value, name, type') ->- return $ Label value name type'- where attrs = do- value <- (read . unpack) <$> requireAttr "value"- name <- requireAttr "name"- type' <- (fromMaybe TypeValue . join) . fmap parseBasicLabelTypeValue <$> attr "type"- return (value, name, type')--parseLabelGroup :: MonadThrow m => ConduitM Event o m (Maybe LabelGroup)-parseLabelGroup = tagName (ns "LabelGroup") attrs $ \(from, to, name, type') -> return $ LabelGroup from to name type'- where attrs = do- from <- requireAttr "from"- to <- requireAttr "to"- name <- requireAttr "name"- type' <- (fromMaybe TypeValue . join . fmap parseBasicLabelTypeValue) <$> attr "type"- return (from, to, name, type')--parseNotes :: MonadThrow m => ConduitM Event o m (Maybe Notes)-parseNotes = tagNoAttr (ns "Notes") $ do- note <- content- return $ Notes note--parseBasicLabelTypeValue :: Text -> Maybe BasicLabelTypeValue-parseBasicLabelTypeValue "value" = Just TypeValue-parseBasicLabelTypeValue "invalid" = Just TypeInvalid-parseBasicLabelTypeValue "error" = Just TypeError-parseBasicLabelTypeValue _ = Nothing--parseEndianess :: Text -> Maybe Endianess-parseEndianess "little" = Just LittleEndian-parseEndianess "big" = Just BigEndian-parseEndianess _ = Nothing--parseLabelSet :: MonadThrow m => ConduitM Event o m (Maybe LabelSet)-parseLabelSet = tagNoAttr (ns "LabelSet") $ do- labels <- many parseLabel- labelGroups <- many parseLabelGroup- return $ LabelSet labels labelGroups--attrRead :: Read a => Name -> AttrParser (Maybe a)-attrRead name = fmap (read . unpack) <$> attr name--ns :: Text -> Name-ns n = let ns' = Just "http://kayak.2codeornot2code.org/1.0"- pfx = Nothing- in Name n ns' pfx--makeLenses ''Bus-makeLenses ''Consumer-makeLenses ''Document-makeLenses ''Label-makeLenses ''LabelGroup-makeLenses ''LabelSet-makeLenses ''Message-makeLenses ''Multiplex-makeLenses ''MuxGroup-makeLenses ''NetworkDefinition-makeLenses ''Node-makeLenses ''NodeRef-makeLenses ''Producer-makeLenses ''Signal-makeLenses ''Value-makeLenses ''Var
+ src/Text/Kcd.hs view
@@ -0,0 +1,5 @@+module Text.Kcd (+ module Text.Kcd.Parser+ ) where++import Text.Kcd.Parser
+ src/Text/Kcd/Parser.hs view
@@ -0,0 +1,450 @@+{-# LANGUAGE GeneralizedNewtypeDeriving #-}+{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE TemplateHaskell #-}++-- |+-- > import qualified Kcd.Parser as KCD+-- > main = do+-- > kcd <- KCD.parseKcdFile "example.kcd"+-- > print kcd++module Text.Kcd.Parser+ (+ parseKcdFile+ , parseNetworkDefinition+ , BasicLabelTypeValue (..)+ , Bus (..)+ , Consumer (..)+ , Document (..)+ , Endianess (..)+ , Label (..)+ , LabelGroup (..)+ , LabelSet (..)+ , Message (..)+ , MessageId (..)+ , MessageLength (..)+ , Multiplex (..)+ , MuxGroup (..)+ , NetworkDefinition (..)+ , Node (..)+ , NodeRef (..)+ , Notes (..)+ , Producer (..)+ , Signal (..)+ , Value (..)+ , ValueType (..)+ , Var (..)+ )+where++import Control.Applicative ((<|>))+import Control.Lens.TH (makeLenses)+import Control.Monad (join)+import Control.Monad.Catch (MonadCatch, MonadThrow)+import Control.Monad.Trans.Resource (runResourceT)+import Data.Conduit (($$), ConduitM)+import Data.Maybe (fromMaybe)+import Data.Monoid ((<>))+import Data.Text (Text, pack, unpack)+import Data.Text.Read (Reader, hexadecimal)+import Data.XML.Types (Event, Name(..))+import Text.XML.Stream.Parse++-- | Definition of one or more CAN bus networks in one file.+data NetworkDefinition = NetworkDefinition+ { _networkDefinitionDocument :: Document+ , _networkDefinitionNodes :: [Node]+ , _networkDefinitionBuses :: [Bus]+ } deriving (Show, Eq)++-- | Describes the scope of application e.g. the target vehicle or controlled device.+data Document = Document+ { -- | The name of the network definition document.+ _documentName :: Maybe Text+ -- | The version of the network definition document.+ , _documentVersion :: Maybe Text+ -- | The owner or author of the network definition document.+ , _documentAuthor :: Maybe Text+ -- | The owner company of the network definition document.+ , _documentCompany :: Maybe Text+ -- | The release date of this version of the network definition document.+ , _documentDate :: Maybe Text+ , _documentContent :: Text+ } deriving (Show, Eq)++-- | network transport system that transfers the data between several nodes.+data Bus = Bus+ { _busMessages :: [Message]+ -- | Human-readable name of the bus network (e.g. "Comfort").+ , _busName :: Text+ -- | Nominal data transfer rate in baud (e.g. 500000, 125000, 100000 or 83333).+ , _busBaudrate :: Int+ } deriving (Show, Eq)++-- | An endpoint connected to the network (e.g. an electronic control unit) that is able to+-- | send messages to or receive messages from other endpoints.+data Node = Node+ { -- | Unique identifier of the network node.+ _nodeId :: Text+ -- | Human-readable name of the network node (e.g. "Brake").+ , _nodeName :: Maybe Text+ , _nodeVars :: [Var]+ } deriving (Show, Eq)++-- | A variable, a symbolic name associated to a chunk of information (e.g. a string or a value).+data Var = Var+ { _varValue :: Value+ , _varNotes :: Maybe Notes+ -- | Unique name of the variable.+ , _varName :: Text+ } deriving (Show, Eq)++newtype MessageId = MessageId { _unMessageId :: Int } deriving (Eq, Show, Ord)++data MessageLength =+ Auto+ | LengthValue Int deriving (Show, Eq)++data Message = Message+ { _messageNotes :: Maybe Notes+ , _messageProducer :: Maybe Producer+ , _messageMultiplex :: Maybe Multiplex+ , _messageSignals :: [Signal]+ , _messageId :: MessageId+ , _messageName :: Text+ , _messageLength :: MessageLength+ -- | Repetition interval of a cyclic network message in milliseconds+ , _messageInterval :: Int+ -- | Sending behavior of the network message. True, if message is triggered by signal changes.+ , _messageTriggered :: Bool+ -- | Frame format of the network message.+ , _messageFormat :: Text+ -- | True, if message is a remote frame+ , _messageRemote :: Bool+ } deriving (Show, Eq)++-- | A looping counter to make a group of signals (MuxGroup) alternately active at a time.+data Multiplex = Multiplex+ { _multiplexMuxGroup :: [MuxGroup]+ , _multiplexNotes :: Maybe Notes+ , _multiplexConsumer :: Maybe Consumer+ , _multiplexValue :: Maybe Value+ , _multiplexLabels :: [Label]+ , _multiplexEndianess :: Endianess+ -- | Bit length of the signal.+ , _multiplexLength :: Int+ -- | Human readable name of the signal+ , _multiplexName :: Text+ -- | Least significant bit offset of the signal relative to the least significant bit of the messages data payload+ , _multiplexOffset :: Int+ } deriving (Show, Eq)++-- | A group of signals that is just valid when the count value of the group matches with the looping+-- | counter (Multiplex).+data MuxGroup = MuxGroup+ { _muxGroupSignals :: [Signal]+ -- | count value of the Multiplex when the signals of this group become valid.+ , _muxGroupCount :: Int+ } deriving (Show, Eq)++-- | A discrete part of information contained in the payload of a message.+data Signal = Signal+ { -- | Describes the purpose of the signal/variable and/or comments on its usage.+ _signalNotes :: Maybe Notes+ , _signalConsumer :: Maybe Consumer+ , _signalValue :: Maybe Value+ -- | A set of label and label groups. Each label describes the meaning of a single raw value by an alias name.+ -- | A single value can only belong to a one label or label group.+ , _signalLabelSet :: [LabelSet]+ -- | Determines if Byteorder is big-endian (Motorola), little-endian (Intel) otherwise.+ , _signalEndianess :: Endianess+ -- | Bit length of the signal.+ , _signalLength :: Int+ -- | Human readable name of the signal+ , _signalName :: Text+ -- | Least significant bit offset of the signal relative to the least significant bit of the messages data payload+ , _signalOffset :: Int+ } deriving (Show, Eq)++data ValueType =+ ValueTypeUnsigned -- Unsigned+ | ValueTypeSigned -- Signed+ | ValueTypeSingle -- Single+ | ValueTypeDouble -- Double+ deriving (Show, Eq)++-- | Details of how the raw value of the signal/variable shall be interpreted.+data Value = Value+ { -- | Lower validity limit of the interpreted value after using the slope/intercept equation.+ _valueMin :: Double+ -- | Upper validity limit of the interpreted value after using the slope/intercept equation.+ , _valueMax :: Double+ -- | The slope "m" of a linear equation y = mx + b.+ , _valueSlope :: Double+ -- | The y-axis intercept "b" of a linear equation y = mx + b.+ , _valueIntercept :: Double+ -- | Physical unit of the value written as unit term as described in "The Unified Code for Units of Measure"+ -- | (http :://unitsofmeasure.org/ucum.html)+ , _valueUnit :: Text+ -- | Datatype of the value e.g. "unsigned","signed" or IEE754 "single", "double".+ , _valueType :: ValueType+ } deriving (Show, Eq)++-- | Network node that is a user/receiver of the assigned signal.+data Consumer = Consumer+ { _consumerNodeRef :: [NodeRef]+ } deriving (Show, Eq)++-- | Origin network node that is the sender of the assigned message.+data Producer = Producer+ { _producerNodeRef :: [NodeRef]+ } deriving (Show, Eq)++-- | An endpoint connected to the network that is able to send messages to or receive messages from other endpoints.+data NodeRef = NodeRef+ { -- | Referencing a network node by its unique identifier.+ _nodeRefId :: Text+ } deriving (Show, Eq)++-- | Descriptive name for a single value e.g. to describe an enumeration, mark special,invalid or error values.+data Label = Label+ { -- | Signal raw value that is described here.+ _labelValue :: Int+ -- | Human readable name of the signal+ , _labelName :: Text+ , _labelType :: BasicLabelTypeValue+ } deriving (Show, Eq)++data LabelGroup = LabelGroup+ { -- | Signal raw value the label group is starting with.+ _labelGroupFrom :: Text+ -- | Signal raw value the label group is ending with.+ , _labelGroupTo :: Text+ -- | Human-readable name for this value.+ , _labelGroupName :: Text+ -- | Type of value :: "value", "invalid" or "error"+ , _labelGroupType :: BasicLabelTypeValue+ } deriving (Show, Eq)++data LabelSet = LabelSet+ { _labelSetLabel :: [Label]+ , _labelSetLabelGroup :: [LabelGroup]+ } deriving (Show, Eq)++data BasicLabelTypeValue =+ TypeValue -- Value+ | TypeInvalid -- Invalid+ | TypeError -- Error+ deriving (Show, Eq)++data Endianess =+ LittleEndian -- Little+ | BigEndian -- Big+ deriving (Show, Eq)++-- | Describes the purpose of the signal/variable and/or comments on its usage.+newtype Notes = Notes Text deriving (Show, Eq);++parseSettings :: ParseSettings+parseSettings = def { psDecodeEntities = decodeHtmlEntities+ , psRetainNamespaces = False }++parseKcdFile :: String -> IO NetworkDefinition+parseKcdFile f = runResourceT $+ parseFile parseSettings f $$+ force "Missing NetworkDefinition" parseNetworkDefinition++parseNetworkDefinition :: MonadThrow m => ConduitM Event o m (Maybe NetworkDefinition)+parseNetworkDefinition = tagIgnoreAttrs (ns "NetworkDefinition") $ do+ document <- force "Missing document" parseDocument+ nodes <- many parseNode+ buses <- many parseBus+ return $ NetworkDefinition document nodes buses++parseDocument :: MonadThrow m => ConduitM Event o m (Maybe Document)+parseDocument = tagName (ns "Document") attrs $ \(name, version, author, company, date) -> do+ docContent <- content+ return $ Document name version author company date docContent+ where attrs = do+ name <- attr "name"+ version <- attr "version"+ author <- attr "author"+ company <- attr "company"+ date <- attr "date"+ return $ (,,,,) name version author company date++parseVar :: MonadThrow m => ConduitM Event o m (Maybe Var)+parseVar = tagName (ns "Var") (requireAttr "name") $ \name -> do+ notes <- parseNotes+ value <- force "Missing Value" parseValue+ return $ Var value notes name++parseBus :: MonadThrow m => ConduitM Event o m (Maybe Bus)+parseBus = tagName (ns "Bus") attrs $ \(name, baudrate)-> do+ messages <- many parseMessage+ return $ Bus messages name baudrate+ where attrs = do+ name <- requireAttr "name"+ baudrate <- fromMaybe 500000 <$> attrRead "baudrate"+ return (name, baudrate)++parseMessageLength :: Text -> MessageLength+parseMessageLength "auto" = Auto+parseMessageLength i = LengthValue $ read $ unpack i++parseMessage :: MonadThrow m => ConduitM Event o m (Maybe Message)+parseMessage = tagName (ns "Message") attrs $ \(id, name, length, interval, triggered, count, format, remote) -> do+ notes <- parseNotes+ producer <- parseProducer+ multiplex <- parseMultiplex+ signals <- many parseSignal+ return $ Message notes producer multiplex signals id name length interval triggered format remote+ where attrs = do+ id <- (MessageId . readHexNumber) <$> requireAttr "id"+ name <- requireAttr "name"+ length <- maybe Auto parseMessageLength <$> attr "length"+ interval <- fromMaybe 0 <$> attrRead "interval"+ triggered <- fromMaybe False <$> attrRead "triggered"+ count <- fromMaybe 0 <$> attrRead "count"+ format <- fromMaybe "standard" <$> attr "format"+ remote <- fromMaybe False <$> attrRead "remote"+ return (id, name, length, interval, triggered, count, format, remote)++readHexNumber :: Text -> Int+readHexNumber s = let (Right (n, _)) = hexadecimal s in n++basicSignalAttrs :: AttrParser (Endianess, Int, Text, Int)+basicSignalAttrs = do+ endianess <- (fromMaybe LittleEndian . join . fmap parseEndianess) <$> attr "endianess"+ length <- fromMaybe 1 <$> attrRead "length"+ name <- requireAttr "name"+ offset <- (read . unpack) <$> requireAttr "offset"+ return (endianess, length, name, offset)++parseMultiplex :: MonadThrow m => ConduitM Event o m (Maybe Multiplex)+parseMultiplex = tagName (ns "Multiplex") basicSignalAttrs $ \(endianess, length, name, offset) -> do+ muxGroup <- many parseMuxGroup+ notes <- parseNotes+ consumer <- parseConsumer+ value <- parseValue+ labels <- many parseLabel+ return $ Multiplex muxGroup notes consumer value labels endianess length name offset++parseMuxGroup :: MonadThrow m => ConduitM Event o m (Maybe MuxGroup)+parseMuxGroup = tagName (ns "MuxGroup") countAttr $ \count -> do+ signals <- many parseSignal+ return $ MuxGroup signals count+ where countAttr = (read . unpack) <$> requireAttr "count"++parseSignal :: MonadThrow m => ConduitM Event o m (Maybe Signal)+parseSignal = tagName (ns "Signal") basicSignalAttrs $ \(endianess, length, name, offset) -> do+ notes <- parseNotes+ consumer <- parseConsumer+ value <- parseValue+ labelSet <- many parseLabelSet+ return $ Signal notes consumer value labelSet endianess length name offset++parseValueType :: Text -> Maybe ValueType+parseValueType "unsigned" = Just ValueTypeUnsigned+parseValueType "signed" = Just ValueTypeSigned+parseValueType "single" = Just ValueTypeSingle+parseValueType "double" = Just ValueTypeDouble+parseValueType _ = Nothing++parseValue :: MonadThrow m => ConduitM Event o m (Maybe Value)+parseValue = tagName (ns "Value") attrs $ \value -> return value+ where attrs = do+ min <- fromMaybe 0.0 <$> attrRead "min"+ max <- fromMaybe 0.0 <$> attrRead "max"+ slope <- fromMaybe 0.0 <$> attrRead "slope"+ intercept <- fromMaybe 0.0 <$> attrRead "intercept"+ unit <- fromMaybe "1" <$> attr "unit"+ type' <- (fromMaybe ValueTypeUnsigned . join . fmap parseValueType) <$> attr "type"+ return $ Value min max slope intercept unit type'++parseConsumer :: MonadThrow m => ConduitM Event o m (Maybe Consumer)+parseConsumer = tagNoAttr (ns "Consumer") $ do+ nodeRefs <- many parseNodeRef+ return $ Consumer nodeRefs++parseProducer :: MonadThrow m => ConduitM Event o m (Maybe Producer)+parseProducer = tagNoAttr (ns "Producer") $ do+ nodeRefs <- many parseNodeRef+ return $ Producer nodeRefs++parseNode :: MonadThrow m => ConduitM Event o m (Maybe Node)+parseNode = tagName (ns "Node") attrs $ \(id, name) -> do+ vars <- many parseVar+ return $ Node id name vars+ where attrs = do+ id <- requireAttr "id"+ name <- attr "name"+ return (id, name)++parseNodeRef :: MonadThrow m => ConduitM Event o m (Maybe NodeRef)+parseNodeRef = tagName (ns "NodeRef") (requireAttr "id") $ \id -> return $ NodeRef id++parseLabel :: MonadThrow m => ConduitM Event o m (Maybe Label)+parseLabel = tagName (ns "Label") attrs $ \(value, name, type') ->+ return $ Label value name type'+ where attrs = do+ value <- (read . unpack) <$> requireAttr "value"+ name <- requireAttr "name"+ type' <- (fromMaybe TypeValue . join) . fmap parseBasicLabelTypeValue <$> attr "type"+ return (value, name, type')++parseLabelGroup :: MonadThrow m => ConduitM Event o m (Maybe LabelGroup)+parseLabelGroup = tagName (ns "LabelGroup") attrs $ \(from, to, name, type') -> return $ LabelGroup from to name type'+ where attrs = do+ from <- requireAttr "from"+ to <- requireAttr "to"+ name <- requireAttr "name"+ type' <- (fromMaybe TypeValue . join . fmap parseBasicLabelTypeValue) <$> attr "type"+ return (from, to, name, type')++parseNotes :: MonadThrow m => ConduitM Event o m (Maybe Notes)+parseNotes = tagNoAttr (ns "Notes") $ do+ note <- content+ return $ Notes note++parseBasicLabelTypeValue :: Text -> Maybe BasicLabelTypeValue+parseBasicLabelTypeValue "value" = Just TypeValue+parseBasicLabelTypeValue "invalid" = Just TypeInvalid+parseBasicLabelTypeValue "error" = Just TypeError+parseBasicLabelTypeValue _ = Nothing++parseEndianess :: Text -> Maybe Endianess+parseEndianess "little" = Just LittleEndian+parseEndianess "big" = Just BigEndian+parseEndianess _ = Nothing++parseLabelSet :: MonadThrow m => ConduitM Event o m (Maybe LabelSet)+parseLabelSet = tagNoAttr (ns "LabelSet") $ do+ labels <- many parseLabel+ labelGroups <- many parseLabelGroup+ return $ LabelSet labels labelGroups++attrRead :: Read a => Name -> AttrParser (Maybe a)+attrRead name = fmap (read . unpack) <$> attr name++ns :: Text -> Name+ns n = let ns' = Just "http://kayak.2codeornot2code.org/1.0"+ pfx = Nothing+ in Name n ns' pfx++makeLenses ''Bus+makeLenses ''Consumer+makeLenses ''Document+makeLenses ''Label+makeLenses ''LabelGroup+makeLenses ''LabelSet+makeLenses ''Message+makeLenses ''Multiplex+makeLenses ''MuxGroup+makeLenses ''NetworkDefinition+makeLenses ''Node+makeLenses ''NodeRef+makeLenses ''Producer+makeLenses ''Signal+makeLenses ''Value+makeLenses ''Var