-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | EIBd Client -- -- EIBd Client written in Haskell. @package eibd-client-simple @version 0.0.3 module EIBd.Client.Address -- | Used to determine a message's origin. Each individual address points -- to a single device in the system. It is used as follows: -- --
-- myDeviceAddr :: IndividualAddress -- myDeviceAddr = "1.2.3" -- With OverloadedStrings only ---- -- or -- --
-- myDeviceAddr :: IndividualAddress -- myDeviceAddr = toIndividualAddress 1 2 3 ---- -- Use fromIndividualAddress, in order to dissect an individual -- address: -- --
-- (a, b, c) = fromIndividualAddress myDeviceAddr ---- -- where (a, b, c) are the main-line, sub-line and device -- address. newtype IndividualAddress IndividualAddress :: Word16 -> IndividualAddress -- | Inspect an individual address. fromIndividualAddress :: IndividualAddress -> (Word8, Word8, Word8) -- | Create an individual address. toIndividualAddress :: Word8 -> Word8 -> Word8 -> IndividualAddress -- | Used to identify communication groups. Individual and group addresses -- are created and inspected in similiar fashion. -- --
-- myGrpAddr :: GroupAddress -- myGrpAddr = "1/2/3" ---- -- or -- --
-- myGrpAddr :: GroupAddress -- myGrpAddr = toGroupAddress 1 2 3 ---- -- Inspect the components of a group address in the following manner: -- --
-- (a, b, c) = fromGroupAddress myGrpAddr --newtype GroupAddress GroupAddress :: Word16 -> GroupAddress -- | Inspect a group address. fromGroupAddress :: GroupAddress -> (Word8, Word8, Word8) -- | Create a group address. toGroupAddress :: Word8 -> Word8 -> Word8 -> GroupAddress instance Eq IndividualAddress instance Ord IndividualAddress instance Eq GroupAddress instance Ord GroupAddress instance Show GroupAddress instance IsString GroupAddress instance Show IndividualAddress instance IsString IndividualAddress module EIBd.Client.Types -- | Datapoint Type class DatapointType a fromDPT :: DatapointType a => a -> ByteString toDPT :: DatapointType a => ByteString -> Maybe a -- | DPT 1.x - 1 bit type DPTB1 = Bool -- | DPT 2.x - 2 bits data DPTB2 DPTB2 :: Bool -> Bool -> DPTB2 -- | DPT 3.x - 1 control bit and a 3-bit unsigned integer data DPTB1U3 DPTB1U3 :: Bool -> Word8 -> DPTB1U3 -- | DPT 4.x and 5.x - 8-bit unsigned integer type DPTU8 = Word8 -- | DPT 6.x -- 8-bit signed integer type DPTS8 = Int8 -- | DPT 9.x -- 16-bit floating (not really) point integer newtype DPTF16 DPTF16 :: Float -> DPTF16 instance Show DPTB2 instance Eq DPTB2 instance Ord DPTB2 instance Show DPTB1U3 instance Eq DPTB1U3 instance Ord DPTB1U3 instance Show DPTF16 instance Eq DPTF16 instance Ord DPTF16 instance DatapointType DPTF16 instance DatapointType Int8 instance DatapointType Word8 instance DatapointType DPTB1U3 instance DatapointType DPTB2 instance DatapointType Bool module EIBd.Client.Connection -- | It is possible to connect to a local EIBd server instance via unix -- socket or remotely via a TCP socket. -- --
-- connection <- connectLocal "/tmp/eib" ---- -- or -- --
-- connection <- connectRemote "eibd.address.here" 6720 --data Connection -- | Connect to an EIBd server via a TCP Socket. connectRemote :: ByteString -> Word16 -> IO Connection -- | Connect to an EIBd server via a Unix Socket. connectLocal :: ByteString -> IO Connection -- | Default EIBd port defaultPort :: Word16 -- | Message (very closely related to a CEMI frame) data Message Message :: IndividualAddress -> GroupAddress -> Word8 -> APCI -> ByteString -> Message messageSource :: Message -> IndividualAddress messageDestination :: Message -> GroupAddress messageTPCI :: Message -> Word8 messageAPCI :: Message -> APCI messagePayload :: Message -> ByteString -- | Application Protocol Control Information determines the kind of a -- message. data APCI GroupAddrRead :: APCI GroupAddrResponse :: APCI GroupAddrWrite :: APCI IndividualWrite :: APCI IndividualRequest :: APCI IndividualResponse :: APCI AdcRead :: APCI AdcResponse :: APCI MemoryRead :: APCI MemoryResponse :: APCI MemoryWrite :: APCI UserMessage :: APCI MaskVersionRead :: APCI MaskVersionResponse :: APCI Restart :: APCI Escape :: APCI -- | Fetch a message from the EIBd instance. recvMessage :: Connection -> IO Message -- | Send a message to the EIBd instance. sendMessage :: Connection -> GroupAddress -> Word8 -> APCI -> ByteString -> IO Bool -- | Alternative to "sendMessage". sendMessage' :: Connection -> Message -> IO Bool -- | A special kind of message targeting only communication groups. data GroupMessage GroupRead :: GroupMessage GroupResponse :: ByteString -> GroupMessage GroupWrite :: ByteString -> GroupMessage -- | Receive a group message. recvGroupMessage :: Connection -> IO (IndividualAddress, GroupAddress, GroupMessage) -- | Send a group message. sendGroupMessage :: Connection -> GroupAddress -> GroupMessage -> IO Bool instance Show Connection instance Show APCI instance Eq APCI instance Ord APCI instance Show Message instance Eq Message instance Show GroupMessage instance Eq GroupMessage module EIBd.Client.Groups -- | Handle cached group values type GroupM = MaybeT (StateT GroupCache IO) -- | Execute a GroupM action. Changes to group values will be send to EIBd -- after the GroupM action has run. execGroupM :: GroupM a -> Connection -> GroupCache -> IO GroupCache -- | Try to execute a GroupM action. If it fails return the given -- alternative value. tryGroupM :: a -> GroupM a -> GroupM a -- | Similar to "tryGroupM" but without an alternative return value. tryGroupM_ :: GroupM a -> GroupM () -- | Update a group value. The new value will be commited to the cache -- immediately but not to the bus. See "execGroupM" for more. putGroup :: DatapointType a => GroupAddress -> a -> GroupM () -- | Fetch a group value. If a group value is not cached yet, this function -- will silently fail and stop further instructions. Even in a case of -- failure, previous changes to group values will be commited to EIBd. getGroup :: DatapointType a => GroupAddress -> GroupM a -- | Clear the entire cache. clearGroups :: GroupM () -- | Remove one group from the cache. uncacheGroup :: GroupAddress -> GroupM () module EIBd.Client