{-# LANGUAGE BlockArguments #-}
{-# LANGUAGE DeriveFunctor #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}
module Tango.Client
(
DeviceProxy,
TangoUrl,
Milliseconds (Milliseconds),
parseTangoUrl,
withDeviceProxy,
newDeviceProxy,
deleteDeviceProxy,
TangoException (TangoException),
RawCommon.ErrSeverity (..),
DevFailed (DevFailed),
devFailedDesc,
devFailedReason,
devFailedOrigin,
devFailedSeverity,
AttributeName (AttributeName),
AttributeInfo (AttributeInfo),
getConfigsForAttributes,
getConfigForAttribute,
TangoValue (TangoValue, tangoValueRead, tangoValueWrite),
Image (Image, imageContent, imageDimX, imageDimY),
TangoAttrMemorizedType (NotKnown, None, Memorized, MemorizedWriteInit),
readIntegralAttribute,
readIntegralImageAttribute,
readIntegralSpectrumAttribute,
readRealAttribute,
readRealImageAttribute,
readRealSpectrumAttribute,
writeIntegralAttribute,
writeIntegralImageAttribute,
writeIntegralSpectrumAttribute,
writeRealAttribute,
writeRealImageAttribute,
writeRealSpectrumAttribute,
readBoolAttribute,
readBoolImageAttribute,
readBoolSpectrumAttribute,
readDoubleAttribute,
readDoubleImageAttribute,
readDoubleSpectrumAttribute,
readEnumAttribute,
readEnumImageAttribute,
readEnumSpectrumAttribute,
readFloatAttribute,
readFloatImageAttribute,
readFloatSpectrumAttribute,
readLong64Attribute,
readLong64ImageAttribute,
readLong64SpectrumAttribute,
readLongAttribute,
readLongImageAttribute,
readLongSpectrumAttribute,
readShortAttribute,
readShortImageAttribute,
readShortSpectrumAttribute,
readStateAttribute,
readStateImageAttribute,
readStateSpectrumAttribute,
readStringAttribute,
readStringImageAttribute,
readStringSpectrumAttribute,
readULong64Attribute,
readULong64ImageAttribute,
readULong64SpectrumAttribute,
readULongAttribute,
readULongImageAttribute,
readULongSpectrumAttribute,
readUShortAttribute,
readUShortImageAttribute,
readUShortSpectrumAttribute,
writeBoolAttribute,
writeBoolImageAttribute,
writeBoolSpectrumAttribute,
writeDoubleAttribute,
writeDoubleImageAttribute,
writeDoubleSpectrumAttribute,
writeEnumAttribute,
writeEnumImageAttribute,
writeEnumSpectrumAttribute,
writeFloatAttribute,
writeFloatImageAttribute,
writeFloatSpectrumAttribute,
writeLong64Attribute,
writeLong64ImageAttribute,
writeLong64SpectrumAttribute,
writeLongAttribute,
writeLongImageAttribute,
writeLongSpectrumAttribute,
writeShortAttribute,
writeShortImageAttribute,
writeShortSpectrumAttribute,
writeStateAttribute,
writeStateImageAttribute,
writeStateSpectrumAttribute,
writeStringAttribute,
writeStringImageAttribute,
writeStringSpectrumAttribute,
writeULong64Attribute,
writeULong64ImageAttribute,
writeULong64SpectrumAttribute,
writeULongAttribute,
writeULongImageAttribute,
writeULongSpectrumAttribute,
writeUShortAttribute,
writeUShortImageAttribute,
writeUShortSpectrumAttribute,
CommandName (CommandName),
DisplayLevel (..),
commandInVoidOutVoid,
CommandData (..),
commandInOutGeneric,
commandInEnumOutGeneric,
commandInGenericOutEnum,
commandInEnumOutEnum,
commandListQuery,
commandQuery,
CommandInfo (..),
Property (..),
PropertyName (..),
getDeviceProperties,
putDeviceProperties,
deleteDeviceProperties,
HaskellTangoDevState (Alarm, Close, Disable, Extract, Fault, Init, Insert, Moving, Off, On, Open, Running, Standby, Unknown),
subscribeEvent,
unsubscribeEvent,
withSubscribedEvent,
SubscribedEvent,
EventType (..),
DatabaseProxy,
createDatabaseProxy,
deleteDatabaseProxy,
withDatabaseProxy,
databaseSearchByDeviceName,
databaseSearchByClass,
databaseSearchObjectsByName,
databaseSearchObjectPropertiesByName,
lockDevice,
unlockDevice,
getAttributeNames,
withLocked,
setTimeout,
getTimeout,
pollCommand,
stopPollCommand,
pollAttribute,
stopPollAttribute,
)
where
import Control.Applicative (Applicative, pure, (<*>))
import Control.Exception (Exception, throw)
import Control.Monad (void, when, (>>=))
import Control.Monad.IO.Class (MonadIO, liftIO)
import Data.Bool (Bool (False, True), otherwise, (||))
import Data.Either (Either (Left, Right))
import Data.Eq (Eq, (/=))
import Data.Foldable (any)
import Data.Function (const, id, ($), (.))
import Data.Functor (Functor, (<$>))
import Data.Int (Int, Int16, Int32, Int64)
import Data.List (drop, head, length, splitAt)
import Data.Maybe (Maybe (Just, Nothing))
import Data.Ord ((>))
import Data.Semigroup ((<>))
import Data.Text (Text, intercalate, isPrefixOf, null, pack, splitOn, unpack)
import Data.Traversable (traverse)
import Data.Word (Word16, Word64)
import Foreign (Storable)
import Foreign.C.String (CString)
import Foreign.C.Types (CInt)
import Foreign.Ptr (Ptr, nullPtr)
import System.IO (IO)
import Tango.Raw.Common
( DatabaseProxyPtr,
DevFailed (DevFailed, devFailedDesc, devFailedOrigin, devFailedReason, devFailedSeverity),
DeviceProxyPtr,
EventType,
HaskellAttrWriteType,
HaskellAttributeData (HaskellAttributeData, dataFormat, dataQuality, dataType, dimX, dimY, name, nbRead, tangoAttributeData, timeStamp),
HaskellAttributeInfoList (HaskellAttributeInfoList, attributeInfoListLength, attributeInfoListSequence),
HaskellCommandData (HaskellCommandData, tangoCommandData),
HaskellCommandInfo (HaskellCommandInfo, cmdDisplayLevel, cmdInType, cmdInTypeDesc, cmdName, cmdOutType, cmdOutTypeDesc, cmdTag),
HaskellCommandInfoList (HaskellCommandInfoList, commandInfoLength, commandInfoSequence),
HaskellDataFormat (HaskellImage, HaskellScalar, HaskellSpectrum),
HaskellDataQuality (HaskellValid),
HaskellDbData (HaskellDbData, dbDataLength, dbDataSequence),
HaskellDbDatum (HaskellDbDatum, dbDatumIsEmpty, dbDatumPropData, dbDatumPropertyName, dbDatumWrongDataType),
HaskellDispLevel,
HaskellErrorStack (errorStackLength, errorStackSequence),
HaskellTangoAttributeData
( HaskellAttributeDataBoolArray,
HaskellAttributeDataDoubleArray,
HaskellAttributeDataFloatArray,
HaskellAttributeDataLong64Array,
HaskellAttributeDataLongArray,
HaskellAttributeDataShortArray,
HaskellAttributeDataStateArray,
HaskellAttributeDataStringArray,
HaskellAttributeDataULong64Array,
HaskellAttributeDataULongArray,
HaskellAttributeDataUShortArray
),
HaskellTangoCommandData (HaskellCommandBool, HaskellCommandCString, HaskellCommandDevEnum, HaskellCommandDevState, HaskellCommandDouble, HaskellCommandFloat, HaskellCommandInt32, HaskellCommandLong64, HaskellCommandShort, HaskellCommandULong64, HaskellCommandUShort, HaskellCommandVarBool, HaskellCommandVarCString, HaskellCommandVarDevState, HaskellCommandVarDouble, HaskellCommandVarFloat, HaskellCommandVarLong, HaskellCommandVarLong64, HaskellCommandVarShort, HaskellCommandVarULong, HaskellCommandVarULong64, HaskellCommandVarUShort, HaskellCommandVoid),
HaskellTangoDataType (HaskellDevBoolean, HaskellDevDouble, HaskellDevEnum, HaskellDevFloat, HaskellDevInt, HaskellDevLong, HaskellDevLong64, HaskellDevShort, HaskellDevState, HaskellDevString, HaskellDevULong, HaskellDevULong64, HaskellDevUShort, HaskellDevVarBooleanArray, HaskellDevVarDoubleArray, HaskellDevVarFloatArray, HaskellDevVarLong64Array, HaskellDevVarLongArray, HaskellDevVarShortArray, HaskellDevVarStateArray, HaskellDevVarStringArray, HaskellDevVarULong64Array, HaskellDevVarULongArray, HaskellDevVarUShortArray, HaskellDevVoid),
HaskellTangoDevState (Alarm, Close, Disable, Extract, Fault, Init, Insert, Moving, Off, On, Open, Running, Standby, Unknown),
HaskellTangoPropertyData (HaskellPropStringArray),
HaskellTangoVarArray (HaskellTangoVarArray, varArrayLength, varArrayValues),
TangoAttrMemorizedType (Memorized, MemorizedWriteInit, None, NotKnown),
Timeval (Timeval),
createEventCallbackWrapper,
tango_command_inout,
tango_command_list_query,
tango_command_query,
tango_create_database_proxy,
tango_create_device_proxy,
tango_create_event_callback,
tango_delete_database_proxy,
tango_delete_device_property,
tango_delete_device_proxy,
tango_free_AttributeData,
tango_free_AttributeInfoList,
tango_free_CommandInfo,
tango_free_CommandInfoList,
tango_free_DbDatum,
tango_free_VarStringArray,
tango_free_event_callback,
tango_get_attribute_config,
tango_get_attribute_list,
tango_get_device_exported,
tango_get_device_exported_for_class,
tango_get_device_property,
tango_get_object_list,
tango_get_object_property_list,
tango_get_timeout_millis,
tango_lock,
tango_poll_attribute,
tango_poll_command,
tango_put_device_property,
tango_read_attribute,
tango_set_timeout_millis,
tango_stop_poll_attribute,
tango_stop_poll_command,
tango_subscribe_event,
tango_unlock,
tango_unsubscribe_event,
tango_write_attribute,
)
import qualified Tango.Raw.Common as RawCommon
import Text.Show (Show, show)
import UnliftIO (MonadUnliftIO, bracket, finally, withRunInIO)
import UnliftIO.Foreign (CBool, CDouble, CFloat, CLong, CShort, CULong, CUShort, alloca, free, new, newArray, newCString, peek, peekArray, peekCString, with, withArray, withCString)
import Prelude (Bounded, Double, Enum (fromEnum, toEnum), Float, Fractional, Integral, Num ((*)), Real, error, fromIntegral, realToFrac)
newtype TangoException = TangoException [DevFailed Text] deriving (Int -> TangoException -> ShowS
[TangoException] -> ShowS
TangoException -> String
(Int -> TangoException -> ShowS)
-> (TangoException -> String)
-> ([TangoException] -> ShowS)
-> Show TangoException
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> TangoException -> ShowS
showsPrec :: Int -> TangoException -> ShowS
$cshow :: TangoException -> String
show :: TangoException -> String
$cshowList :: [TangoException] -> ShowS
showList :: [TangoException] -> ShowS
Show)
instance Exception TangoException
withCStringText :: (MonadUnliftIO m) => Text -> (CString -> m a) -> m a
withCStringText :: forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
t = String -> (CString -> m a) -> m a
forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CString -> m a) -> m a
withCString (Text -> String
unpack Text
t)
peekCStringText :: (MonadUnliftIO m) => CString -> m Text
peekCStringText :: forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText CString
x = do
String
result <- IO String -> m String
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (CString -> IO String
forall (m :: * -> *). MonadIO m => CString -> m String
peekCString CString
x)
Text -> m Text
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (String -> Text
pack String
result)
peekCStringArrayText :: (MonadUnliftIO m, Integral i) => i -> Ptr CString -> m [Text]
peekCStringArrayText :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i) =>
i -> Ptr CString -> m [Text]
peekCStringArrayText i
len Ptr CString
x = do
[CString]
ptrList <- IO [CString] -> m [CString]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [CString] -> m [CString]) -> IO [CString] -> m [CString]
forall a b. (a -> b) -> a -> b
$ Int -> Ptr CString -> IO [CString]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (i -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
len) Ptr CString
x
(CString -> m Text) -> [CString] -> m [Text]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText [CString]
ptrList
checkResult :: (MonadUnliftIO m) => m (Ptr HaskellErrorStack) -> m ()
checkResult :: forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult m (Ptr HaskellErrorStack)
action = do
Ptr HaskellErrorStack
es <- m (Ptr HaskellErrorStack)
action
Bool -> m () -> m ()
forall (f :: * -> *). Applicative f => Bool -> f () -> f ()
when (Ptr HaskellErrorStack
es Ptr HaskellErrorStack -> Ptr HaskellErrorStack -> Bool
forall a. Eq a => a -> a -> Bool
/= Ptr HaskellErrorStack
forall a. Ptr a
nullPtr) (m () -> m ()) -> m () -> m ()
forall a b. (a -> b) -> a -> b
$ do
HaskellErrorStack
errorStack <- IO HaskellErrorStack -> m HaskellErrorStack
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO HaskellErrorStack -> m HaskellErrorStack)
-> IO HaskellErrorStack -> m HaskellErrorStack
forall a b. (a -> b) -> a -> b
$ Ptr HaskellErrorStack -> IO HaskellErrorStack
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellErrorStack
es
[DevFailed CString]
stackItems <- Int -> Ptr (DevFailed CString) -> m [DevFailed CString]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellErrorStack -> Word32
errorStackLength HaskellErrorStack
errorStack)) (HaskellErrorStack -> Ptr (DevFailed CString)
errorStackSequence HaskellErrorStack
errorStack)
[DevFailed Text]
formattedStackItems :: [DevFailed Text] <- (DevFailed CString -> m (DevFailed Text))
-> [DevFailed CString] -> m [DevFailed Text]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((CString -> m Text) -> DevFailed CString -> m (DevFailed Text)
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> DevFailed a -> f (DevFailed b)
traverse CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText) [DevFailed CString]
stackItems
TangoException -> m ()
forall a e. Exception e => e -> a
throw ([DevFailed Text] -> TangoException
TangoException [DevFailed Text]
formattedStackItems)
newtype TangoUrl = TangoUrl Text
parseTangoUrl :: Text -> Either Text TangoUrl
parseTangoUrl :: Text -> Either Text TangoUrl
parseTangoUrl Text
url =
let tangoUrlFromText' :: Text -> Either Text TangoUrl
tangoUrlFromText' Text
url' =
let urlComponents :: [Text]
urlComponents = HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
splitOn Text
"/" Text
url'
in if [Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
urlComponents Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
/= Int
3 Bool -> Bool -> Bool
|| (Text -> Bool) -> [Text] -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
any Text -> Bool
null [Text]
urlComponents
then Text -> Either Text TangoUrl
forall a b. a -> Either a b
Left (Text -> Either Text TangoUrl) -> Text -> Either Text TangoUrl
forall a b. (a -> b) -> a -> b
$ Text
"\"" Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
url Text -> Text -> Text
forall a. Semigroup a => a -> a -> a
<> Text
"\" is not a valid tango URL: has to be of the form \"[tango://host:port/]domain/family/member\""
else TangoUrl -> Either Text TangoUrl
forall a b. b -> Either a b
Right (Text -> TangoUrl
TangoUrl Text
url)
in Text -> Either Text TangoUrl
tangoUrlFromText' (Text -> Either Text TangoUrl) -> Text -> Either Text TangoUrl
forall a b. (a -> b) -> a -> b
$
if Text
"tango://" Text -> Text -> Bool
`isPrefixOf` Text
url
then Text -> [Text] -> Text
intercalate Text
"/" ([Text] -> Text) -> [Text] -> Text
forall a b. (a -> b) -> a -> b
$ Int -> [Text] -> [Text]
forall a. Int -> [a] -> [a]
drop Int
3 (HasCallStack => Text -> Text -> [Text]
Text -> Text -> [Text]
splitOn Text
"/" Text
url)
else Text
url
newtype DeviceProxy = DeviceProxy DeviceProxyPtr
type DatabaseProxy = DatabaseProxyPtr
boolToCBool :: Bool -> CBool
boolToCBool :: Bool -> CBool
boolToCBool Bool
True = CBool
1
boolToCBool Bool
False = CBool
0
cboolToBool :: CBool -> Bool
cboolToBool :: CBool -> Bool
cboolToBool CBool
x
| CBool
x CBool -> CBool -> Bool
forall a. Ord a => a -> a -> Bool
> CBool
0 = Bool
True
| Bool
otherwise = Bool
False
newDeviceProxy :: forall m. (MonadUnliftIO m) => TangoUrl -> m DeviceProxy
newDeviceProxy :: forall (m :: * -> *). MonadUnliftIO m => TangoUrl -> m DeviceProxy
newDeviceProxy (TangoUrl Text
url) = IO DeviceProxy -> m DeviceProxy
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DeviceProxy -> m DeviceProxy)
-> IO DeviceProxy -> m DeviceProxy
forall a b. (a -> b) -> a -> b
$
(Ptr DeviceProxyPtr -> IO DeviceProxy) -> IO DeviceProxy
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca ((Ptr DeviceProxyPtr -> IO DeviceProxy) -> IO DeviceProxy)
-> (Ptr DeviceProxyPtr -> IO DeviceProxy) -> IO DeviceProxy
forall a b. (a -> b) -> a -> b
$ \Ptr DeviceProxyPtr
proxyPtrPtr -> do
String -> (CString -> IO DeviceProxy) -> IO DeviceProxy
forall (m :: * -> *) a.
MonadUnliftIO m =>
String -> (CString -> m a) -> m a
withCString (Text -> String
unpack Text
url) ((CString -> IO DeviceProxy) -> IO DeviceProxy)
-> (CString -> IO DeviceProxy) -> IO DeviceProxy
forall a b. (a -> b) -> a -> b
$ \CString
proxyName -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (CString -> Ptr DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_create_device_proxy CString
proxyName Ptr DeviceProxyPtr
proxyPtrPtr)
DeviceProxyPtr -> DeviceProxy
DeviceProxy (DeviceProxyPtr -> DeviceProxy)
-> IO DeviceProxyPtr -> IO DeviceProxy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr DeviceProxyPtr -> IO DeviceProxyPtr
forall a. Storable a => Ptr a -> IO a
peek Ptr DeviceProxyPtr
proxyPtrPtr
deleteDeviceProxy :: forall m. (MonadUnliftIO m) => DeviceProxy -> m ()
deleteDeviceProxy :: forall (m :: * -> *). MonadUnliftIO m => DeviceProxy -> m ()
deleteDeviceProxy (DeviceProxy DeviceProxyPtr
proxyPtr) = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_delete_device_proxy DeviceProxyPtr
proxyPtr)
withDeviceProxy :: forall m a. (MonadUnliftIO m) => TangoUrl -> (DeviceProxy -> m a) -> m a
withDeviceProxy :: forall (m :: * -> *) a.
MonadUnliftIO m =>
TangoUrl -> (DeviceProxy -> m a) -> m a
withDeviceProxy (TangoUrl Text
proxyAddress) =
let initialize :: m DeviceProxy
initialize :: m DeviceProxy
initialize =
IO DeviceProxy -> m DeviceProxy
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DeviceProxy -> m DeviceProxy)
-> IO DeviceProxy -> m DeviceProxy
forall a b. (a -> b) -> a -> b
$ (Ptr DeviceProxyPtr -> IO DeviceProxy) -> IO DeviceProxy
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr DeviceProxyPtr
proxyPtrPtr -> do
Text -> (CString -> IO DeviceProxy) -> IO DeviceProxy
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
proxyAddress \CString
proxyAddressPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (CString -> Ptr DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_create_device_proxy CString
proxyAddressPtr Ptr DeviceProxyPtr
proxyPtrPtr)
DeviceProxyPtr -> DeviceProxy
DeviceProxy (DeviceProxyPtr -> DeviceProxy)
-> IO DeviceProxyPtr -> IO DeviceProxy
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Ptr DeviceProxyPtr -> IO DeviceProxyPtr
forall a. Storable a => Ptr a -> IO a
peek Ptr DeviceProxyPtr
proxyPtrPtr
deinitialize :: DeviceProxy -> m ()
deinitialize :: DeviceProxy -> m ()
deinitialize (DeviceProxy DeviceProxyPtr
proxyPtrPtr) =
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_delete_device_proxy DeviceProxyPtr
proxyPtrPtr)
in m DeviceProxy
-> (DeviceProxy -> m ()) -> (DeviceProxy -> m a) -> m a
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket m DeviceProxy
initialize DeviceProxy -> m ()
deinitialize
writeScalarAttribute ::
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy ->
AttributeName ->
tangoType ->
HaskellTangoDataType ->
(HaskellTangoVarArray tangoType -> HaskellTangoAttributeData) ->
m ()
writeScalarAttribute :: forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeName) tangoType
newValue HaskellTangoDataType
tangoType HaskellTangoVarArray tangoType -> HaskellTangoAttributeData
intract = do
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName ((CString -> m ()) -> m ()) -> (CString -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \CString
attributeNamePtr ->
tangoType -> (Ptr tangoType -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with tangoType
newValue ((Ptr tangoType -> m ()) -> m ())
-> (Ptr tangoType -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \Ptr tangoType
newValuePtr ->
HaskellAttributeData -> (Ptr HaskellAttributeData -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
( HaskellAttributeData
{ dataFormat :: HaskellDataFormat
dataFormat = HaskellDataFormat
HaskellScalar,
dataQuality :: HaskellDataQuality
dataQuality = HaskellDataQuality
HaskellValid,
nbRead :: CLong
nbRead = CLong
0,
name :: CString
name = CString
attributeNamePtr,
dimX :: Int32
dimX = Int32
1,
dimY :: Int32
dimY = Int32
1,
timeStamp :: Timeval
timeStamp = CLong -> CLong -> Timeval
Timeval CLong
0 CLong
0,
dataType :: HaskellTangoDataType
dataType = HaskellTangoDataType
tangoType,
tangoAttributeData :: HaskellTangoAttributeData
tangoAttributeData = HaskellTangoVarArray tangoType -> HaskellTangoAttributeData
intract (Word32 -> Ptr tangoType -> HaskellTangoVarArray tangoType
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray Word32
1 Ptr tangoType
newValuePtr)
}
)
(IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> (Ptr HaskellAttributeData -> IO ())
-> Ptr HaskellAttributeData
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellAttributeData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr
-> Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack)
tango_write_attribute DeviceProxyPtr
proxyPtr)
writeSpectrumAttribute ::
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy ->
AttributeName ->
[tangoType] ->
HaskellTangoDataType ->
(HaskellTangoVarArray tangoType -> HaskellTangoAttributeData) ->
m ()
writeSpectrumAttribute :: forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeName) [tangoType]
newValues HaskellTangoDataType
tangoType HaskellTangoVarArray tangoType -> HaskellTangoAttributeData
intract =
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName ((CString -> m ()) -> m ()) -> (CString -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \CString
attributeNamePtr ->
[tangoType] -> (Ptr tangoType -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [tangoType]
newValues \Ptr tangoType
newValuesPtr ->
HaskellAttributeData -> (Ptr HaskellAttributeData -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
( HaskellAttributeData
{ dataFormat :: HaskellDataFormat
dataFormat = HaskellDataFormat
HaskellSpectrum,
dataQuality :: HaskellDataQuality
dataQuality = HaskellDataQuality
HaskellValid,
nbRead :: CLong
nbRead = CLong
0,
name :: CString
name = CString
attributeNamePtr,
dimX :: Int32
dimX = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([tangoType] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [tangoType]
newValues),
dimY :: Int32
dimY = Int32
1,
timeStamp :: Timeval
timeStamp = CLong -> CLong -> Timeval
Timeval CLong
0 CLong
0,
dataType :: HaskellTangoDataType
dataType = HaskellTangoDataType
tangoType,
tangoAttributeData :: HaskellTangoAttributeData
tangoAttributeData = HaskellTangoVarArray tangoType -> HaskellTangoAttributeData
intract (Word32 -> Ptr tangoType -> HaskellTangoVarArray tangoType
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([tangoType] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [tangoType]
newValues)) Ptr tangoType
newValuesPtr)
}
)
(IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> (Ptr HaskellAttributeData -> IO ())
-> Ptr HaskellAttributeData
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellAttributeData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr
-> Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack)
tango_write_attribute DeviceProxyPtr
proxyPtr)
writeImageAttribute ::
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy ->
AttributeName ->
Image tangoType ->
HaskellTangoDataType ->
(HaskellTangoVarArray tangoType -> HaskellTangoAttributeData) ->
m ()
writeImageAttribute :: forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeName) Image tangoType
newImage HaskellTangoDataType
tangoType HaskellTangoVarArray tangoType -> HaskellTangoAttributeData
intract =
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName ((CString -> m ()) -> m ()) -> (CString -> m ()) -> m ()
forall a b. (a -> b) -> a -> b
$ \CString
attributeNamePtr ->
[tangoType] -> (Ptr tangoType -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray (Image tangoType -> [tangoType]
forall a. Image a -> [a]
imageContent Image tangoType
newImage) \Ptr tangoType
newValuesPtr ->
HaskellAttributeData -> (Ptr HaskellAttributeData -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
( HaskellAttributeData
{ dataFormat :: HaskellDataFormat
dataFormat = HaskellDataFormat
HaskellImage,
dataQuality :: HaskellDataQuality
dataQuality = HaskellDataQuality
HaskellValid,
nbRead :: CLong
nbRead = CLong
0,
name :: CString
name = CString
attributeNamePtr,
dimX :: Int32
dimX = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Image tangoType -> Int
forall a. Image a -> Int
imageDimX Image tangoType
newImage),
dimY :: Int32
dimY = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Image tangoType -> Int
forall a. Image a -> Int
imageDimY Image tangoType
newImage),
timeStamp :: Timeval
timeStamp = CLong -> CLong -> Timeval
Timeval CLong
0 CLong
0,
dataType :: HaskellTangoDataType
dataType = HaskellTangoDataType
tangoType,
tangoAttributeData :: HaskellTangoAttributeData
tangoAttributeData = HaskellTangoVarArray tangoType -> HaskellTangoAttributeData
intract (Word32 -> Ptr tangoType -> HaskellTangoVarArray tangoType
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([tangoType] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length (Image tangoType -> [tangoType]
forall a. Image a -> [a]
imageContent Image tangoType
newImage))) Ptr tangoType
newValuesPtr)
}
)
(IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> (Ptr HaskellAttributeData -> IO ())
-> Ptr HaskellAttributeData
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellAttributeData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr
-> Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack)
tango_write_attribute DeviceProxyPtr
proxyPtr)
writeIntegralAttribute :: (MonadUnliftIO m, Integral i) => DeviceProxy -> AttributeName -> i -> m ()
writeIntegralAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i) =>
DeviceProxy -> AttributeName -> i -> m ()
writeIntegralAttribute DeviceProxy
proxy AttributeName
attributeName i
newValue = do
AttributeInfo
config <- DeviceProxy -> AttributeName -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName
case AttributeInfo -> HaskellTangoDataType
attributeInfoDataType AttributeInfo
config of
HaskellTangoDataType
HaskellDevShort ->
DeviceProxy -> AttributeName -> Int16 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Int16 -> m ()
writeShortAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
newValue)
HaskellTangoDataType
HaskellDevUShort ->
DeviceProxy -> AttributeName -> Word16 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Word16 -> m ()
writeUShortAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
newValue)
HaskellTangoDataType
HaskellDevLong ->
DeviceProxy -> AttributeName -> Int64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Int64 -> m ()
writeLongAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
newValue)
HaskellTangoDataType
HaskellDevULong ->
DeviceProxy -> AttributeName -> Word64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Word64 -> m ()
writeULongAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
newValue)
HaskellTangoDataType
HaskellDevLong64 ->
DeviceProxy -> AttributeName -> Int64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Int64 -> m ()
writeLong64Attribute DeviceProxy
proxy AttributeName
attributeName (i -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
newValue)
HaskellTangoDataType
HaskellDevULong64 ->
DeviceProxy -> AttributeName -> Word64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Word64 -> m ()
writeULong64Attribute DeviceProxy
proxy AttributeName
attributeName (i -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral i
newValue)
HaskellTangoDataType
_ -> String -> m ()
forall a. HasCallStack => String -> a
error (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"tried to write integral attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" but the attribute is not an integral type"
writeIntegralSpectrumAttribute :: (MonadUnliftIO m, Integral i) => DeviceProxy -> AttributeName -> [i] -> m ()
writeIntegralSpectrumAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i) =>
DeviceProxy -> AttributeName -> [i] -> m ()
writeIntegralSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [i]
newValues = do
AttributeInfo
config <- DeviceProxy -> AttributeName -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName
case AttributeInfo -> HaskellTangoDataType
attributeInfoDataType AttributeInfo
config of
HaskellTangoDataType
HaskellDevVarShortArray ->
DeviceProxy -> AttributeName -> [Int16] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Int16] -> m ()
writeShortSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Int16) -> [i] -> [Int16]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
HaskellDevVarUShortArray ->
DeviceProxy -> AttributeName -> [Word16] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Word16] -> m ()
writeUShortSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Word16) -> [i] -> [Word16]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
HaskellDevVarLongArray ->
DeviceProxy -> AttributeName -> [Int64] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Int64] -> m ()
writeLongSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Int64) -> [i] -> [Int64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
HaskellDevVarULongArray ->
DeviceProxy -> AttributeName -> [Word64] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Word64] -> m ()
writeULongSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Word64) -> [i] -> [Word64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
HaskellDevVarLong64Array ->
DeviceProxy -> AttributeName -> [Int64] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Int64] -> m ()
writeLong64SpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Int64) -> [i] -> [Int64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
HaskellDevVarULong64Array ->
DeviceProxy -> AttributeName -> [Word64] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Word64] -> m ()
writeULong64SpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Word64) -> [i] -> [Word64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
_ -> String -> m ()
forall a. HasCallStack => String -> a
error (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"tried to write integral attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" but the attribute is not an integral type"
writeIntegralImageAttribute :: (MonadUnliftIO m, Integral i) => DeviceProxy -> AttributeName -> Image i -> m ()
writeIntegralImageAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i) =>
DeviceProxy -> AttributeName -> Image i -> m ()
writeIntegralImageAttribute DeviceProxy
proxy AttributeName
attributeName Image i
newValues = do
AttributeInfo
config <- DeviceProxy -> AttributeName -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName
case AttributeInfo -> HaskellTangoDataType
attributeInfoDataType AttributeInfo
config of
HaskellTangoDataType
HaskellDevVarShortArray ->
DeviceProxy -> AttributeName -> Image Int16 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Int16 -> m ()
writeShortImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Int16) -> Image i -> Image Int16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
HaskellDevVarUShortArray ->
DeviceProxy -> AttributeName -> Image Word16 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Word16 -> m ()
writeUShortImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Word16) -> Image i -> Image Word16
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
HaskellDevVarLongArray ->
DeviceProxy -> AttributeName -> Image Int64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Int64 -> m ()
writeLongImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Int64) -> Image i -> Image Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
HaskellDevVarULongArray ->
DeviceProxy -> AttributeName -> Image Word64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Word64 -> m ()
writeULongImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Word64) -> Image i -> Image Word64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
HaskellDevVarLong64Array ->
DeviceProxy -> AttributeName -> Image Int64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Int64 -> m ()
writeLong64ImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Int64) -> Image i -> Image Int64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
HaskellDevVarULong64Array ->
DeviceProxy -> AttributeName -> Image Word64 -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Word64 -> m ()
writeULong64ImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (i -> Word64) -> Image i -> Image Word64
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
_ -> String -> m ()
forall a. HasCallStack => String -> a
error (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"tried to write integral attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" but the attribute is not an integral type"
writeRealImageAttribute :: (MonadUnliftIO m, Real i) => DeviceProxy -> AttributeName -> Image i -> m ()
writeRealImageAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Real i) =>
DeviceProxy -> AttributeName -> Image i -> m ()
writeRealImageAttribute DeviceProxy
proxy AttributeName
attributeName Image i
newValues = do
AttributeInfo
config <- DeviceProxy -> AttributeName -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName
case AttributeInfo -> HaskellTangoDataType
attributeInfoDataType AttributeInfo
config of
HaskellTangoDataType
HaskellDevFloat ->
DeviceProxy -> AttributeName -> Image Double -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Double -> m ()
writeFloatImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (i -> Double) -> Image i -> Image Double
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
HaskellDevDouble ->
DeviceProxy -> AttributeName -> Image Double -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Double -> m ()
writeDoubleImageAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (i -> Double) -> Image i -> Image Double
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image i
newValues)
HaskellTangoDataType
_ -> String -> m ()
forall a. HasCallStack => String -> a
error (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"tried to write real attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" but the attribute is not a real type"
writeRealAttribute :: (MonadUnliftIO m, Real i) => DeviceProxy -> AttributeName -> i -> m ()
writeRealAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Real i) =>
DeviceProxy -> AttributeName -> i -> m ()
writeRealAttribute DeviceProxy
proxy AttributeName
attributeName i
newValue = do
AttributeInfo
config <- DeviceProxy -> AttributeName -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName
case AttributeInfo -> HaskellTangoDataType
attributeInfoDataType AttributeInfo
config of
HaskellTangoDataType
HaskellDevFloat ->
DeviceProxy -> AttributeName -> Double -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Double -> m ()
writeFloatAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac i
newValue)
HaskellTangoDataType
HaskellDevDouble ->
DeviceProxy -> AttributeName -> Double -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Double -> m ()
writeDoubleAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac i
newValue)
HaskellTangoDataType
_ -> String -> m ()
forall a. HasCallStack => String -> a
error (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"tried to write real attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" but the attribute is not a real type"
writeRealSpectrumAttribute :: (MonadUnliftIO m, Real i) => DeviceProxy -> AttributeName -> [i] -> m ()
writeRealSpectrumAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Real i) =>
DeviceProxy -> AttributeName -> [i] -> m ()
writeRealSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [i]
newValues = do
AttributeInfo
config <- DeviceProxy -> AttributeName -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName
case AttributeInfo -> HaskellTangoDataType
attributeInfoDataType AttributeInfo
config of
HaskellTangoDataType
HaskellDevVarFloatArray ->
DeviceProxy -> AttributeName -> [Double] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Double] -> m ()
writeFloatSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (i -> Double) -> [i] -> [Double]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
HaskellDevVarDoubleArray ->
DeviceProxy -> AttributeName -> [Double] -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Double] -> m ()
writeDoubleSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (i -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (i -> Double) -> [i] -> [Double]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [i]
newValues)
HaskellTangoDataType
_ -> String -> m ()
forall a. HasCallStack => String -> a
error (String -> m ()) -> String -> m ()
forall a b. (a -> b) -> a -> b
$ String
"tried to write real attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" but the attribute is not a real type"
writeBoolAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Bool -> m ()
writeBoolAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Bool -> m ()
writeBoolAttribute DeviceProxy
proxy AttributeName
attributeName Bool
newValue =
DeviceProxy
-> AttributeName
-> CBool
-> HaskellTangoDataType
-> (HaskellTangoVarArray CBool -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Bool -> CBool
boolToCBool Bool
newValue) HaskellTangoDataType
HaskellDevBoolean HaskellTangoVarArray CBool -> HaskellTangoAttributeData
HaskellAttributeDataBoolArray
writeBoolSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Bool] -> m ()
writeBoolSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Bool] -> m ()
writeBoolSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Bool]
newValues =
DeviceProxy
-> AttributeName
-> [CBool]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CBool -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Bool -> CBool
boolToCBool (Bool -> CBool) -> [Bool] -> [CBool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Bool]
newValues) HaskellTangoDataType
HaskellDevBoolean HaskellTangoVarArray CBool -> HaskellTangoAttributeData
HaskellAttributeDataBoolArray
writeBoolImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Bool -> m ()
writeBoolImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Bool -> m ()
writeBoolImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Bool
newImage =
DeviceProxy
-> AttributeName
-> Image CBool
-> HaskellTangoDataType
-> (HaskellTangoVarArray CBool -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Bool -> CBool
boolToCBool (Bool -> CBool) -> Image Bool -> Image CBool
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Bool
newImage) HaskellTangoDataType
HaskellDevBoolean HaskellTangoVarArray CBool -> HaskellTangoAttributeData
HaskellAttributeDataBoolArray
writeShortAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Int16 -> m ()
writeShortAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Int16 -> m ()
writeShortAttribute DeviceProxy
proxy AttributeName
attributeName Int16
newValue =
DeviceProxy
-> AttributeName
-> CShort
-> HaskellTangoDataType
-> (HaskellTangoVarArray CShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Int16 -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int16
newValue) HaskellTangoDataType
HaskellDevShort HaskellTangoVarArray CShort -> HaskellTangoAttributeData
HaskellAttributeDataShortArray
writeShortSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Int16] -> m ()
writeShortSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Int16] -> m ()
writeShortSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Int16]
newValues =
DeviceProxy
-> AttributeName
-> [CShort]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Int16 -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int16 -> CShort) -> [Int16] -> [CShort]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int16]
newValues) HaskellTangoDataType
HaskellDevShort HaskellTangoVarArray CShort -> HaskellTangoAttributeData
HaskellAttributeDataShortArray
writeShortImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Int16 -> m ()
writeShortImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Int16 -> m ()
writeShortImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Int16
newImage =
DeviceProxy
-> AttributeName
-> Image CShort
-> HaskellTangoDataType
-> (HaskellTangoVarArray CShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Int16 -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int16 -> CShort) -> Image Int16 -> Image CShort
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Int16
newImage) HaskellTangoDataType
HaskellDevShort HaskellTangoVarArray CShort -> HaskellTangoAttributeData
HaskellAttributeDataShortArray
writeUShortAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Word16 -> m ()
writeUShortAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Word16 -> m ()
writeUShortAttribute DeviceProxy
proxy AttributeName
attributeName Word16
newValue =
DeviceProxy
-> AttributeName
-> CUShort
-> HaskellTangoDataType
-> (HaskellTangoVarArray CUShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Word16 -> CUShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
newValue) HaskellTangoDataType
HaskellDevUShort HaskellTangoVarArray CUShort -> HaskellTangoAttributeData
HaskellAttributeDataUShortArray
writeUShortSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Word16] -> m ()
writeUShortSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Word16] -> m ()
writeUShortSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Word16]
newValues =
DeviceProxy
-> AttributeName
-> [CUShort]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CUShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Word16 -> CUShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> CUShort) -> [Word16] -> [CUShort]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word16]
newValues) HaskellTangoDataType
HaskellDevUShort HaskellTangoVarArray CUShort -> HaskellTangoAttributeData
HaskellAttributeDataUShortArray
writeUShortImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Word16 -> m ()
writeUShortImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Word16 -> m ()
writeUShortImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Word16
newImage =
DeviceProxy
-> AttributeName
-> Image CUShort
-> HaskellTangoDataType
-> (HaskellTangoVarArray CUShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Word16 -> CUShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> CUShort) -> Image Word16 -> Image CUShort
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Word16
newImage) HaskellTangoDataType
HaskellDevUShort HaskellTangoVarArray CUShort -> HaskellTangoAttributeData
HaskellAttributeDataUShortArray
writeLongAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Int64 -> m ()
writeLongAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Int64 -> m ()
writeLongAttribute DeviceProxy
proxy AttributeName
attributeName Int64
newValue =
DeviceProxy
-> AttributeName
-> CLong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CLong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
newValue) HaskellTangoDataType
HaskellDevLong HaskellTangoVarArray CLong -> HaskellTangoAttributeData
HaskellAttributeDataLongArray
writeLongSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Int64] -> m ()
writeLongSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Int64] -> m ()
writeLongSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Int64]
newValues =
DeviceProxy
-> AttributeName
-> [CLong]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CLong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> CLong) -> [Int64] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int64]
newValues) HaskellTangoDataType
HaskellDevLong HaskellTangoVarArray CLong -> HaskellTangoAttributeData
HaskellAttributeDataLongArray
writeLongImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Int64 -> m ()
writeLongImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Int64 -> m ()
writeLongImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Int64
newImage =
DeviceProxy
-> AttributeName
-> Image CLong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CLong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> CLong) -> Image Int64 -> Image CLong
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Int64
newImage) HaskellTangoDataType
HaskellDevLong HaskellTangoVarArray CLong -> HaskellTangoAttributeData
HaskellAttributeDataLongArray
writeULongAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Word64 -> m ()
writeULongAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Word64 -> m ()
writeULongAttribute DeviceProxy
proxy AttributeName
attributeName Word64
newValue =
DeviceProxy
-> AttributeName
-> CULong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CULong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
newValue) HaskellTangoDataType
HaskellDevULong HaskellTangoVarArray CULong -> HaskellTangoAttributeData
HaskellAttributeDataULongArray
writeULongSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Word64] -> m ()
writeULongSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Word64] -> m ()
writeULongSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Word64]
newValues =
DeviceProxy
-> AttributeName
-> [CULong]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CULong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> CULong) -> [Word64] -> [CULong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word64]
newValues) HaskellTangoDataType
HaskellDevULong HaskellTangoVarArray CULong -> HaskellTangoAttributeData
HaskellAttributeDataULongArray
writeULongImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Word64 -> m ()
writeULongImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Word64 -> m ()
writeULongImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Word64
newImage =
DeviceProxy
-> AttributeName
-> Image CULong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CULong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> CULong) -> Image Word64 -> Image CULong
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Word64
newImage) HaskellTangoDataType
HaskellDevULong HaskellTangoVarArray CULong -> HaskellTangoAttributeData
HaskellAttributeDataULongArray
writeULong64Attribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Word64 -> m ()
writeULong64Attribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Word64 -> m ()
writeULong64Attribute DeviceProxy
proxy AttributeName
attributeName Word64
newValue =
DeviceProxy
-> AttributeName
-> CULong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CULong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
newValue) HaskellTangoDataType
HaskellDevULong64 HaskellTangoVarArray CULong -> HaskellTangoAttributeData
HaskellAttributeDataULong64Array
writeULong64SpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Word64] -> m ()
writeULong64SpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Word64] -> m ()
writeULong64SpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Word64]
newValues =
DeviceProxy
-> AttributeName
-> [CULong]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CULong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> CULong) -> [Word64] -> [CULong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word64]
newValues) HaskellTangoDataType
HaskellDevULong64 HaskellTangoVarArray CULong -> HaskellTangoAttributeData
HaskellAttributeDataULong64Array
writeULong64ImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Word64 -> m ()
writeULong64ImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Word64 -> m ()
writeULong64ImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Word64
newImage =
DeviceProxy
-> AttributeName
-> Image CULong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CULong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> CULong) -> Image Word64 -> Image CULong
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Word64
newImage) HaskellTangoDataType
HaskellDevULong64 HaskellTangoVarArray CULong -> HaskellTangoAttributeData
HaskellAttributeDataULong64Array
writeFloatAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Double -> m ()
writeFloatAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Double -> m ()
writeFloatAttribute DeviceProxy
proxy AttributeName
attributeName Double
newValue =
DeviceProxy
-> AttributeName
-> CFloat
-> HaskellTangoDataType
-> (HaskellTangoVarArray CFloat -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Double -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
newValue) HaskellTangoDataType
HaskellDevFloat HaskellTangoVarArray CFloat -> HaskellTangoAttributeData
HaskellAttributeDataFloatArray
writeFloatSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Double] -> m ()
writeFloatSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Double] -> m ()
writeFloatSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Double]
newValues =
DeviceProxy
-> AttributeName
-> [CFloat]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CFloat -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Double -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Double -> CFloat) -> [Double] -> [CFloat]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Double]
newValues) HaskellTangoDataType
HaskellDevFloat HaskellTangoVarArray CFloat -> HaskellTangoAttributeData
HaskellAttributeDataFloatArray
writeFloatImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Double -> m ()
writeFloatImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Double -> m ()
writeFloatImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Double
newImage =
DeviceProxy
-> AttributeName
-> Image CFloat
-> HaskellTangoDataType
-> (HaskellTangoVarArray CFloat -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Double -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Double -> CFloat) -> Image Double -> Image CFloat
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Double
newImage) HaskellTangoDataType
HaskellDevFloat HaskellTangoVarArray CFloat -> HaskellTangoAttributeData
HaskellAttributeDataFloatArray
writeDoubleAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Double -> m ()
writeDoubleAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Double -> m ()
writeDoubleAttribute DeviceProxy
proxy AttributeName
attributeName Double
newValue =
DeviceProxy
-> AttributeName
-> CDouble
-> HaskellTangoDataType
-> (HaskellTangoVarArray CDouble -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
newValue) HaskellTangoDataType
HaskellDevDouble HaskellTangoVarArray CDouble -> HaskellTangoAttributeData
HaskellAttributeDataDoubleArray
writeDoubleSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Double] -> m ()
writeDoubleSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Double] -> m ()
writeDoubleSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Double]
newValues =
DeviceProxy
-> AttributeName
-> [CDouble]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CDouble -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Double -> CDouble) -> [Double] -> [CDouble]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Double]
newValues) HaskellTangoDataType
HaskellDevDouble HaskellTangoVarArray CDouble -> HaskellTangoAttributeData
HaskellAttributeDataDoubleArray
writeDoubleImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Double -> m ()
writeDoubleImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Double -> m ()
writeDoubleImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Double
newImage =
DeviceProxy
-> AttributeName
-> Image CDouble
-> HaskellTangoDataType
-> (HaskellTangoVarArray CDouble -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Double -> CDouble) -> Image Double -> Image CDouble
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Double
newImage) HaskellTangoDataType
HaskellDevDouble HaskellTangoVarArray CDouble -> HaskellTangoAttributeData
HaskellAttributeDataDoubleArray
writeStateAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> HaskellTangoDevState -> m ()
writeStateAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> HaskellTangoDevState -> m ()
writeStateAttribute DeviceProxy
proxy AttributeName
attributeName HaskellTangoDevState
newValue =
DeviceProxy
-> AttributeName
-> HaskellTangoDevState
-> HaskellTangoDataType
-> (HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName HaskellTangoDevState
newValue HaskellTangoDataType
HaskellDevState HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoAttributeData
HaskellAttributeDataStateArray
writeStateSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [HaskellTangoDevState] -> m ()
writeStateSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [HaskellTangoDevState] -> m ()
writeStateSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [HaskellTangoDevState]
newValues =
DeviceProxy
-> AttributeName
-> [HaskellTangoDevState]
-> HaskellTangoDataType
-> (HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [HaskellTangoDevState]
newValues HaskellTangoDataType
HaskellDevState HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoAttributeData
HaskellAttributeDataStateArray
writeStateImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image HaskellTangoDevState -> m ()
writeStateImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image HaskellTangoDevState -> m ()
writeStateImageAttribute DeviceProxy
proxy AttributeName
attributeName Image HaskellTangoDevState
newImage =
DeviceProxy
-> AttributeName
-> Image HaskellTangoDevState
-> HaskellTangoDataType
-> (HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName Image HaskellTangoDevState
newImage HaskellTangoDataType
HaskellDevState HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoAttributeData
HaskellAttributeDataStateArray
writeEnumAttribute :: (MonadUnliftIO m, Enum t) => DeviceProxy -> AttributeName -> t -> m ()
writeEnumAttribute :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> AttributeName -> t -> m ()
writeEnumAttribute DeviceProxy
proxy AttributeName
attributeName t
newValue =
DeviceProxy
-> AttributeName
-> CShort
-> HaskellTangoDataType
-> (HaskellTangoVarArray CShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Int -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (t -> Int
forall a. Enum a => a -> Int
fromEnum t
newValue)) HaskellTangoDataType
HaskellDevEnum HaskellTangoVarArray CShort -> HaskellTangoAttributeData
HaskellAttributeDataShortArray
writeEnumSpectrumAttribute :: (MonadUnliftIO m, Enum t) => DeviceProxy -> AttributeName -> [t] -> m ()
writeEnumSpectrumAttribute :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> AttributeName -> [t] -> m ()
writeEnumSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [t]
newValues =
DeviceProxy
-> AttributeName
-> [CShort]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Int -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CShort) -> (t -> Int) -> t -> CShort
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> Int
forall a. Enum a => a -> Int
fromEnum (t -> CShort) -> [t] -> [CShort]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [t]
newValues) HaskellTangoDataType
HaskellDevEnum HaskellTangoVarArray CShort -> HaskellTangoAttributeData
HaskellAttributeDataShortArray
writeEnumImageAttribute :: (MonadUnliftIO m, Enum t) => DeviceProxy -> AttributeName -> Image t -> m ()
writeEnumImageAttribute :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> AttributeName -> Image t -> m ()
writeEnumImageAttribute DeviceProxy
proxy AttributeName
attributeName Image t
newImage =
DeviceProxy
-> AttributeName
-> Image CShort
-> HaskellTangoDataType
-> (HaskellTangoVarArray CShort -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Int -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> CShort) -> (t -> Int) -> t -> CShort
forall b c a. (b -> c) -> (a -> b) -> a -> c
. t -> Int
forall a. Enum a => a -> Int
fromEnum (t -> CShort) -> Image t -> Image CShort
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image t
newImage) HaskellTangoDataType
HaskellDevEnum HaskellTangoVarArray CShort -> HaskellTangoAttributeData
HaskellAttributeDataShortArray
writeStringAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Text -> m ()
writeStringAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Text -> m ()
writeStringAttribute (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeName) Text
newValue =
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName \CString
attributeNameC -> do
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
newValue \CString
newValuePtr ->
CString -> (Ptr CString -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with CString
newValuePtr \Ptr CString
newValuePtrPtr ->
HaskellAttributeData -> (Ptr HaskellAttributeData -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
( HaskellAttributeData
{ dataFormat :: HaskellDataFormat
dataFormat = HaskellDataFormat
HaskellScalar,
dataQuality :: HaskellDataQuality
dataQuality = HaskellDataQuality
HaskellValid,
nbRead :: CLong
nbRead = CLong
0,
name :: CString
name = CString
attributeNameC,
dimX :: Int32
dimX = Int32
1,
dimY :: Int32
dimY = Int32
1,
timeStamp :: Timeval
timeStamp = CLong -> CLong -> Timeval
Timeval CLong
0 CLong
0,
dataType :: HaskellTangoDataType
dataType = HaskellTangoDataType
HaskellDevString,
tangoAttributeData :: HaskellTangoAttributeData
tangoAttributeData = HaskellTangoVarArray CString -> HaskellTangoAttributeData
HaskellAttributeDataStringArray (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray Word32
1 Ptr CString
newValuePtrPtr)
}
)
(IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> (Ptr HaskellAttributeData -> IO ())
-> Ptr HaskellAttributeData
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellAttributeData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr
-> Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack)
tango_write_attribute DeviceProxyPtr
proxyPtr)
writeStringSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Text] -> m ()
writeStringSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Text] -> m ()
writeStringSpectrumAttribute (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeName) [Text]
newValues =
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName \CString
attributeNameC ->
m [CString] -> ([CString] -> m [()]) -> ([CString] -> m ()) -> m ()
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket ((Text -> m CString) -> [Text] -> m [CString]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (String -> m CString) -> (Text -> String) -> Text -> m CString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack) [Text]
newValues) ((CString -> m ()) -> [CString] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m ()
forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free) \[CString]
stringPointerList ->
[CString] -> (Ptr CString -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [CString]
stringPointerList \Ptr CString
stringPointerPtr ->
HaskellAttributeData -> (Ptr HaskellAttributeData -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
( HaskellAttributeData
{ dataFormat :: HaskellDataFormat
dataFormat = HaskellDataFormat
HaskellSpectrum,
dataQuality :: HaskellDataQuality
dataQuality = HaskellDataQuality
HaskellValid,
nbRead :: CLong
nbRead = CLong
0,
name :: CString
name = CString
attributeNameC,
dimX :: Int32
dimX = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
newValues),
dimY :: Int32
dimY = Int32
1,
timeStamp :: Timeval
timeStamp = CLong -> CLong -> Timeval
Timeval CLong
0 CLong
0,
dataType :: HaskellTangoDataType
dataType = HaskellTangoDataType
HaskellDevString,
tangoAttributeData :: HaskellTangoAttributeData
tangoAttributeData = HaskellTangoVarArray CString -> HaskellTangoAttributeData
HaskellAttributeDataStringArray (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
newValues)) Ptr CString
stringPointerPtr)
}
)
(IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> (Ptr HaskellAttributeData -> IO ())
-> Ptr HaskellAttributeData
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellAttributeData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr
-> Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack)
tango_write_attribute DeviceProxyPtr
proxyPtr)
writeStringImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Text -> m ()
writeStringImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Text -> m ()
writeStringImageAttribute (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeName) (Image [Text]
newImage Int
imageX Int
imageY) =
Text -> (CString -> m ()) -> m ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName \CString
attributeNameC ->
m [CString] -> ([CString] -> m [()]) -> ([CString] -> m ()) -> m ()
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket ((Text -> m CString) -> [Text] -> m [CString]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (String -> m CString) -> (Text -> String) -> Text -> m CString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack) [Text]
newImage) ((CString -> m ()) -> [CString] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m ()
forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free) \[CString]
stringPointerList ->
[CString] -> (Ptr CString -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [CString]
stringPointerList \Ptr CString
stringPointerPtr ->
HaskellAttributeData -> (Ptr HaskellAttributeData -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
( HaskellAttributeData
{ dataFormat :: HaskellDataFormat
dataFormat = HaskellDataFormat
HaskellSpectrum,
dataQuality :: HaskellDataQuality
dataQuality = HaskellDataQuality
HaskellValid,
nbRead :: CLong
nbRead = CLong
0,
name :: CString
name = CString
attributeNameC,
dimX :: Int32
dimX = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
imageX,
dimY :: Int32
dimY = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
imageY,
timeStamp :: Timeval
timeStamp = CLong -> CLong -> Timeval
Timeval CLong
0 CLong
0,
dataType :: HaskellTangoDataType
dataType = HaskellTangoDataType
HaskellDevString,
tangoAttributeData :: HaskellTangoAttributeData
tangoAttributeData = HaskellTangoVarArray CString -> HaskellTangoAttributeData
HaskellAttributeDataStringArray (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int
imageX Int -> Int -> Int
forall a. Num a => a -> a -> a
* Int
imageY)) Ptr CString
stringPointerPtr)
}
)
(IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ())
-> (Ptr HaskellAttributeData -> IO ())
-> Ptr HaskellAttributeData
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellAttributeData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr
-> Ptr HaskellAttributeData -> IO (Ptr HaskellErrorStack)
tango_write_attribute DeviceProxyPtr
proxyPtr)
writeLong64Attribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Int64 -> m ()
writeLong64Attribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Int64 -> m ()
writeLong64Attribute DeviceProxy
proxy AttributeName
attributeName Int64
newValue =
DeviceProxy
-> AttributeName
-> CLong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CLong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeScalarAttribute DeviceProxy
proxy AttributeName
attributeName (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
newValue) HaskellTangoDataType
HaskellDevLong64 HaskellTangoVarArray CLong -> HaskellTangoAttributeData
HaskellAttributeDataLong64Array
writeLong64SpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> [Int64] -> m ()
writeLong64SpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> [Int64] -> m ()
writeLong64SpectrumAttribute DeviceProxy
proxy AttributeName
attributeName [Int64]
newValues =
DeviceProxy
-> AttributeName
-> [CLong]
-> HaskellTangoDataType
-> (HaskellTangoVarArray CLong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> [tangoType]
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeSpectrumAttribute DeviceProxy
proxy AttributeName
attributeName (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> CLong) -> [Int64] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int64]
newValues) HaskellTangoDataType
HaskellDevLong64 HaskellTangoVarArray CLong -> HaskellTangoAttributeData
HaskellAttributeDataLong64Array
writeLong64ImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Image Int64 -> m ()
writeLong64ImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Image Int64 -> m ()
writeLong64ImageAttribute DeviceProxy
proxy AttributeName
attributeName Image Int64
newImage =
DeviceProxy
-> AttributeName
-> Image CLong
-> HaskellTangoDataType
-> (HaskellTangoVarArray CLong -> HaskellTangoAttributeData)
-> m ()
forall (m :: * -> *) tangoType.
(MonadUnliftIO m, Storable tangoType) =>
DeviceProxy
-> AttributeName
-> Image tangoType
-> HaskellTangoDataType
-> (HaskellTangoVarArray tangoType -> HaskellTangoAttributeData)
-> m ()
writeImageAttribute DeviceProxy
proxy AttributeName
attributeName (Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> CLong) -> Image Int64 -> Image CLong
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> Image Int64
newImage) HaskellTangoDataType
HaskellDevLong64 HaskellTangoVarArray CLong -> HaskellTangoAttributeData
HaskellAttributeDataLong64Array
newtype AttributeName = AttributeName Text deriving (Int -> AttributeName -> ShowS
[AttributeName] -> ShowS
AttributeName -> String
(Int -> AttributeName -> ShowS)
-> (AttributeName -> String)
-> ([AttributeName] -> ShowS)
-> Show AttributeName
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AttributeName -> ShowS
showsPrec :: Int -> AttributeName -> ShowS
$cshow :: AttributeName -> String
show :: AttributeName -> String
$cshowList :: [AttributeName] -> ShowS
showList :: [AttributeName] -> ShowS
Show)
withReadAttribute :: (MonadUnliftIO m) => DeviceProxyPtr -> CString -> (HaskellAttributeData -> m a) -> m a
withReadAttribute :: forall (m :: * -> *) a.
MonadUnliftIO m =>
DeviceProxyPtr -> CString -> (HaskellAttributeData -> m a) -> m a
withReadAttribute DeviceProxyPtr
proxyPtr CString
attributeNameC HaskellAttributeData -> m a
f = (Ptr HaskellAttributeData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr HaskellAttributeData
haskellAttributeDataPtr -> do
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString
-> Ptr HaskellAttributeData
-> IO (Ptr HaskellErrorStack)
tango_read_attribute DeviceProxyPtr
proxyPtr CString
attributeNameC Ptr HaskellAttributeData
haskellAttributeDataPtr)
HaskellAttributeData
haskellAttributeData <- IO HaskellAttributeData -> m HaskellAttributeData
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO HaskellAttributeData -> m HaskellAttributeData)
-> IO HaskellAttributeData -> m HaskellAttributeData
forall a b. (a -> b) -> a -> b
$ Ptr HaskellAttributeData -> IO HaskellAttributeData
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellAttributeData
haskellAttributeDataPtr
m a -> m () -> m a
forall (m :: * -> *) a b. MonadUnliftIO m => m a -> m b -> m a
finally (HaskellAttributeData -> m a
f HaskellAttributeData
haskellAttributeData) (IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Ptr HaskellAttributeData -> IO ()
tango_free_AttributeData Ptr HaskellAttributeData
haskellAttributeDataPtr)
withExtractedAttributeValue :: (MonadUnliftIO m) => (HaskellAttributeData -> m (Maybe a)) -> DeviceProxy -> AttributeName -> (a -> m b) -> m b
HaskellAttributeData -> m (Maybe a)
extractValue (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeNameHaskell) a -> m b
f =
Text -> (CString -> m b) -> m b
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeNameHaskell ((CString -> m b) -> m b) -> (CString -> m b) -> m b
forall a b. (a -> b) -> a -> b
$ \CString
attributeNameC -> DeviceProxyPtr -> CString -> (HaskellAttributeData -> m b) -> m b
forall (m :: * -> *) a.
MonadUnliftIO m =>
DeviceProxyPtr -> CString -> (HaskellAttributeData -> m a) -> m a
withReadAttribute DeviceProxyPtr
proxyPtr CString
attributeNameC \HaskellAttributeData
haskellAttributeData -> do
Maybe a
extractedValue <- HaskellAttributeData -> m (Maybe a)
extractValue HaskellAttributeData
haskellAttributeData
case Maybe a
extractedValue of
Maybe a
Nothing -> String -> m b
forall a. HasCallStack => String -> a
error (String
"invalid type for attribute \"" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack Text
attributeNameHaskell String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"\"")
Just a
v -> a -> m b
f a
v
readAttributeGeneral :: (MonadIO m) => (HaskellAttributeData -> IO (Maybe a)) -> DeviceProxy -> AttributeName -> m a
readAttributeGeneral :: forall (m :: * -> *) a.
MonadIO m =>
(HaskellAttributeData -> IO (Maybe a))
-> DeviceProxy -> AttributeName -> m a
readAttributeGeneral HaskellAttributeData -> IO (Maybe a)
extractValue (DeviceProxy DeviceProxyPtr
proxyPtr) (AttributeName Text
attributeNameHaskell) =
IO a -> m a
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO a -> m a) -> IO a -> m a
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO a) -> IO a
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeNameHaskell ((CString -> IO a) -> IO a) -> (CString -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \CString
attributeName -> do
(Ptr HaskellAttributeData -> IO a) -> IO a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca ((Ptr HaskellAttributeData -> IO a) -> IO a)
-> (Ptr HaskellAttributeData -> IO a) -> IO a
forall a b. (a -> b) -> a -> b
$ \Ptr HaskellAttributeData
haskellAttributeDataPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString
-> Ptr HaskellAttributeData
-> IO (Ptr HaskellErrorStack)
tango_read_attribute DeviceProxyPtr
proxyPtr CString
attributeName Ptr HaskellAttributeData
haskellAttributeDataPtr)
HaskellAttributeData
haskellAttributeData <- Ptr HaskellAttributeData -> IO HaskellAttributeData
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellAttributeData
haskellAttributeDataPtr
Maybe a
extractedValue <- HaskellAttributeData -> IO (Maybe a)
extractValue HaskellAttributeData
haskellAttributeData
case Maybe a
extractedValue of
Maybe a
Nothing -> String -> IO a
forall a. HasCallStack => String -> a
error (String
"invalid type for attribute \"" String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Text -> String
unpack Text
attributeNameHaskell String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"\"")
Just a
v ->
a -> IO a
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure a
v
data AtLeastTwo a = AtLeastTwo a a [a]
readAttributeSimple ::
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a)) ->
(HaskellAttributeData -> AtLeastTwo a -> m b) ->
DeviceProxy ->
AttributeName ->
m b
readAttributeSimple :: forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a)
extractValue HaskellAttributeData -> AtLeastTwo a -> m b
convertValue DeviceProxy
proxy AttributeName
attributeName = (HaskellAttributeData
-> m (Maybe (HaskellAttributeData, HaskellTangoVarArray a)))
-> DeviceProxy
-> AttributeName
-> ((HaskellAttributeData, HaskellTangoVarArray a) -> m b)
-> m b
forall (m :: * -> *) a b.
MonadUnliftIO m =>
(HaskellAttributeData -> m (Maybe a))
-> DeviceProxy -> AttributeName -> (a -> m b) -> m b
withExtractedAttributeValue (\HaskellAttributeData
d -> Maybe (HaskellAttributeData, HaskellTangoVarArray a)
-> m (Maybe (HaskellAttributeData, HaskellTangoVarArray a))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ((HaskellAttributeData
d,) (HaskellTangoVarArray a
-> (HaskellAttributeData, HaskellTangoVarArray a))
-> Maybe (HaskellTangoVarArray a)
-> Maybe (HaskellAttributeData, HaskellTangoVarArray a)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a)
extractValue (HaskellAttributeData -> HaskellTangoAttributeData
tangoAttributeData HaskellAttributeData
d))) DeviceProxy
proxy AttributeName
attributeName \(HaskellAttributeData
attributeData, HaskellTangoVarArray a
tangoArray) -> do
[a]
arrayElements <- Int -> Ptr a -> m [a]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellTangoVarArray a -> Word32
forall a. HaskellTangoVarArray a -> Word32
varArrayLength HaskellTangoVarArray a
tangoArray)) (HaskellTangoVarArray a -> Ptr a
forall a. HaskellTangoVarArray a -> Ptr a
varArrayValues HaskellTangoVarArray a
tangoArray)
case [a]
arrayElements of
(a
first : a
second : [a]
rest) -> HaskellAttributeData -> AtLeastTwo a -> m b
convertValue HaskellAttributeData
attributeData (a -> a -> [a] -> AtLeastTwo a
forall a. a -> a -> [a] -> AtLeastTwo a
AtLeastTwo a
first a
second [a]
rest)
[a]
_ -> String -> m b
forall a. HasCallStack => String -> a
error (String -> m b) -> String -> m b
forall a b. (a -> b) -> a -> b
$ String
"couldn't read attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
": expected a value array of length at least two, but got " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [a] -> String
forall a. Show a => a -> String
show [a]
arrayElements
readAttributeSimple' ::
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a])) ->
(HaskellAttributeData -> AtLeastTwo a -> m b) ->
DeviceProxy ->
AttributeName ->
m b
readAttributeSimple' :: forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [a])
extractValue HaskellAttributeData -> AtLeastTwo a -> m b
convertValue DeviceProxy
proxy AttributeName
attributeName = do
(HaskellAttributeData
attributeData, [a]
tangoArray) <- (HaskellAttributeData -> IO (Maybe (HaskellAttributeData, [a])))
-> DeviceProxy -> AttributeName -> m (HaskellAttributeData, [a])
forall (m :: * -> *) a.
MonadIO m =>
(HaskellAttributeData -> IO (Maybe a))
-> DeviceProxy -> AttributeName -> m a
readAttributeGeneral (\HaskellAttributeData
d -> ((HaskellAttributeData
d,) ([a] -> (HaskellAttributeData, [a]))
-> Maybe [a] -> Maybe (HaskellAttributeData, [a])
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (Maybe [a] -> Maybe (HaskellAttributeData, [a]))
-> IO (Maybe [a]) -> IO (Maybe (HaskellAttributeData, [a]))
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoAttributeData -> IO (Maybe [a])
extractValue (HaskellAttributeData -> HaskellTangoAttributeData
tangoAttributeData HaskellAttributeData
d)) DeviceProxy
proxy AttributeName
attributeName
case [a]
tangoArray of
(a
first : a
second : [a]
rest) -> HaskellAttributeData -> AtLeastTwo a -> m b
convertValue HaskellAttributeData
attributeData (a -> a -> [a] -> AtLeastTwo a
forall a. a -> a -> [a] -> AtLeastTwo a
AtLeastTwo a
first a
second [a]
rest)
[a]
_ -> String -> m b
forall a. HasCallStack => String -> a
error (String -> m b) -> String -> m b
forall a b. (a -> b) -> a -> b
$ String
"couldn't read attribute " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> AttributeName -> String
forall a. Show a => a -> String
show AttributeName
attributeName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
": expected a value array of length at least two, but got " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> [a] -> String
forall a. Show a => a -> String
show [a]
tangoArray
convertGenericScalar :: (Applicative f) => (a -> b) -> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar :: forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar a -> b
f HaskellAttributeData
_ (AtLeastTwo a
first a
second [a]
_) = TangoValue b -> f (TangoValue b)
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (b -> b -> TangoValue b
forall a. a -> a -> TangoValue a
TangoValue (a -> b
f a
first) (a -> b
f a
second))
convertGenericSpectrum :: (Applicative f) => (a -> b) -> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum :: forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum a -> b
f (HaskellAttributeData {Int32
dimX :: HaskellAttributeData -> Int32
dimX :: Int32
dimX}) (AtLeastTwo a
first a
second [a]
remainder) =
let wholeList :: [b]
wholeList = a -> b
f (a -> b) -> [a] -> [b]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a
first a -> [a] -> [a]
forall a. a -> [a] -> [a]
: a
second a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
remainder)
([b]
readValue, [b]
writeValue) = Int -> [b] -> ([b], [b])
forall a. Int -> [a] -> ([a], [a])
splitAt (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) [b]
wholeList
in TangoValue [b] -> f (TangoValue [b])
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([b] -> [b] -> TangoValue [b]
forall a. a -> a -> TangoValue a
TangoValue [b]
readValue [b]
writeValue)
convertGenericSpectrum' :: (Applicative f) => HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [a])
convertGenericSpectrum' :: forall (f :: * -> *) a.
Applicative f =>
HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [a])
convertGenericSpectrum' (HaskellAttributeData {Int32
dimX :: HaskellAttributeData -> Int32
dimX :: Int32
dimX}) (AtLeastTwo a
first a
second [a]
remainder) =
let wholeList :: [a]
wholeList = a
first a -> [a] -> [a]
forall a. a -> [a] -> [a]
: a
second a -> [a] -> [a]
forall a. a -> [a] -> [a]
: [a]
remainder
([a]
readValue, [a]
writeValue) = Int -> [a] -> ([a], [a])
forall a. Int -> [a] -> ([a], [a])
splitAt (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) [a]
wholeList
in TangoValue [a] -> f (TangoValue [a])
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([a] -> [a] -> TangoValue [a]
forall a. a -> a -> TangoValue a
TangoValue [a]
readValue [a]
writeValue)
convertGenericImage :: (Applicative f) => (a1 -> a2) -> HaskellAttributeData -> AtLeastTwo a1 -> f (TangoValue (Image a2))
convertGenericImage :: forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage a1 -> a2
f (HaskellAttributeData {Int32
dimX :: HaskellAttributeData -> Int32
dimX :: Int32
dimX, Int32
dimY :: HaskellAttributeData -> Int32
dimY :: Int32
dimY}) (AtLeastTwo a1
first a1
second [a1]
remainder) =
let wholeList :: [a2]
wholeList = a1 -> a2
f (a1 -> a2) -> [a1] -> [a2]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> (a1
first a1 -> [a1] -> [a1]
forall a. a -> [a] -> [a]
: a1
second a1 -> [a1] -> [a1]
forall a. a -> [a] -> [a]
: [a1]
remainder)
([a2]
readValue, [a2]
writeValue) = Int -> [a2] -> ([a2], [a2])
forall a. Int -> [a] -> ([a], [a])
splitAt (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int32
dimX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
dimY)) [a2]
wholeList
in TangoValue (Image a2) -> f (TangoValue (Image a2))
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( Image a2 -> Image a2 -> TangoValue (Image a2)
forall a. a -> a -> TangoValue a
TangoValue
([a2] -> Int -> Int -> Image a2
forall a. [a] -> Int -> Int -> Image a
Image [a2]
readValue (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimY))
([a2] -> Int -> Int -> Image a2
forall a. [a] -> Int -> Int -> Image a
Image [a2]
writeValue (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimY))
)
convertGenericImage' :: (Applicative f) => HaskellAttributeData -> AtLeastTwo a1 -> f (TangoValue (Image a1))
convertGenericImage' :: forall (f :: * -> *) a1.
Applicative f =>
HaskellAttributeData -> AtLeastTwo a1 -> f (TangoValue (Image a1))
convertGenericImage' (HaskellAttributeData {Int32
dimX :: HaskellAttributeData -> Int32
dimX :: Int32
dimX, Int32
dimY :: HaskellAttributeData -> Int32
dimY :: Int32
dimY}) (AtLeastTwo a1
first a1
second [a1]
remainder) =
let wholeList :: [a1]
wholeList = a1
first a1 -> [a1] -> [a1]
forall a. a -> [a] -> [a]
: a1
second a1 -> [a1] -> [a1]
forall a. a -> [a] -> [a]
: [a1]
remainder
([a1]
readValue, [a1]
writeValue) = Int -> [a1] -> ([a1], [a1])
forall a. Int -> [a] -> ([a], [a])
splitAt (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int32
dimX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
dimY)) [a1]
wholeList
in TangoValue (Image a1) -> f (TangoValue (Image a1))
forall a. a -> f a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( Image a1 -> Image a1 -> TangoValue (Image a1)
forall a. a -> a -> TangoValue a
TangoValue
([a1] -> Int -> Int -> Image a1
forall a. [a] -> Int -> Int -> Image a
Image [a1]
readValue (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimY))
([a1] -> Int -> Int -> Image a1
forall a. [a] -> Int -> Int -> Image a
Image [a1]
writeValue (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimY))
)
data TangoValue a = TangoValue
{
forall a. TangoValue a -> a
tangoValueRead :: a,
forall a. TangoValue a -> a
tangoValueWrite :: a
}
deriving (Int -> TangoValue a -> ShowS
[TangoValue a] -> ShowS
TangoValue a -> String
(Int -> TangoValue a -> ShowS)
-> (TangoValue a -> String)
-> ([TangoValue a] -> ShowS)
-> Show (TangoValue a)
forall a. Show a => Int -> TangoValue a -> ShowS
forall a. Show a => [TangoValue a] -> ShowS
forall a. Show a => TangoValue a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> TangoValue a -> ShowS
showsPrec :: Int -> TangoValue a -> ShowS
$cshow :: forall a. Show a => TangoValue a -> String
show :: TangoValue a -> String
$cshowList :: forall a. Show a => [TangoValue a] -> ShowS
showList :: [TangoValue a] -> ShowS
Show)
data Image a = Image
{
forall a. Image a -> [a]
imageContent :: ![a],
forall a. Image a -> Int
imageDimX :: !Int,
forall a. Image a -> Int
imageDimY :: !Int
}
deriving (Int -> Image a -> ShowS
[Image a] -> ShowS
Image a -> String
(Int -> Image a -> ShowS)
-> (Image a -> String) -> ([Image a] -> ShowS) -> Show (Image a)
forall a. Show a => Int -> Image a -> ShowS
forall a. Show a => [Image a] -> ShowS
forall a. Show a => Image a -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall a. Show a => Int -> Image a -> ShowS
showsPrec :: Int -> Image a -> ShowS
$cshow :: forall a. Show a => Image a -> String
show :: Image a -> String
$cshowList :: forall a. Show a => [Image a] -> ShowS
showList :: [Image a] -> ShowS
Show, (forall a b. (a -> b) -> Image a -> Image b)
-> (forall a b. a -> Image b -> Image a) -> Functor Image
forall a b. a -> Image b -> Image a
forall a b. (a -> b) -> Image a -> Image b
forall (f :: * -> *).
(forall a b. (a -> b) -> f a -> f b)
-> (forall a b. a -> f b -> f a) -> Functor f
$cfmap :: forall a b. (a -> b) -> Image a -> Image b
fmap :: forall a b. (a -> b) -> Image a -> Image b
$c<$ :: forall a b. a -> Image b -> Image a
<$ :: forall a b. a -> Image b -> Image a
Functor)
readIntegralAttribute :: forall m i. (MonadUnliftIO m, Integral i, Show i) => DeviceProxy -> AttributeName -> m (TangoValue i)
readIntegralAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i, Show i) =>
DeviceProxy -> AttributeName -> m (TangoValue i)
readIntegralAttribute = (HaskellTangoAttributeData -> IO (Maybe [i]))
-> (HaskellAttributeData -> AtLeastTwo i -> m (TangoValue i))
-> DeviceProxy
-> AttributeName
-> m (TangoValue i)
forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [i])
forall i (m :: * -> *).
(Integral i, MonadUnliftIO m) =>
HaskellTangoAttributeData -> m (Maybe [i])
extractIntegral ((i -> i)
-> HaskellAttributeData -> AtLeastTwo i -> m (TangoValue i)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar i -> i
forall a. a -> a
id)
extractIntegral :: (Integral i, MonadUnliftIO m) => HaskellTangoAttributeData -> m (Maybe [i])
(HaskellAttributeDataLongArray HaskellTangoVarArray CLong
a) = do
[CLong]
arrayElements <- Int -> Ptr CLong -> m [CLong]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellTangoVarArray CLong -> Word32
forall a. HaskellTangoVarArray a -> Word32
varArrayLength HaskellTangoVarArray CLong
a)) (HaskellTangoVarArray CLong -> Ptr CLong
forall a. HaskellTangoVarArray a -> Ptr a
varArrayValues HaskellTangoVarArray CLong
a)
Maybe [i] -> m (Maybe [i])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe [i] -> m (Maybe [i])) -> Maybe [i] -> m (Maybe [i])
forall a b. (a -> b) -> a -> b
$ [i] -> Maybe [i]
forall a. a -> Maybe a
Just (CLong -> i
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CLong -> i) -> [CLong] -> [i]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [CLong]
arrayElements)
extractIntegral HaskellTangoAttributeData
_ = Maybe [i] -> m (Maybe [i])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe [i]
forall a. Maybe a
Nothing
readIntegralSpectrumAttribute :: (MonadUnliftIO m, Integral i, Show i) => DeviceProxy -> AttributeName -> m (TangoValue [i])
readIntegralSpectrumAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i, Show i) =>
DeviceProxy -> AttributeName -> m (TangoValue [i])
readIntegralSpectrumAttribute = (HaskellTangoAttributeData -> IO (Maybe [i]))
-> (HaskellAttributeData -> AtLeastTwo i -> m (TangoValue [i]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [i])
forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [i])
forall i (m :: * -> *).
(Integral i, MonadUnliftIO m) =>
HaskellTangoAttributeData -> m (Maybe [i])
extractIntegral HaskellAttributeData -> AtLeastTwo i -> m (TangoValue [i])
forall (f :: * -> *) a.
Applicative f =>
HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [a])
convertGenericSpectrum'
readIntegralImageAttribute :: (MonadUnliftIO m, Integral i, Show i) => DeviceProxy -> AttributeName -> m (TangoValue (Image i))
readIntegralImageAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i, Show i) =>
DeviceProxy -> AttributeName -> m (TangoValue (Image i))
readIntegralImageAttribute = (HaskellTangoAttributeData -> IO (Maybe [i]))
-> (HaskellAttributeData
-> AtLeastTwo i -> m (TangoValue (Image i)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image i))
forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [i])
forall i (m :: * -> *).
(Integral i, MonadUnliftIO m) =>
HaskellTangoAttributeData -> m (Maybe [i])
extractIntegral HaskellAttributeData -> AtLeastTwo i -> m (TangoValue (Image i))
forall (f :: * -> *) a1.
Applicative f =>
HaskellAttributeData -> AtLeastTwo a1 -> f (TangoValue (Image a1))
convertGenericImage'
extractReal :: (Fractional i, MonadUnliftIO m) => HaskellTangoAttributeData -> m (Maybe [i])
(HaskellAttributeDataDoubleArray HaskellTangoVarArray CDouble
a) = do
[CDouble]
arrayElements <- Int -> Ptr CDouble -> m [CDouble]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellTangoVarArray CDouble -> Word32
forall a. HaskellTangoVarArray a -> Word32
varArrayLength HaskellTangoVarArray CDouble
a)) (HaskellTangoVarArray CDouble -> Ptr CDouble
forall a. HaskellTangoVarArray a -> Ptr a
varArrayValues HaskellTangoVarArray CDouble
a)
Maybe [i] -> m (Maybe [i])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe [i] -> m (Maybe [i])) -> Maybe [i] -> m (Maybe [i])
forall a b. (a -> b) -> a -> b
$ [i] -> Maybe [i]
forall a. a -> Maybe a
Just (CDouble -> i
forall a b. (Real a, Fractional b) => a -> b
realToFrac (CDouble -> i) -> [CDouble] -> [i]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [CDouble]
arrayElements)
extractReal (HaskellAttributeDataFloatArray HaskellTangoVarArray CFloat
a) = do
[CFloat]
arrayElements <- Int -> Ptr CFloat -> m [CFloat]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellTangoVarArray CFloat -> Word32
forall a. HaskellTangoVarArray a -> Word32
varArrayLength HaskellTangoVarArray CFloat
a)) (HaskellTangoVarArray CFloat -> Ptr CFloat
forall a. HaskellTangoVarArray a -> Ptr a
varArrayValues HaskellTangoVarArray CFloat
a)
Maybe [i] -> m (Maybe [i])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe [i] -> m (Maybe [i])) -> Maybe [i] -> m (Maybe [i])
forall a b. (a -> b) -> a -> b
$ [i] -> Maybe [i]
forall a. a -> Maybe a
Just (CFloat -> i
forall a b. (Real a, Fractional b) => a -> b
realToFrac (CFloat -> i) -> [CFloat] -> [i]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [CFloat]
arrayElements)
extractReal HaskellTangoAttributeData
_ = Maybe [i] -> m (Maybe [i])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe [i]
forall a. Maybe a
Nothing
readRealAttribute :: forall m i. (MonadUnliftIO m, Fractional i, Show i) => DeviceProxy -> AttributeName -> m (TangoValue i)
readRealAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Fractional i, Show i) =>
DeviceProxy -> AttributeName -> m (TangoValue i)
readRealAttribute = (HaskellTangoAttributeData -> IO (Maybe [i]))
-> (HaskellAttributeData -> AtLeastTwo i -> m (TangoValue i))
-> DeviceProxy
-> AttributeName
-> m (TangoValue i)
forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [i])
forall i (m :: * -> *).
(Fractional i, MonadUnliftIO m) =>
HaskellTangoAttributeData -> m (Maybe [i])
extractReal ((i -> i)
-> HaskellAttributeData -> AtLeastTwo i -> m (TangoValue i)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar i -> i
forall a. a -> a
id)
readRealSpectrumAttribute :: (MonadUnliftIO m, Fractional i, Show i) => DeviceProxy -> AttributeName -> m (TangoValue [i])
readRealSpectrumAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Fractional i, Show i) =>
DeviceProxy -> AttributeName -> m (TangoValue [i])
readRealSpectrumAttribute = (HaskellTangoAttributeData -> IO (Maybe [i]))
-> (HaskellAttributeData -> AtLeastTwo i -> m (TangoValue [i]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [i])
forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [i])
forall i (m :: * -> *).
(Fractional i, MonadUnliftIO m) =>
HaskellTangoAttributeData -> m (Maybe [i])
extractReal HaskellAttributeData -> AtLeastTwo i -> m (TangoValue [i])
forall (f :: * -> *) a.
Applicative f =>
HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [a])
convertGenericSpectrum'
readRealImageAttribute :: (MonadUnliftIO m, Fractional i, Show i) => DeviceProxy -> AttributeName -> m (TangoValue (Image i))
readRealImageAttribute :: forall (m :: * -> *) i.
(MonadUnliftIO m, Fractional i, Show i) =>
DeviceProxy -> AttributeName -> m (TangoValue (Image i))
readRealImageAttribute = (HaskellTangoAttributeData -> IO (Maybe [i]))
-> (HaskellAttributeData
-> AtLeastTwo i -> m (TangoValue (Image i)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image i))
forall (m :: * -> *) a b.
(MonadIO m, Show a) =>
(HaskellTangoAttributeData -> IO (Maybe [a]))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple' HaskellTangoAttributeData -> IO (Maybe [i])
forall i (m :: * -> *).
(Fractional i, MonadUnliftIO m) =>
HaskellTangoAttributeData -> m (Maybe [i])
extractReal HaskellAttributeData -> AtLeastTwo i -> m (TangoValue (Image i))
forall (f :: * -> *) a1.
Applicative f =>
HaskellAttributeData -> AtLeastTwo a1 -> f (TangoValue (Image a1))
convertGenericImage'
extractBool :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool)
(HaskellAttributeDataBoolArray HaskellTangoVarArray CBool
a) = HaskellTangoVarArray CBool -> Maybe (HaskellTangoVarArray CBool)
forall a. a -> Maybe a
Just HaskellTangoVarArray CBool
a
extractBool HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CBool)
forall a. Maybe a
Nothing
readBoolAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Bool)
readBoolAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Bool)
readBoolAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool))
-> (HaskellAttributeData
-> AtLeastTwo CBool -> m (TangoValue Bool))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Bool)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool)
extractBool ((CBool -> Bool)
-> HaskellAttributeData -> AtLeastTwo CBool -> m (TangoValue Bool)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CBool -> Bool
cboolToBool)
readBoolSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Bool])
readBoolSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Bool])
readBoolSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool))
-> (HaskellAttributeData
-> AtLeastTwo CBool -> m (TangoValue [Bool]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Bool])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool)
extractBool ((CBool -> Bool)
-> HaskellAttributeData
-> AtLeastTwo CBool
-> m (TangoValue [Bool])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CBool -> Bool
cboolToBool)
readBoolImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Bool))
readBoolImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Bool))
readBoolImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool))
-> (HaskellAttributeData
-> AtLeastTwo CBool -> m (TangoValue (Image Bool)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Bool))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CBool)
extractBool ((CBool -> Bool)
-> HaskellAttributeData
-> AtLeastTwo CBool
-> m (TangoValue (Image Bool))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CBool -> Bool
cboolToBool)
readStringAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Text)
readStringAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Text)
readStringAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString))
-> (HaskellAttributeData
-> AtLeastTwo CString -> m (TangoValue Text))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Text)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString)
extract HaskellAttributeData -> AtLeastTwo CString -> m (TangoValue Text)
forall {f :: * -> *} {p}.
MonadUnliftIO f =>
p -> AtLeastTwo CString -> f (TangoValue Text)
convert
where
extract :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString)
extract (HaskellAttributeDataStringArray HaskellTangoVarArray CString
a) = HaskellTangoVarArray CString
-> Maybe (HaskellTangoVarArray CString)
forall a. a -> Maybe a
Just HaskellTangoVarArray CString
a
extract HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CString)
forall a. Maybe a
Nothing
convert :: p -> AtLeastTwo CString -> f (TangoValue Text)
convert p
_ (AtLeastTwo CString
read CString
write []) = Text -> Text -> TangoValue Text
forall a. a -> a -> TangoValue a
TangoValue (Text -> Text -> TangoValue Text)
-> f Text -> f (Text -> TangoValue Text)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> f Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText CString
read f (Text -> TangoValue Text) -> f Text -> f (TangoValue Text)
forall a b. f (a -> b) -> f a -> f b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CString -> f Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText CString
write
convert p
_ AtLeastTwo CString
_ = String -> f (TangoValue Text)
forall a. HasCallStack => String -> a
error String
"expected a read and a write value for attribute, got more elements"
readStringSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Text])
readStringSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Text])
readStringSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString))
-> (HaskellAttributeData
-> AtLeastTwo CString -> m (TangoValue [Text]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Text])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString)
extract HaskellAttributeData -> AtLeastTwo CString -> m (TangoValue [Text])
forall {m :: * -> *}.
MonadUnliftIO m =>
HaskellAttributeData -> AtLeastTwo CString -> m (TangoValue [Text])
convert
where
extract :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString)
extract (HaskellAttributeDataStringArray HaskellTangoVarArray CString
a) = HaskellTangoVarArray CString
-> Maybe (HaskellTangoVarArray CString)
forall a. a -> Maybe a
Just HaskellTangoVarArray CString
a
extract HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CString)
forall a. Maybe a
Nothing
convert :: HaskellAttributeData -> AtLeastTwo CString -> m (TangoValue [Text])
convert (HaskellAttributeData {Int32
dimX :: HaskellAttributeData -> Int32
dimX :: Int32
dimX}) (AtLeastTwo CString
first CString
second [CString]
remainder) = do
[Text]
wholeList <- (CString -> m Text) -> [CString] -> m [Text]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (CString
first CString -> [CString] -> [CString]
forall a. a -> [a] -> [a]
: CString
second CString -> [CString] -> [CString]
forall a. a -> [a] -> [a]
: [CString]
remainder)
let ([Text]
readValue, [Text]
writeValue) = Int -> [Text] -> ([Text], [Text])
forall a. Int -> [a] -> ([a], [a])
splitAt (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) [Text]
wholeList
TangoValue [Text] -> m (TangoValue [Text])
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure ([Text] -> [Text] -> TangoValue [Text]
forall a. a -> a -> TangoValue a
TangoValue [Text]
readValue [Text]
writeValue)
readStringImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Text))
readStringImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Text))
readStringImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString))
-> (HaskellAttributeData
-> AtLeastTwo CString -> m (TangoValue (Image Text)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Text))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString)
extract HaskellAttributeData
-> AtLeastTwo CString -> m (TangoValue (Image Text))
forall {m :: * -> *}.
MonadUnliftIO m =>
HaskellAttributeData
-> AtLeastTwo CString -> m (TangoValue (Image Text))
convert
where
extract :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CString)
extract (HaskellAttributeDataStringArray HaskellTangoVarArray CString
a) = HaskellTangoVarArray CString
-> Maybe (HaskellTangoVarArray CString)
forall a. a -> Maybe a
Just HaskellTangoVarArray CString
a
extract HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CString)
forall a. Maybe a
Nothing
convert :: HaskellAttributeData
-> AtLeastTwo CString -> m (TangoValue (Image Text))
convert (HaskellAttributeData {Int32
dimX :: HaskellAttributeData -> Int32
dimX :: Int32
dimX, Int32
dimY :: HaskellAttributeData -> Int32
dimY :: Int32
dimY}) (AtLeastTwo CString
first CString
second [CString]
remainder) = do
[Text]
wholeList <- (CString -> m Text) -> [CString] -> m [Text]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (CString
first CString -> [CString] -> [CString]
forall a. a -> [a] -> [a]
: CString
second CString -> [CString] -> [CString]
forall a. a -> [a] -> [a]
: [CString]
remainder)
let ([Text]
readValue, [Text]
writeValue) = Int -> [Text] -> ([Text], [Text])
forall a. Int -> [a] -> ([a], [a])
splitAt (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int32
dimX Int32 -> Int32 -> Int32
forall a. Num a => a -> a -> a
* Int32
dimY)) [Text]
wholeList
TangoValue (Image Text) -> m (TangoValue (Image Text))
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
( Image Text -> Image Text -> TangoValue (Image Text)
forall a. a -> a -> TangoValue a
TangoValue
([Text] -> Int -> Int -> Image Text
forall a. [a] -> Int -> Int -> Image a
Image [Text]
readValue (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimY))
([Text] -> Int -> Int -> Image Text
forall a. [a] -> Int -> Int -> Image a
Image [Text]
writeValue (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimX) (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
dimY))
)
extractShort :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
(HaskellAttributeDataShortArray HaskellTangoVarArray CShort
a) = HaskellTangoVarArray CShort -> Maybe (HaskellTangoVarArray CShort)
forall a. a -> Maybe a
Just HaskellTangoVarArray CShort
a
extractShort HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CShort)
forall a. Maybe a
Nothing
readShortAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Int16)
readShortAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Int16)
readShortAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort))
-> (HaskellAttributeData
-> AtLeastTwo CShort -> m (TangoValue Int16))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Int16)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
extractShort ((CShort -> Int16)
-> HaskellAttributeData
-> AtLeastTwo CShort
-> m (TangoValue Int16)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CShort -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readShortSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Int16])
readShortSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Int16])
readShortSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort))
-> (HaskellAttributeData
-> AtLeastTwo CShort -> m (TangoValue [Int16]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Int16])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
extractShort ((CShort -> Int16)
-> HaskellAttributeData
-> AtLeastTwo CShort
-> m (TangoValue [Int16])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CShort -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readShortImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Int16))
readShortImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Int16))
readShortImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort))
-> (HaskellAttributeData
-> AtLeastTwo CShort -> m (TangoValue (Image Int16)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Int16))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
extractShort ((CShort -> Int16)
-> HaskellAttributeData
-> AtLeastTwo CShort
-> m (TangoValue (Image Int16))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CShort -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
extractUShort :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort)
(HaskellAttributeDataUShortArray HaskellTangoVarArray CUShort
a) = HaskellTangoVarArray CUShort
-> Maybe (HaskellTangoVarArray CUShort)
forall a. a -> Maybe a
Just HaskellTangoVarArray CUShort
a
extractUShort HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CUShort)
forall a. Maybe a
Nothing
readUShortAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Word16)
readUShortAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Word16)
readUShortAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort))
-> (HaskellAttributeData
-> AtLeastTwo CUShort -> m (TangoValue Word16))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Word16)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort)
extractUShort ((CUShort -> Word16)
-> HaskellAttributeData
-> AtLeastTwo CUShort
-> m (TangoValue Word16)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CUShort -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readUShortSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Word16])
readUShortSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Word16])
readUShortSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort))
-> (HaskellAttributeData
-> AtLeastTwo CUShort -> m (TangoValue [Word16]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Word16])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort)
extractUShort ((CUShort -> Word16)
-> HaskellAttributeData
-> AtLeastTwo CUShort
-> m (TangoValue [Word16])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CUShort -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readUShortImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Word16))
readUShortImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Word16))
readUShortImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort))
-> (HaskellAttributeData
-> AtLeastTwo CUShort -> m (TangoValue (Image Word16)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Word16))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CUShort)
extractUShort ((CUShort -> Word16)
-> HaskellAttributeData
-> AtLeastTwo CUShort
-> m (TangoValue (Image Word16))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CUShort -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
extractLong :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
(HaskellAttributeDataLongArray HaskellTangoVarArray CLong
a) = HaskellTangoVarArray CLong -> Maybe (HaskellTangoVarArray CLong)
forall a. a -> Maybe a
Just HaskellTangoVarArray CLong
a
extractLong HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CLong)
forall a. Maybe a
Nothing
readLongAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Int64)
readLongAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Int64)
readLongAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong))
-> (HaskellAttributeData
-> AtLeastTwo CLong -> m (TangoValue Int64))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Int64)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
extractLong ((CLong -> Int64)
-> HaskellAttributeData -> AtLeastTwo CLong -> m (TangoValue Int64)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readLongSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Int64])
readLongSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Int64])
readLongSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong))
-> (HaskellAttributeData
-> AtLeastTwo CLong -> m (TangoValue [Int64]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Int64])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
extractLong ((CLong -> Int64)
-> HaskellAttributeData
-> AtLeastTwo CLong
-> m (TangoValue [Int64])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readLongImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Int64))
readLongImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Int64))
readLongImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong))
-> (HaskellAttributeData
-> AtLeastTwo CLong -> m (TangoValue (Image Int64)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Int64))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
extractLong ((CLong -> Int64)
-> HaskellAttributeData
-> AtLeastTwo CLong
-> m (TangoValue (Image Int64))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
extractULong :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
(HaskellAttributeDataULongArray HaskellTangoVarArray CULong
a) = HaskellTangoVarArray CULong -> Maybe (HaskellTangoVarArray CULong)
forall a. a -> Maybe a
Just HaskellTangoVarArray CULong
a
extractULong HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CULong)
forall a. Maybe a
Nothing
readULongAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Word64)
readULongAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Word64)
readULongAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong))
-> (HaskellAttributeData
-> AtLeastTwo CULong -> m (TangoValue Word64))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Word64)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
extractULong ((CULong -> Word64)
-> HaskellAttributeData
-> AtLeastTwo CULong
-> m (TangoValue Word64)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readULongSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Word64])
readULongSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Word64])
readULongSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong))
-> (HaskellAttributeData
-> AtLeastTwo CULong -> m (TangoValue [Word64]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Word64])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
extractULong ((CULong -> Word64)
-> HaskellAttributeData
-> AtLeastTwo CULong
-> m (TangoValue [Word64])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readULongImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Word64))
readULongImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Word64))
readULongImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong))
-> (HaskellAttributeData
-> AtLeastTwo CULong -> m (TangoValue (Image Word64)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Word64))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
extractULong ((CULong -> Word64)
-> HaskellAttributeData
-> AtLeastTwo CULong
-> m (TangoValue (Image Word64))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
extractLong64 :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
(HaskellAttributeDataLong64Array HaskellTangoVarArray CLong
a) = HaskellTangoVarArray CLong -> Maybe (HaskellTangoVarArray CLong)
forall a. a -> Maybe a
Just HaskellTangoVarArray CLong
a
extractLong64 HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CLong)
forall a. Maybe a
Nothing
readLong64Attribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Int64)
readLong64Attribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Int64)
readLong64Attribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong))
-> (HaskellAttributeData
-> AtLeastTwo CLong -> m (TangoValue Int64))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Int64)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
extractLong64 ((CLong -> Int64)
-> HaskellAttributeData -> AtLeastTwo CLong -> m (TangoValue Int64)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readLong64SpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Int64])
readLong64SpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Int64])
readLong64SpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong))
-> (HaskellAttributeData
-> AtLeastTwo CLong -> m (TangoValue [Int64]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Int64])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
extractLong64 ((CLong -> Int64)
-> HaskellAttributeData
-> AtLeastTwo CLong
-> m (TangoValue [Int64])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readLong64ImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Int64))
readLong64ImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Int64))
readLong64ImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong))
-> (HaskellAttributeData
-> AtLeastTwo CLong -> m (TangoValue (Image Int64)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Int64))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CLong)
extractLong64 ((CLong -> Int64)
-> HaskellAttributeData
-> AtLeastTwo CLong
-> m (TangoValue (Image Int64))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
extractULong64 :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
(HaskellAttributeDataULong64Array HaskellTangoVarArray CULong
a) = HaskellTangoVarArray CULong -> Maybe (HaskellTangoVarArray CULong)
forall a. a -> Maybe a
Just HaskellTangoVarArray CULong
a
extractULong64 HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CULong)
forall a. Maybe a
Nothing
readULong64Attribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Word64)
readULong64Attribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Word64)
readULong64Attribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong))
-> (HaskellAttributeData
-> AtLeastTwo CULong -> m (TangoValue Word64))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Word64)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
extractULong64 ((CULong -> Word64)
-> HaskellAttributeData
-> AtLeastTwo CULong
-> m (TangoValue Word64)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readULong64SpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Word64])
readULong64SpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Word64])
readULong64SpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong))
-> (HaskellAttributeData
-> AtLeastTwo CULong -> m (TangoValue [Word64]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Word64])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
extractULong64 ((CULong -> Word64)
-> HaskellAttributeData
-> AtLeastTwo CULong
-> m (TangoValue [Word64])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
readULong64ImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Word64))
readULong64ImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Word64))
readULong64ImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong))
-> (HaskellAttributeData
-> AtLeastTwo CULong -> m (TangoValue (Image Word64)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Word64))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CULong)
extractULong64 ((CULong -> Word64)
-> HaskellAttributeData
-> AtLeastTwo CULong
-> m (TangoValue (Image Word64))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral)
extractFloat :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat)
(HaskellAttributeDataFloatArray HaskellTangoVarArray CFloat
a) = HaskellTangoVarArray CFloat -> Maybe (HaskellTangoVarArray CFloat)
forall a. a -> Maybe a
Just HaskellTangoVarArray CFloat
a
extractFloat HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CFloat)
forall a. Maybe a
Nothing
readFloatAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Double)
readFloatAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Double)
readFloatAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat))
-> (HaskellAttributeData
-> AtLeastTwo CFloat -> m (TangoValue Double))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Double)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat)
extractFloat ((CFloat -> Double)
-> HaskellAttributeData
-> AtLeastTwo CFloat
-> m (TangoValue Double)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CFloat -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
readFloatSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Double])
readFloatSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Double])
readFloatSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat))
-> (HaskellAttributeData
-> AtLeastTwo CFloat -> m (TangoValue [Double]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Double])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat)
extractFloat ((CFloat -> Double)
-> HaskellAttributeData
-> AtLeastTwo CFloat
-> m (TangoValue [Double])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CFloat -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
readFloatImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Double))
readFloatImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Double))
readFloatImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat))
-> (HaskellAttributeData
-> AtLeastTwo CFloat -> m (TangoValue (Image Double)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Double))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CFloat)
extractFloat ((CFloat -> Double)
-> HaskellAttributeData
-> AtLeastTwo CFloat
-> m (TangoValue (Image Double))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CFloat -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
extractDouble :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble)
(HaskellAttributeDataDoubleArray HaskellTangoVarArray CDouble
a) = HaskellTangoVarArray CDouble
-> Maybe (HaskellTangoVarArray CDouble)
forall a. a -> Maybe a
Just HaskellTangoVarArray CDouble
a
extractDouble HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CDouble)
forall a. Maybe a
Nothing
readDoubleAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue Double)
readDoubleAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue Double)
readDoubleAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble))
-> (HaskellAttributeData
-> AtLeastTwo CDouble -> m (TangoValue Double))
-> DeviceProxy
-> AttributeName
-> m (TangoValue Double)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble)
extractDouble ((CDouble -> Double)
-> HaskellAttributeData
-> AtLeastTwo CDouble
-> m (TangoValue Double)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
readDoubleSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [Double])
readDoubleSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue [Double])
readDoubleSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble))
-> (HaskellAttributeData
-> AtLeastTwo CDouble -> m (TangoValue [Double]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [Double])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble)
extractDouble ((CDouble -> Double)
-> HaskellAttributeData
-> AtLeastTwo CDouble
-> m (TangoValue [Double])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
readDoubleImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image Double))
readDoubleImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue (Image Double))
readDoubleImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble))
-> (HaskellAttributeData
-> AtLeastTwo CDouble -> m (TangoValue (Image Double)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image Double))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CDouble)
extractDouble ((CDouble -> Double)
-> HaskellAttributeData
-> AtLeastTwo CDouble
-> m (TangoValue (Image Double))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac)
extractState :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray HaskellTangoDevState)
(HaskellAttributeDataStateArray HaskellTangoVarArray HaskellTangoDevState
a) = HaskellTangoVarArray HaskellTangoDevState
-> Maybe (HaskellTangoVarArray HaskellTangoDevState)
forall a. a -> Maybe a
Just HaskellTangoVarArray HaskellTangoDevState
a
extractState HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray HaskellTangoDevState)
forall a. Maybe a
Nothing
readStateAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue HaskellTangoDevState)
readStateAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m (TangoValue HaskellTangoDevState)
readStateAttribute = (HaskellTangoAttributeData
-> Maybe (HaskellTangoVarArray HaskellTangoDevState))
-> (HaskellAttributeData
-> AtLeastTwo HaskellTangoDevState
-> m (TangoValue HaskellTangoDevState))
-> DeviceProxy
-> AttributeName
-> m (TangoValue HaskellTangoDevState)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData
-> Maybe (HaskellTangoVarArray HaskellTangoDevState)
extractState ((HaskellTangoDevState -> HaskellTangoDevState)
-> HaskellAttributeData
-> AtLeastTwo HaskellTangoDevState
-> m (TangoValue HaskellTangoDevState)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar HaskellTangoDevState -> HaskellTangoDevState
forall a. a -> a
id)
readStateSpectrumAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue [HaskellTangoDevState])
readStateSpectrumAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy
-> AttributeName -> m (TangoValue [HaskellTangoDevState])
readStateSpectrumAttribute = (HaskellTangoAttributeData
-> Maybe (HaskellTangoVarArray HaskellTangoDevState))
-> (HaskellAttributeData
-> AtLeastTwo HaskellTangoDevState
-> m (TangoValue [HaskellTangoDevState]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [HaskellTangoDevState])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData
-> Maybe (HaskellTangoVarArray HaskellTangoDevState)
extractState ((HaskellTangoDevState -> HaskellTangoDevState)
-> HaskellAttributeData
-> AtLeastTwo HaskellTangoDevState
-> m (TangoValue [HaskellTangoDevState])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum HaskellTangoDevState -> HaskellTangoDevState
forall a. a -> a
id)
readStateImageAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m (TangoValue (Image HaskellTangoDevState))
readStateImageAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy
-> AttributeName -> m (TangoValue (Image HaskellTangoDevState))
readStateImageAttribute = (HaskellTangoAttributeData
-> Maybe (HaskellTangoVarArray HaskellTangoDevState))
-> (HaskellAttributeData
-> AtLeastTwo HaskellTangoDevState
-> m (TangoValue (Image HaskellTangoDevState)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image HaskellTangoDevState))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData
-> Maybe (HaskellTangoVarArray HaskellTangoDevState)
extractState ((HaskellTangoDevState -> HaskellTangoDevState)
-> HaskellAttributeData
-> AtLeastTwo HaskellTangoDevState
-> m (TangoValue (Image HaskellTangoDevState))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage HaskellTangoDevState -> HaskellTangoDevState
forall a. a -> a
id)
extractEnum :: HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
(HaskellAttributeDataShortArray HaskellTangoVarArray CShort
a) = HaskellTangoVarArray CShort -> Maybe (HaskellTangoVarArray CShort)
forall a. a -> Maybe a
Just HaskellTangoVarArray CShort
a
extractEnum HaskellTangoAttributeData
_ = Maybe (HaskellTangoVarArray CShort)
forall a. Maybe a
Nothing
readEnumAttribute :: (MonadUnliftIO m, Enum t) => DeviceProxy -> AttributeName -> m (TangoValue t)
readEnumAttribute :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> AttributeName -> m (TangoValue t)
readEnumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort))
-> (HaskellAttributeData -> AtLeastTwo CShort -> m (TangoValue t))
-> DeviceProxy
-> AttributeName
-> m (TangoValue t)
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
extractEnum ((CShort -> t)
-> HaskellAttributeData -> AtLeastTwo CShort -> m (TangoValue t)
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue b)
convertGenericScalar (Int -> t
forall a. Enum a => Int -> a
toEnum (Int -> t) -> (CShort -> Int) -> CShort -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CShort -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral))
readEnumSpectrumAttribute :: (MonadUnliftIO m, Enum t) => DeviceProxy -> AttributeName -> m (TangoValue [t])
readEnumSpectrumAttribute :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> AttributeName -> m (TangoValue [t])
readEnumSpectrumAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort))
-> (HaskellAttributeData
-> AtLeastTwo CShort -> m (TangoValue [t]))
-> DeviceProxy
-> AttributeName
-> m (TangoValue [t])
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
extractEnum ((CShort -> t)
-> HaskellAttributeData -> AtLeastTwo CShort -> m (TangoValue [t])
forall (f :: * -> *) a b.
Applicative f =>
(a -> b)
-> HaskellAttributeData -> AtLeastTwo a -> f (TangoValue [b])
convertGenericSpectrum (Int -> t
forall a. Enum a => Int -> a
toEnum (Int -> t) -> (CShort -> Int) -> CShort -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CShort -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral))
readEnumImageAttribute :: (MonadUnliftIO m, Enum t) => DeviceProxy -> AttributeName -> m (TangoValue (Image t))
readEnumImageAttribute :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> AttributeName -> m (TangoValue (Image t))
readEnumImageAttribute = (HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort))
-> (HaskellAttributeData
-> AtLeastTwo CShort -> m (TangoValue (Image t)))
-> DeviceProxy
-> AttributeName
-> m (TangoValue (Image t))
forall a (m :: * -> *) b.
(Storable a, Show a, MonadUnliftIO m) =>
(HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray a))
-> (HaskellAttributeData -> AtLeastTwo a -> m b)
-> DeviceProxy
-> AttributeName
-> m b
readAttributeSimple HaskellTangoAttributeData -> Maybe (HaskellTangoVarArray CShort)
extractEnum ((CShort -> t)
-> HaskellAttributeData
-> AtLeastTwo CShort
-> m (TangoValue (Image t))
forall (f :: * -> *) a1 a2.
Applicative f =>
(a1 -> a2)
-> HaskellAttributeData
-> AtLeastTwo a1
-> f (TangoValue (Image a2))
convertGenericImage (Int -> t
forall a. Enum a => Int -> a
toEnum (Int -> t) -> (CShort -> Int) -> CShort -> t
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CShort -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral))
newtype CommandName = CommandName Text
instance Show CommandName where
show :: CommandName -> String
show (CommandName Text
n) = ShowS
forall a. Show a => a -> String
show (Text -> String
unpack Text
n)
data CommandData
= CommandVoid
| CommandBool !Bool
| CommandShort !Int16
| CommandUShort !Word16
| CommandInt32 !Int32
| CommandInt64 !Int64
| CommandWord64 !Word64
| CommandFloat !Float
| CommandDouble !Double
| CommandString !Text
| CommandState !HaskellTangoDevState
| CommandEnum !Int16
| CommandListBool ![Bool]
| CommandListShort ![Int16]
| CommandListUShort ![Word16]
| CommandListInt64 ![Int64]
| CommandListWord64 ![Word64]
| CommandListLong64 ![Int64]
| CommandListULong64 ![Word64]
| CommandListFloat ![Float]
| CommandListDouble ![Double]
| CommandListString ![Text]
| CommandListState ![HaskellTangoDevState]
deriving (Int -> CommandData -> ShowS
[CommandData] -> ShowS
CommandData -> String
(Int -> CommandData -> ShowS)
-> (CommandData -> String)
-> ([CommandData] -> ShowS)
-> Show CommandData
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommandData -> ShowS
showsPrec :: Int -> CommandData -> ShowS
$cshow :: CommandData -> String
show :: CommandData -> String
$cshowList :: [CommandData] -> ShowS
showList :: [CommandData] -> ShowS
Show)
commandInVoidOutVoid :: (MonadUnliftIO m) => DeviceProxy -> CommandName -> m ()
commandInVoidOutVoid :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> m ()
commandInVoidOutVoid (DeviceProxy DeviceProxyPtr
proxyPtr) (CommandName Text
commandName) =
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
Text -> (CString -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText
Text
commandName
\CString
commandNamePtr ->
HaskellCommandData -> (Ptr HaskellCommandData -> IO ()) -> IO ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVoid HaskellTangoCommandData
HaskellCommandVoid) ((Ptr HaskellCommandData -> IO ()) -> IO ())
-> (Ptr HaskellCommandData -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr HaskellCommandData
commandDataInPtr -> HaskellCommandData -> (Ptr HaskellCommandData -> IO ()) -> IO ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVoid HaskellTangoCommandData
HaskellCommandVoid) ((Ptr HaskellCommandData -> IO ()) -> IO ())
-> (Ptr HaskellCommandData -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr HaskellCommandData
commandDataOutPtr ->
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> IO (Ptr HaskellErrorStack) -> IO ()
forall a b. (a -> b) -> a -> b
$ DeviceProxyPtr
-> CString
-> Ptr HaskellCommandData
-> Ptr HaskellCommandData
-> IO (Ptr HaskellErrorStack)
tango_command_inout DeviceProxyPtr
proxyPtr CString
commandNamePtr Ptr HaskellCommandData
commandDataInPtr Ptr HaskellCommandData
commandDataOutPtr
withVarArray :: (MonadUnliftIO m, Storable a) => [a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray :: forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray [a]
b HaskellTangoVarArray a -> m b
f = [a] -> (Ptr a -> m b) -> m b
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [a]
b (HaskellTangoVarArray a -> m b
f (HaskellTangoVarArray a -> m b)
-> (Ptr a -> HaskellTangoVarArray a) -> Ptr a -> m b
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Word32 -> Ptr a -> HaskellTangoVarArray a
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([a] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [a]
b)))
newCStringText :: (MonadUnliftIO m) => Text -> m CString
newCStringText :: forall (m :: * -> *). MonadUnliftIO m => Text -> m CString
newCStringText = String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (String -> m CString) -> (Text -> String) -> Text -> m CString
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> String
unpack
withRawCommandData :: (MonadUnliftIO m) => CommandData -> (Ptr HaskellCommandData -> m a) -> m a
withRawCommandData :: forall (m :: * -> *) a.
MonadUnliftIO m =>
CommandData -> (Ptr HaskellCommandData -> m a) -> m a
withRawCommandData CommandData
CommandVoid Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVoid HaskellTangoCommandData
HaskellCommandVoid) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandBool Bool
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevBoolean (CBool -> HaskellTangoCommandData
HaskellCommandBool (Bool -> CBool
boolToCBool Bool
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandShort Int16
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevShort (CShort -> HaskellTangoCommandData
HaskellCommandShort (Int16 -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int16
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandUShort Word16
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevUShort (CUShort -> HaskellTangoCommandData
HaskellCommandUShort (Word16 -> CUShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word16
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandInt32 Int32
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevInt (CInt -> HaskellTangoCommandData
HaskellCommandInt32 (Int32 -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandInt64 Int64
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevShort (CULong -> HaskellTangoCommandData
HaskellCommandULong64 (Int64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int64
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandWord64 Word64
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevUShort (CLong -> HaskellTangoCommandData
HaskellCommandLong64 (Word64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word64
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandFloat Float
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevFloat (CFloat -> HaskellTangoCommandData
HaskellCommandFloat (Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac Float
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandDouble Double
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevDouble (CDouble -> HaskellTangoCommandData
HaskellCommandDouble (Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
b))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandString Text
t) Ptr HaskellCommandData -> m a
f =
m CString -> (CString -> m ()) -> (CString -> m a) -> m a
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket
(String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (Text -> String
unpack Text
t))
CString -> m ()
forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free
(\CString
s -> HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevString (CString -> HaskellTangoCommandData
HaskellCommandCString CString
s)) Ptr HaskellCommandData -> m a
f)
withRawCommandData (CommandState HaskellTangoDevState
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevState (HaskellTangoDevState -> HaskellTangoCommandData
HaskellCommandDevState HaskellTangoDevState
b)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandEnum Int16
b) Ptr HaskellCommandData -> m a
f = HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevEnum (CShort -> HaskellTangoCommandData
HaskellCommandDevEnum (Int -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int16 -> Int
forall a. Enum a => a -> Int
fromEnum Int16
b)))) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListBool [Bool]
b) Ptr HaskellCommandData -> m a
f =
[CBool] -> (HaskellTangoVarArray CBool -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Bool -> CBool
boolToCBool (Bool -> CBool) -> [Bool] -> [CBool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Bool]
b)
\HaskellTangoVarArray CBool
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarBooleanArray (HaskellTangoVarArray CBool -> HaskellTangoCommandData
HaskellCommandVarBool HaskellTangoVarArray CBool
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListShort [Int16]
b) Ptr HaskellCommandData -> m a
f =
[CShort] -> (HaskellTangoVarArray CShort -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Int16 -> CShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int16 -> CShort) -> [Int16] -> [CShort]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int16]
b)
\HaskellTangoVarArray CShort
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarShortArray (HaskellTangoVarArray CShort -> HaskellTangoCommandData
HaskellCommandVarShort HaskellTangoVarArray CShort
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListUShort [Word16]
b) Ptr HaskellCommandData -> m a
f =
[CUShort] -> (HaskellTangoVarArray CUShort -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Word16 -> CUShort
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word16 -> CUShort) -> [Word16] -> [CUShort]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word16]
b)
\HaskellTangoVarArray CUShort
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarUShortArray (HaskellTangoVarArray CUShort -> HaskellTangoCommandData
HaskellCommandVarUShort HaskellTangoVarArray CUShort
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListInt64 [Int64]
b) Ptr HaskellCommandData -> m a
f =
[CLong] -> (HaskellTangoVarArray CLong -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> CLong) -> [Int64] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int64]
b)
\HaskellTangoVarArray CLong
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarLongArray (HaskellTangoVarArray CLong -> HaskellTangoCommandData
HaskellCommandVarLong HaskellTangoVarArray CLong
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListLong64 [Int64]
b) Ptr HaskellCommandData -> m a
f =
[CLong] -> (HaskellTangoVarArray CLong -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Int64 -> CLong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int64 -> CLong) -> [Int64] -> [CLong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Int64]
b)
\HaskellTangoVarArray CLong
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarLong64Array (HaskellTangoVarArray CLong -> HaskellTangoCommandData
HaskellCommandVarLong64 HaskellTangoVarArray CLong
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListWord64 [Word64]
b) Ptr HaskellCommandData -> m a
f =
[CULong] -> (HaskellTangoVarArray CULong -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> CULong) -> [Word64] -> [CULong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word64]
b)
\HaskellTangoVarArray CULong
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarULongArray (HaskellTangoVarArray CULong -> HaskellTangoCommandData
HaskellCommandVarULong HaskellTangoVarArray CULong
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListULong64 [Word64]
b) Ptr HaskellCommandData -> m a
f =
[CULong] -> (HaskellTangoVarArray CULong -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Word64 -> CULong
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Word64 -> CULong) -> [Word64] -> [CULong]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Word64]
b)
\HaskellTangoVarArray CULong
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarULong64Array (HaskellTangoVarArray CULong -> HaskellTangoCommandData
HaskellCommandVarULong64 HaskellTangoVarArray CULong
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListFloat [Float]
b) Ptr HaskellCommandData -> m a
f =
[CFloat] -> (HaskellTangoVarArray CFloat -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Float -> CFloat
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Float -> CFloat) -> [Float] -> [CFloat]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Float]
b)
\HaskellTangoVarArray CFloat
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarFloatArray (HaskellTangoVarArray CFloat -> HaskellTangoCommandData
HaskellCommandVarFloat HaskellTangoVarArray CFloat
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListDouble [Double]
b) Ptr HaskellCommandData -> m a
f =
[CDouble] -> (HaskellTangoVarArray CDouble -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
(Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac (Double -> CDouble) -> [Double] -> [CDouble]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [Double]
b)
\HaskellTangoVarArray CDouble
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarDoubleArray (HaskellTangoVarArray CDouble -> HaskellTangoCommandData
HaskellCommandVarDouble HaskellTangoVarArray CDouble
varList)) Ptr HaskellCommandData -> m a
f
withRawCommandData (CommandListString [Text]
texts) Ptr HaskellCommandData -> m a
f =
m [CString] -> ([CString] -> m [()]) -> ([CString] -> m a) -> m a
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
UnliftIO.bracket
((Text -> m CString) -> [Text] -> m [CString]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse Text -> m CString
forall (m :: * -> *). MonadUnliftIO m => Text -> m CString
newCStringText [Text]
texts)
((CString -> m ()) -> [CString] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m ()
forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free)
( \[CString]
textPtrList -> [CString] -> (HaskellTangoVarArray CString -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
[CString]
textPtrList
\HaskellTangoVarArray CString
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarStringArray (HaskellTangoVarArray CString -> HaskellTangoCommandData
HaskellCommandVarCString HaskellTangoVarArray CString
varList)) Ptr HaskellCommandData -> m a
f
)
withRawCommandData (CommandListState [HaskellTangoDevState]
b) Ptr HaskellCommandData -> m a
f =
[HaskellTangoDevState]
-> (HaskellTangoVarArray HaskellTangoDevState -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (HaskellTangoVarArray a -> m b) -> m b
withVarArray
[HaskellTangoDevState]
b
\HaskellTangoVarArray HaskellTangoDevState
varList ->
HaskellCommandData -> (Ptr HaskellCommandData -> m a) -> m a
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
HaskellCommandData HaskellTangoDataType
HaskellDevVarStateArray (HaskellTangoVarArray HaskellTangoDevState
-> HaskellTangoCommandData
HaskellCommandVarDevState HaskellTangoVarArray HaskellTangoDevState
varList)) Ptr HaskellCommandData -> m a
f
tangoVarArrayToList :: (MonadUnliftIO m, Storable a) => HaskellTangoVarArray a -> m [a]
tangoVarArrayToList :: forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList (HaskellTangoVarArray {Word32
varArrayLength :: forall a. HaskellTangoVarArray a -> Word32
varArrayLength :: Word32
varArrayLength, Ptr a
varArrayValues :: forall a. HaskellTangoVarArray a -> Ptr a
varArrayValues :: Ptr a
varArrayValues}) =
Int -> Ptr a -> m [a]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Word32
varArrayLength) Ptr a
varArrayValues
fromRawCommandData :: (MonadUnliftIO m) => HaskellCommandData -> m (Maybe CommandData)
fromRawCommandData :: forall (m :: * -> *).
MonadUnliftIO m =>
HaskellCommandData -> m (Maybe CommandData)
fromRawCommandData (HaskellCommandData {HaskellTangoCommandData
tangoCommandData :: HaskellCommandData -> HaskellTangoCommandData
tangoCommandData :: HaskellTangoCommandData
tangoCommandData}) =
case HaskellTangoCommandData
tangoCommandData of
HaskellTangoCommandData
HaskellCommandVoid -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just CommandData
CommandVoid
HaskellCommandBool CBool
cbool -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Bool -> CommandData
CommandBool (Bool -> CommandData) -> Bool -> CommandData
forall a b. (a -> b) -> a -> b
$ CBool -> Bool
cboolToBool CBool
cbool
HaskellCommandShort CShort
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Int16 -> CommandData
CommandShort (Int16 -> CommandData) -> Int16 -> CommandData
forall a b. (a -> b) -> a -> b
$ CShort -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral CShort
v
HaskellCommandUShort CUShort
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Word16 -> CommandData
CommandUShort (Word16 -> CommandData) -> Word16 -> CommandData
forall a b. (a -> b) -> a -> b
$ CUShort -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral CUShort
v
HaskellCommandFloat CFloat
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Float -> CommandData
CommandFloat (Float -> CommandData) -> Float -> CommandData
forall a b. (a -> b) -> a -> b
$ CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac CFloat
v
HaskellCommandDouble CDouble
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Double -> CommandData
CommandDouble (Double -> CommandData) -> Double -> CommandData
forall a b. (a -> b) -> a -> b
$ CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac CDouble
v
HaskellCommandCString CString
v -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> (String -> CommandData) -> String -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Text -> CommandData
CommandString (Text -> CommandData) -> (String -> Text) -> String -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. String -> Text
pack (String -> Maybe CommandData) -> m String -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> m String
forall (m :: * -> *). MonadIO m => CString -> m String
peekCString CString
v
HaskellCommandInt32 CInt
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Int32 -> CommandData
CommandInt32 (Int32 -> CommandData) -> Int32 -> CommandData
forall a b. (a -> b) -> a -> b
$ CInt -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
v
HaskellCommandLong64 CLong
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Int64 -> CommandData
CommandInt64 (Int64 -> CommandData) -> Int64 -> CommandData
forall a b. (a -> b) -> a -> b
$ CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral CLong
v
HaskellCommandDevState HaskellTangoDevState
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ HaskellTangoDevState -> CommandData
CommandState HaskellTangoDevState
v
HaskellCommandULong64 CULong
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Word64 -> CommandData
CommandWord64 (Word64 -> CommandData) -> Word64 -> CommandData
forall a b. (a -> b) -> a -> b
$ CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral CULong
v
HaskellCommandDevEnum CShort
v -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Maybe CommandData -> m (Maybe CommandData))
-> Maybe CommandData -> m (Maybe CommandData)
forall a b. (a -> b) -> a -> b
$ CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> CommandData -> Maybe CommandData
forall a b. (a -> b) -> a -> b
$ Int16 -> CommandData
CommandEnum (Int16 -> CommandData) -> Int16 -> CommandData
forall a b. (a -> b) -> a -> b
$ Int -> Int16
forall a. Enum a => Int -> a
toEnum (Int -> Int16) -> Int -> Int16
forall a b. (a -> b) -> a -> b
$ CShort -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CShort
v
HaskellCommandVarBool HaskellTangoVarArray CBool
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CBool] -> CommandData) -> [CBool] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Bool] -> CommandData
CommandListBool ([Bool] -> CommandData)
-> ([CBool] -> [Bool]) -> [CBool] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CBool -> Bool
cboolToBool (CBool -> Bool) -> [CBool] -> [Bool]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CBool] -> Maybe CommandData)
-> m [CBool] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CBool -> m [CBool]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CBool
a
HaskellCommandVarShort HaskellTangoVarArray CShort
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CShort] -> CommandData) -> [CShort] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int16] -> CommandData
CommandListShort ([Int16] -> CommandData)
-> ([CShort] -> [Int16]) -> [CShort] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CShort -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CShort -> Int16) -> [CShort] -> [Int16]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CShort] -> Maybe CommandData)
-> m [CShort] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CShort -> m [CShort]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CShort
a
HaskellCommandVarUShort HaskellTangoVarArray CUShort
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CUShort] -> CommandData) -> [CUShort] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word16] -> CommandData
CommandListUShort ([Word16] -> CommandData)
-> ([CUShort] -> [Word16]) -> [CUShort] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CUShort -> Word16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CUShort -> Word16) -> [CUShort] -> [Word16]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CUShort] -> Maybe CommandData)
-> m [CUShort] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CUShort -> m [CUShort]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CUShort
a
HaskellCommandVarLong HaskellTangoVarArray CLong
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CLong] -> CommandData) -> [CLong] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int64] -> CommandData
CommandListInt64 ([Int64] -> CommandData)
-> ([CLong] -> [Int64]) -> [CLong] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CLong -> Int64) -> [CLong] -> [Int64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CLong] -> Maybe CommandData)
-> m [CLong] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CLong -> m [CLong]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CLong
a
HaskellCommandVarULong HaskellTangoVarArray CULong
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CULong] -> CommandData) -> [CULong] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word64] -> CommandData
CommandListWord64 ([Word64] -> CommandData)
-> ([CULong] -> [Word64]) -> [CULong] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CULong -> Word64) -> [CULong] -> [Word64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CULong] -> Maybe CommandData)
-> m [CULong] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CULong -> m [CULong]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CULong
a
HaskellCommandVarLong64 HaskellTangoVarArray CLong
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CLong] -> CommandData) -> [CLong] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Int64] -> CommandData
CommandListLong64 ([Int64] -> CommandData)
-> ([CLong] -> [Int64]) -> [CLong] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CLong -> Int64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CLong -> Int64) -> [CLong] -> [Int64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CLong] -> Maybe CommandData)
-> m [CLong] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CLong -> m [CLong]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CLong
a
HaskellCommandVarULong64 HaskellTangoVarArray CULong
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CULong] -> CommandData) -> [CULong] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Word64] -> CommandData
CommandListULong64 ([Word64] -> CommandData)
-> ([CULong] -> [Word64]) -> [CULong] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CULong -> Word64
forall a b. (Integral a, Num b) => a -> b
fromIntegral (CULong -> Word64) -> [CULong] -> [Word64]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CULong] -> Maybe CommandData)
-> m [CULong] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CULong -> m [CULong]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CULong
a
HaskellCommandVarFloat HaskellTangoVarArray CFloat
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CFloat] -> CommandData) -> [CFloat] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Float] -> CommandData
CommandListFloat ([Float] -> CommandData)
-> ([CFloat] -> [Float]) -> [CFloat] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CFloat -> Float
forall a b. (Real a, Fractional b) => a -> b
realToFrac (CFloat -> Float) -> [CFloat] -> [Float]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CFloat] -> Maybe CommandData)
-> m [CFloat] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CFloat -> m [CFloat]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CFloat
a
HaskellCommandVarDouble HaskellTangoVarArray CDouble
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([CDouble] -> CommandData) -> [CDouble] -> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [Double] -> CommandData
CommandListDouble ([Double] -> CommandData)
-> ([CDouble] -> [Double]) -> [CDouble] -> CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (CDouble -> Double
forall a b. (Real a, Fractional b) => a -> b
realToFrac (CDouble -> Double) -> [CDouble] -> [Double]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) ([CDouble] -> Maybe CommandData)
-> m [CDouble] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray CDouble -> m [CDouble]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CDouble
a
HaskellCommandVarCString HaskellTangoVarArray CString
strings -> do
[CString]
stringsAsList <- HaskellTangoVarArray CString -> m [CString]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CString
strings
[Text]
texts <- (CString -> m Text) -> [CString] -> m [Text]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText [CString]
stringsAsList
Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just ([Text] -> CommandData
CommandListString [Text]
texts))
HaskellCommandVarDevState HaskellTangoVarArray HaskellTangoDevState
a -> CommandData -> Maybe CommandData
forall a. a -> Maybe a
Just (CommandData -> Maybe CommandData)
-> ([HaskellTangoDevState] -> CommandData)
-> [HaskellTangoDevState]
-> Maybe CommandData
forall b c a. (b -> c) -> (a -> b) -> a -> c
. [HaskellTangoDevState] -> CommandData
CommandListState ([HaskellTangoDevState] -> Maybe CommandData)
-> m [HaskellTangoDevState] -> m (Maybe CommandData)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> HaskellTangoVarArray HaskellTangoDevState
-> m [HaskellTangoDevState]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray HaskellTangoDevState
a
HaskellTangoCommandData
_ -> Maybe CommandData -> m (Maybe CommandData)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure Maybe CommandData
forall a. Maybe a
Nothing
commandInOutGeneric :: (MonadUnliftIO m) => DeviceProxy -> CommandName -> CommandData -> m CommandData
commandInOutGeneric :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> CommandData -> m CommandData
commandInOutGeneric (DeviceProxy DeviceProxyPtr
proxyPtr) (CommandName Text
commandName) CommandData
in' =
IO CommandData -> m CommandData
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CommandData -> m CommandData)
-> IO CommandData -> m CommandData
forall a b. (a -> b) -> a -> b
$
Text -> (CString -> IO CommandData) -> IO CommandData
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
commandName ((CString -> IO CommandData) -> IO CommandData)
-> (CString -> IO CommandData) -> IO CommandData
forall a b. (a -> b) -> a -> b
$
\CString
commandNamePtr ->
CommandData
-> (Ptr HaskellCommandData -> IO CommandData) -> IO CommandData
forall (m :: * -> *) a.
MonadUnliftIO m =>
CommandData -> (Ptr HaskellCommandData -> m a) -> m a
withRawCommandData CommandData
in' \Ptr HaskellCommandData
commandDataInPtr ->
HaskellCommandData
-> (Ptr HaskellCommandData -> IO CommandData) -> IO CommandData
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (HaskellTangoDataType
-> HaskellTangoCommandData -> HaskellCommandData
RawCommon.HaskellCommandData HaskellTangoDataType
RawCommon.HaskellDevVoid HaskellTangoCommandData
RawCommon.HaskellCommandVoid) ((Ptr HaskellCommandData -> IO CommandData) -> IO CommandData)
-> (Ptr HaskellCommandData -> IO CommandData) -> IO CommandData
forall a b. (a -> b) -> a -> b
$ \Ptr HaskellCommandData
commandDataOutPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> IO (Ptr HaskellErrorStack) -> IO ()
forall a b. (a -> b) -> a -> b
$ DeviceProxyPtr
-> CString
-> Ptr HaskellCommandData
-> Ptr HaskellCommandData
-> IO (Ptr HaskellErrorStack)
tango_command_inout DeviceProxyPtr
proxyPtr CString
commandNamePtr Ptr HaskellCommandData
commandDataInPtr Ptr HaskellCommandData
commandDataOutPtr
HaskellCommandData
outValue <- Ptr HaskellCommandData -> IO HaskellCommandData
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellCommandData
commandDataOutPtr
Maybe CommandData
result <- HaskellCommandData -> IO (Maybe CommandData)
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellCommandData -> m (Maybe CommandData)
fromRawCommandData HaskellCommandData
outValue
case Maybe CommandData
result of
Maybe CommandData
Nothing -> String -> IO CommandData
forall a. HasCallStack => String -> a
error String
"couldn't convert the command out value"
Just CommandData
result' -> CommandData -> IO CommandData
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CommandData
result'
commandInEnumOutGeneric :: (MonadUnliftIO m, Enum t) => DeviceProxy -> CommandName -> t -> m CommandData
commandInEnumOutGeneric :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> CommandName -> t -> m CommandData
commandInEnumOutGeneric DeviceProxy
proxy CommandName
commandName t
in' = DeviceProxy -> CommandName -> CommandData -> m CommandData
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> CommandData -> m CommandData
commandInOutGeneric DeviceProxy
proxy CommandName
commandName (Int16 -> CommandData
CommandShort (Int16 -> CommandData) -> Int16 -> CommandData
forall a b. (a -> b) -> a -> b
$ Int -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int16) -> Int -> Int16
forall a b. (a -> b) -> a -> b
$ t -> Int
forall a. Enum a => a -> Int
fromEnum t
in')
commandInGenericOutEnum :: (MonadUnliftIO m, Enum t) => DeviceProxy -> CommandName -> CommandData -> m t
commandInGenericOutEnum :: forall (m :: * -> *) t.
(MonadUnliftIO m, Enum t) =>
DeviceProxy -> CommandName -> CommandData -> m t
commandInGenericOutEnum DeviceProxy
proxy CommandName
commandName CommandData
in' = do
CommandData
result <- DeviceProxy -> CommandName -> CommandData -> m CommandData
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> CommandData -> m CommandData
commandInOutGeneric DeviceProxy
proxy CommandName
commandName CommandData
in'
case CommandData
result of
CommandShort Int16
s -> t -> m t
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> t
forall a. Enum a => Int -> a
toEnum (Int16 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int16
s))
CommandData
_ -> String -> m t
forall a. HasCallStack => String -> a
error (String
"command " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> CommandName -> String
forall a. Show a => a -> String
show CommandName
commandName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" was supposed to return a short (for enums), but returned " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> CommandData -> String
forall a. Show a => a -> String
show CommandData
result)
commandInEnumOutEnum :: (MonadUnliftIO m, Enum t, Enum u) => DeviceProxy -> CommandName -> u -> m t
commandInEnumOutEnum :: forall (m :: * -> *) t u.
(MonadUnliftIO m, Enum t, Enum u) =>
DeviceProxy -> CommandName -> u -> m t
commandInEnumOutEnum DeviceProxy
proxy CommandName
commandName u
in' = do
CommandData
result <- DeviceProxy -> CommandName -> CommandData -> m CommandData
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> CommandData -> m CommandData
commandInOutGeneric DeviceProxy
proxy CommandName
commandName (Int16 -> CommandData
CommandShort (Int16 -> CommandData) -> Int16 -> CommandData
forall a b. (a -> b) -> a -> b
$ Int -> Int16
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int16) -> Int -> Int16
forall a b. (a -> b) -> a -> b
$ u -> Int
forall a. Enum a => a -> Int
fromEnum u
in')
case CommandData
result of
CommandShort Int16
s -> t -> m t
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> t
forall a. Enum a => Int -> a
toEnum (Int16 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int16
s))
CommandData
_ -> String -> m t
forall a. HasCallStack => String -> a
error (String
"command " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> CommandName -> String
forall a. Show a => a -> String
show CommandName
commandName String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
" was supposed to return a short (for enums), but returned " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> CommandData -> String
forall a. Show a => a -> String
show CommandData
result)
data AttributeInfo = AttributeInfo
{ AttributeInfo -> HaskellAttrWriteType
attributeInfoWritable :: !HaskellAttrWriteType,
AttributeInfo -> HaskellDataFormat
attributeInfoDataFormat :: !HaskellDataFormat,
AttributeInfo -> HaskellTangoDataType
attributeInfoDataType :: !HaskellTangoDataType,
AttributeInfo -> Int
attributeInfoMaxDimX :: !Int,
AttributeInfo -> Int
attributeInfoMaxDimY :: !Int,
AttributeInfo -> Text
attributeInfoDescription :: !Text,
AttributeInfo -> Text
attributeInfoLabel :: !Text,
AttributeInfo -> Text
attributeInfoUnit :: !Text,
AttributeInfo -> Text
attributeInfoStandardUnit :: !Text,
AttributeInfo -> Text
attributeInfoDisplayUnit :: !Text,
AttributeInfo -> Text
attributeInfoFormat :: !Text,
AttributeInfo -> Text
attributeInfoMinValue :: !Text,
AttributeInfo -> Text
attributeInfoMaxValue :: !Text,
AttributeInfo -> Text
attributeInfoMinAlarm :: !Text,
AttributeInfo -> Text
attributeInfoMaxAlarm :: !Text,
AttributeInfo -> Text
attributeInfoWritableAttrName :: !Text,
AttributeInfo -> HaskellDispLevel
attributeInfoDispLevel :: !HaskellDispLevel,
AttributeInfo -> [Text]
attributeInfoEnumLabels :: [Text],
AttributeInfo -> Text
attributeInfoRootAttrName :: Text,
AttributeInfo -> TangoAttrMemorizedType
attributeInfoMemorized :: !TangoAttrMemorizedType
}
deriving (Int -> AttributeInfo -> ShowS
[AttributeInfo] -> ShowS
AttributeInfo -> String
(Int -> AttributeInfo -> ShowS)
-> (AttributeInfo -> String)
-> ([AttributeInfo] -> ShowS)
-> Show AttributeInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> AttributeInfo -> ShowS
showsPrec :: Int -> AttributeInfo -> ShowS
$cshow :: AttributeInfo -> String
show :: AttributeInfo -> String
$cshowList :: [AttributeInfo] -> ShowS
showList :: [AttributeInfo] -> ShowS
Show)
convertAttributeInfo :: forall m. (MonadUnliftIO m) => RawCommon.HaskellAttributeInfo -> m AttributeInfo
convertAttributeInfo :: forall (m :: * -> *).
MonadUnliftIO m =>
HaskellAttributeInfo -> m AttributeInfo
convertAttributeInfo HaskellAttributeInfo
ai = do
Text
description <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoDescription HaskellAttributeInfo
ai)
Text
label <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoLabel HaskellAttributeInfo
ai)
Text
unit <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoUnit HaskellAttributeInfo
ai)
Text
standardUnit <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoStandardUnit HaskellAttributeInfo
ai)
Text
displayUnit <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoDisplayUnit HaskellAttributeInfo
ai)
Text
format <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoFormat HaskellAttributeInfo
ai)
Text
minValue <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoMinValue HaskellAttributeInfo
ai)
Text
maxValue <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoMaxValue HaskellAttributeInfo
ai)
Text
minAlarm <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoMinAlarm HaskellAttributeInfo
ai)
Text
maxAlarm <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoMaxAlarm HaskellAttributeInfo
ai)
Text
writableAttrName <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoWritableAttrName HaskellAttributeInfo
ai)
[Text]
enumLabelsList <-
Word16 -> Ptr CString -> m [Text]
forall (m :: * -> *) i.
(MonadUnliftIO m, Integral i) =>
i -> Ptr CString -> m [Text]
peekCStringArrayText (HaskellAttributeInfo -> Word16
RawCommon.attributeInfoEnumLabelsCount HaskellAttributeInfo
ai) (HaskellAttributeInfo -> Ptr CString
RawCommon.attributeInfoEnumLabels HaskellAttributeInfo
ai)
Text
rootAttrName <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellAttributeInfo -> CString
RawCommon.attributeInfoRootAttrName HaskellAttributeInfo
ai)
AttributeInfo -> m AttributeInfo
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (AttributeInfo -> m AttributeInfo)
-> AttributeInfo -> m AttributeInfo
forall a b. (a -> b) -> a -> b
$
HaskellAttrWriteType
-> HaskellDataFormat
-> HaskellTangoDataType
-> Int
-> Int
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> Text
-> HaskellDispLevel
-> [Text]
-> Text
-> TangoAttrMemorizedType
-> AttributeInfo
AttributeInfo
(HaskellAttributeInfo -> HaskellAttrWriteType
RawCommon.attributeInfoWritable HaskellAttributeInfo
ai)
(HaskellAttributeInfo -> HaskellDataFormat
RawCommon.attributeInfoDataFormat HaskellAttributeInfo
ai)
(HaskellAttributeInfo -> HaskellTangoDataType
RawCommon.attributeInfoDataType HaskellAttributeInfo
ai)
(Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellAttributeInfo -> Int32
RawCommon.attributeInfoMaxDimX HaskellAttributeInfo
ai))
(Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellAttributeInfo -> Int32
RawCommon.attributeInfoMaxDimY HaskellAttributeInfo
ai))
Text
description
Text
label
Text
unit
Text
standardUnit
Text
displayUnit
Text
format
Text
minValue
Text
maxValue
Text
minAlarm
Text
maxAlarm
Text
writableAttrName
(HaskellAttributeInfo -> HaskellDispLevel
RawCommon.attributeInfoDispLevel HaskellAttributeInfo
ai)
[Text]
enumLabelsList
Text
rootAttrName
(HaskellAttributeInfo -> TangoAttrMemorizedType
RawCommon.attributeInfoMemorized HaskellAttributeInfo
ai)
getConfigForAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m AttributeInfo
getConfigForAttribute DeviceProxy
proxy AttributeName
attributeName =
[AttributeInfo] -> AttributeInfo
forall a. HasCallStack => [a] -> a
head ([AttributeInfo] -> AttributeInfo)
-> m [AttributeInfo] -> m AttributeInfo
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> IO [AttributeInfo] -> m [AttributeInfo]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DeviceProxy -> [AttributeName] -> IO [AttributeInfo]
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> [AttributeName] -> m [AttributeInfo]
getConfigsForAttributes DeviceProxy
proxy [AttributeName
attributeName])
getConfigsForAttributes :: forall m. (MonadUnliftIO m) => DeviceProxy -> [AttributeName] -> m [AttributeInfo]
getConfigsForAttributes :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> [AttributeName] -> m [AttributeInfo]
getConfigsForAttributes (DeviceProxy DeviceProxyPtr
deviceProxyPtr) [AttributeName]
attributeNames = do
let attributeNameToCString :: AttributeName -> m CString
attributeNameToCString :: AttributeName -> m CString
attributeNameToCString (AttributeName Text
t) = String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (Text -> String
unpack Text
t)
m [CString]
-> ([CString] -> m [()])
-> ([CString] -> m [AttributeInfo])
-> m [AttributeInfo]
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket ((AttributeName -> m CString) -> [AttributeName] -> m [CString]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse AttributeName -> m CString
attributeNameToCString [AttributeName]
attributeNames) ((CString -> m ()) -> [CString] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m ()
forall (m :: * -> *) a. MonadIO m => Ptr a -> m ()
free) \[CString]
cstringList ->
[CString]
-> (Ptr CString -> m [AttributeInfo]) -> m [AttributeInfo]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [CString]
cstringList \Ptr CString
cstringPtr ->
HaskellTangoVarArray CString
-> (Ptr (HaskellTangoVarArray CString) -> m [AttributeInfo])
-> m [AttributeInfo]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([AttributeName] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [AttributeName]
attributeNames)) Ptr CString
cstringPtr) \Ptr (HaskellTangoVarArray CString)
varArrayPtr ->
HaskellAttributeInfoList
-> (Ptr HaskellAttributeInfoList -> m [AttributeInfo])
-> m [AttributeInfo]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (Word32 -> Ptr HaskellAttributeInfo -> HaskellAttributeInfoList
HaskellAttributeInfoList Word32
0 Ptr HaskellAttributeInfo
forall a. Ptr a
nullPtr) \Ptr HaskellAttributeInfoList
outputPtr ->
m ()
-> (() -> m ()) -> (() -> m [AttributeInfo]) -> m [AttributeInfo]
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket
(m (Ptr HaskellErrorStack) -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> m (Ptr HaskellErrorStack)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DeviceProxyPtr
-> Ptr (HaskellTangoVarArray CString)
-> Ptr HaskellAttributeInfoList
-> IO (Ptr HaskellErrorStack)
tango_get_attribute_config DeviceProxyPtr
deviceProxyPtr Ptr (HaskellTangoVarArray CString)
varArrayPtr Ptr HaskellAttributeInfoList
outputPtr)))
(\()
_ -> IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr HaskellAttributeInfoList -> IO ()
tango_free_AttributeInfoList Ptr HaskellAttributeInfoList
outputPtr))
\()
_ -> do
HaskellAttributeInfoList
outputPeeked <- IO HaskellAttributeInfoList -> m HaskellAttributeInfoList
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr HaskellAttributeInfoList -> IO HaskellAttributeInfoList
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellAttributeInfoList
outputPtr)
[HaskellAttributeInfo]
elements <- Int -> Ptr HaskellAttributeInfo -> m [HaskellAttributeInfo]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellAttributeInfoList -> Word32
attributeInfoListLength HaskellAttributeInfoList
outputPeeked)) (HaskellAttributeInfoList -> Ptr HaskellAttributeInfo
attributeInfoListSequence HaskellAttributeInfoList
outputPeeked)
(HaskellAttributeInfo -> m AttributeInfo)
-> [HaskellAttributeInfo] -> m [AttributeInfo]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HaskellAttributeInfo -> m AttributeInfo
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellAttributeInfo -> m AttributeInfo
convertAttributeInfo [HaskellAttributeInfo]
elements
newtype PropertyName = PropertyName Text
instance Show PropertyName where
show :: PropertyName -> String
show (PropertyName Text
x) = ShowS
forall a. Show a => a -> String
show (Text -> String
unpack Text
x)
data Property = Property
{ Property -> Text
propertyName :: !Text,
Property -> Bool
propertyIsEmpty :: !Bool,
Property -> Bool
propertyWrongDataType :: !Bool,
Property -> [Text]
propertyData :: ![Text]
}
deriving (Int -> Property -> ShowS
[Property] -> ShowS
Property -> String
(Int -> Property -> ShowS)
-> (Property -> String) -> ([Property] -> ShowS) -> Show Property
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Property -> ShowS
showsPrec :: Int -> Property -> ShowS
$cshow :: Property -> String
show :: Property -> String
$cshowList :: [Property] -> ShowS
showList :: [Property] -> ShowS
Show)
convertPropertyData :: (MonadUnliftIO m) => HaskellTangoPropertyData -> m [Text]
convertPropertyData :: forall (m :: * -> *).
MonadUnliftIO m =>
HaskellTangoPropertyData -> m [Text]
convertPropertyData (HaskellPropStringArray HaskellTangoVarArray CString
v) = HaskellTangoVarArray CString -> m [CString]
forall (m :: * -> *) a.
(MonadUnliftIO m, Storable a) =>
HaskellTangoVarArray a -> m [a]
tangoVarArrayToList HaskellTangoVarArray CString
v m [CString] -> ([CString] -> m [Text]) -> m [Text]
forall a b. m a -> (a -> m b) -> m b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= (CString -> m Text) -> [CString] -> m [Text]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText
convertPropertyData HaskellTangoPropertyData
v = String -> m [Text]
forall a. HasCallStack => String -> a
error (String -> m [Text]) -> String -> m [Text]
forall a b. (a -> b) -> a -> b
$ String
"couldn't convert property data to Haskell: " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> HaskellTangoPropertyData -> String
forall a. Show a => a -> String
show HaskellTangoPropertyData
v
convertDbDatum :: (MonadUnliftIO m) => HaskellDbDatum -> m Property
convertDbDatum :: forall (m :: * -> *).
MonadUnliftIO m =>
HaskellDbDatum -> m Property
convertDbDatum HaskellDbDatum
dbDatum = do
[Text]
propData <- HaskellTangoPropertyData -> m [Text]
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellTangoPropertyData -> m [Text]
convertPropertyData (HaskellDbDatum -> HaskellTangoPropertyData
dbDatumPropData HaskellDbDatum
dbDatum)
Text
nameConverted <- CString -> m Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText (HaskellDbDatum -> CString
dbDatumPropertyName HaskellDbDatum
dbDatum)
Property -> m Property
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> m Property) -> Property -> m Property
forall a b. (a -> b) -> a -> b
$
Text -> Bool -> Bool -> [Text] -> Property
Property
Text
nameConverted
(HaskellDbDatum -> Bool
dbDatumIsEmpty HaskellDbDatum
dbDatum)
(HaskellDbDatum -> Bool
dbDatumWrongDataType HaskellDbDatum
dbDatum)
[Text]
propData
nameToDbDatum :: (MonadUnliftIO m) => PropertyName -> m HaskellDbDatum
nameToDbDatum :: forall (m :: * -> *).
MonadUnliftIO m =>
PropertyName -> m HaskellDbDatum
nameToDbDatum (PropertyName Text
name) = do
CString
nameCString <- String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (Text -> String
unpack Text
name)
HaskellDbDatum -> m HaskellDbDatum
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CString
-> Bool
-> Bool
-> HaskellTangoDataType
-> HaskellTangoPropertyData
-> HaskellDbDatum
HaskellDbDatum CString
nameCString Bool
False Bool
False HaskellTangoDataType
HaskellDevVarStringArray (HaskellTangoVarArray CString -> HaskellTangoPropertyData
HaskellPropStringArray (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray Word32
0 Ptr CString
forall a. Ptr a
nullPtr)))
freeDbDatum :: (MonadUnliftIO m) => HaskellDbDatum -> m ()
freeDbDatum :: forall (m :: * -> *). MonadUnliftIO m => HaskellDbDatum -> m ()
freeDbDatum HaskellDbDatum
dbDatum = do
Ptr HaskellDbDatum
dbDatumPtr <- HaskellDbDatum -> m (Ptr HaskellDbDatum)
forall (m :: * -> *) a. (MonadIO m, Storable a) => a -> m (Ptr a)
new HaskellDbDatum
dbDatum
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr HaskellDbDatum -> IO ()
tango_free_DbDatum Ptr HaskellDbDatum
dbDatumPtr)
getDeviceProperties :: forall m. (MonadUnliftIO m) => DeviceProxy -> [PropertyName] -> m [Property]
getDeviceProperties :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> [PropertyName] -> m [Property]
getDeviceProperties (DeviceProxy DeviceProxyPtr
proxyPtr) [PropertyName]
names =
let initialize :: m [HaskellDbDatum]
initialize :: m [HaskellDbDatum]
initialize = (PropertyName -> m HaskellDbDatum)
-> [PropertyName] -> m [HaskellDbDatum]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse PropertyName -> m HaskellDbDatum
forall (m :: * -> *).
MonadUnliftIO m =>
PropertyName -> m HaskellDbDatum
nameToDbDatum [PropertyName]
names
destroy :: [HaskellDbDatum] -> m ()
destroy :: [HaskellDbDatum] -> m ()
destroy = m [()] -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m [()] -> m ())
-> ([HaskellDbDatum] -> m [()]) -> [HaskellDbDatum] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HaskellDbDatum -> m ()) -> [HaskellDbDatum] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HaskellDbDatum -> m ()
forall (m :: * -> *). MonadUnliftIO m => HaskellDbDatum -> m ()
freeDbDatum
in m [HaskellDbDatum]
-> ([HaskellDbDatum] -> m ())
-> ([HaskellDbDatum] -> m [Property])
-> m [Property]
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
UnliftIO.bracket
m [HaskellDbDatum]
initialize
[HaskellDbDatum] -> m ()
destroy
\[HaskellDbDatum]
dbDatumPtrListIn ->
[HaskellDbDatum]
-> (Ptr HaskellDbDatum -> m [Property]) -> m [Property]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [HaskellDbDatum]
dbDatumPtrListIn \Ptr HaskellDbDatum
dbDatumPtrIn ->
IO [Property] -> m [Property]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Property] -> m [Property]) -> IO [Property] -> m [Property]
forall a b. (a -> b) -> a -> b
$ HaskellDbData
-> (Ptr HaskellDbData -> IO [Property]) -> IO [Property]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
(Word32 -> Ptr HaskellDbDatum -> HaskellDbData
HaskellDbData (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([PropertyName] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [PropertyName]
names)) Ptr HaskellDbDatum
dbDatumPtrIn)
\Ptr HaskellDbData
dbDataPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO (Ptr HaskellErrorStack)
forall a. IO a -> IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DeviceProxyPtr -> Ptr HaskellDbData -> IO (Ptr HaskellErrorStack)
tango_get_device_property DeviceProxyPtr
proxyPtr Ptr HaskellDbData
dbDataPtr))
HaskellDbData
dbData <- IO HaskellDbData -> IO HaskellDbData
forall a. IO a -> IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (Ptr HaskellDbData -> IO HaskellDbData
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellDbData
dbDataPtr)
[HaskellDbDatum]
dbDatumPtrListOut <- Int -> Ptr HaskellDbDatum -> IO [HaskellDbDatum]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellDbData -> Word32
dbDataLength HaskellDbData
dbData)) (HaskellDbData -> Ptr HaskellDbDatum
dbDataSequence HaskellDbData
dbData)
(HaskellDbDatum -> IO Property)
-> [HaskellDbDatum] -> IO [Property]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HaskellDbDatum -> IO Property
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellDbDatum -> m Property
convertDbDatum [HaskellDbDatum]
dbDatumPtrListOut
textListToVarArray :: (MonadUnliftIO m) => [Text] -> m (HaskellTangoVarArray CString)
textListToVarArray :: forall (m :: * -> *).
MonadUnliftIO m =>
[Text] -> m (HaskellTangoVarArray CString)
textListToVarArray [Text]
texts = do
[CString]
cstringList :: [CString] <- (Text -> m CString) -> [Text] -> m [CString]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse Text -> m CString
forall (m :: * -> *). MonadUnliftIO m => Text -> m CString
newCStringText [Text]
texts
Ptr CString
cStringPtr :: Ptr CString <- [CString] -> m (Ptr CString)
forall (m :: * -> *) a. (MonadIO m, Storable a) => [a] -> m (Ptr a)
newArray [CString]
cstringList
HaskellTangoVarArray CString -> m (HaskellTangoVarArray CString)
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([Text] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [Text]
texts)) Ptr CString
cStringPtr)
nameAndValueToDbDatum :: (MonadUnliftIO m) => (PropertyName, [Text]) -> m HaskellDbDatum
nameAndValueToDbDatum :: forall (m :: * -> *).
MonadUnliftIO m =>
(PropertyName, [Text]) -> m HaskellDbDatum
nameAndValueToDbDatum (PropertyName Text
name, [Text]
texts) = do
HaskellTangoVarArray CString
varArray <- [Text] -> m (HaskellTangoVarArray CString)
forall (m :: * -> *).
MonadUnliftIO m =>
[Text] -> m (HaskellTangoVarArray CString)
textListToVarArray [Text]
texts
CString
nameCString <- String -> m CString
forall (m :: * -> *). MonadIO m => String -> m CString
newCString (Text -> String
unpack Text
name)
HaskellDbDatum -> m HaskellDbDatum
forall a. a -> m a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (CString
-> Bool
-> Bool
-> HaskellTangoDataType
-> HaskellTangoPropertyData
-> HaskellDbDatum
HaskellDbDatum CString
nameCString Bool
False Bool
False HaskellTangoDataType
HaskellDevVarStringArray (HaskellTangoVarArray CString -> HaskellTangoPropertyData
HaskellPropStringArray HaskellTangoVarArray CString
varArray))
putDeviceProperties :: forall m. (MonadUnliftIO m) => DeviceProxy -> [(PropertyName, [Text])] -> m ()
putDeviceProperties :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> [(PropertyName, [Text])] -> m ()
putDeviceProperties (DeviceProxy DeviceProxyPtr
proxyPtr) [(PropertyName, [Text])]
namesAndValues =
m [HaskellDbDatum]
-> ([HaskellDbDatum] -> m ()) -> ([HaskellDbDatum] -> m ()) -> m ()
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket
(((PropertyName, [Text]) -> m HaskellDbDatum)
-> [(PropertyName, [Text])] -> m [HaskellDbDatum]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse (PropertyName, [Text]) -> m HaskellDbDatum
forall (m :: * -> *).
MonadUnliftIO m =>
(PropertyName, [Text]) -> m HaskellDbDatum
nameAndValueToDbDatum [(PropertyName, [Text])]
namesAndValues)
(m [()] -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m [()] -> m ())
-> ([HaskellDbDatum] -> m [()]) -> [HaskellDbDatum] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HaskellDbDatum -> m ()) -> [HaskellDbDatum] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HaskellDbDatum -> m ()
forall (m :: * -> *). MonadUnliftIO m => HaskellDbDatum -> m ()
freeDbDatum)
\[HaskellDbDatum]
dbDatumPtrListIn ->
[HaskellDbDatum] -> (Ptr HaskellDbDatum -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [HaskellDbDatum]
dbDatumPtrListIn \Ptr HaskellDbDatum
dbDatumPtrIn ->
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
HaskellDbData -> (Ptr HaskellDbData -> IO ()) -> IO ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
(Word32 -> Ptr HaskellDbDatum -> HaskellDbData
HaskellDbData (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([(PropertyName, [Text])] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [(PropertyName, [Text])]
namesAndValues)) Ptr HaskellDbDatum
dbDatumPtrIn)
(IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellDbData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellDbData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO (Ptr HaskellErrorStack)
forall a. IO a -> IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr HaskellErrorStack) -> IO (Ptr HaskellErrorStack))
-> (Ptr HaskellDbData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellDbData
-> IO (Ptr HaskellErrorStack)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr -> Ptr HaskellDbData -> IO (Ptr HaskellErrorStack)
tango_put_device_property DeviceProxyPtr
proxyPtr)
deleteDeviceProperties :: forall m. (MonadUnliftIO m) => DeviceProxy -> [PropertyName] -> m ()
deleteDeviceProperties :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> [PropertyName] -> m ()
deleteDeviceProperties (DeviceProxy DeviceProxyPtr
proxyPtr) [PropertyName]
names =
let initialize :: m [HaskellDbDatum]
initialize :: m [HaskellDbDatum]
initialize = (PropertyName -> m HaskellDbDatum)
-> [PropertyName] -> m [HaskellDbDatum]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse PropertyName -> m HaskellDbDatum
forall (m :: * -> *).
MonadUnliftIO m =>
PropertyName -> m HaskellDbDatum
nameToDbDatum [PropertyName]
names
destroy :: [HaskellDbDatum] -> m ()
destroy :: [HaskellDbDatum] -> m ()
destroy = m [()] -> m ()
forall (f :: * -> *) a. Functor f => f a -> f ()
void (m [()] -> m ())
-> ([HaskellDbDatum] -> m [()]) -> [HaskellDbDatum] -> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. (HaskellDbDatum -> m ()) -> [HaskellDbDatum] -> m [()]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HaskellDbDatum -> m ()
forall (m :: * -> *). MonadUnliftIO m => HaskellDbDatum -> m ()
freeDbDatum
in m [HaskellDbDatum]
-> ([HaskellDbDatum] -> m ()) -> ([HaskellDbDatum] -> m ()) -> m ()
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket
m [HaskellDbDatum]
initialize
[HaskellDbDatum] -> m ()
destroy
\[HaskellDbDatum]
dbDatumPtrListIn ->
[HaskellDbDatum] -> (Ptr HaskellDbDatum -> m ()) -> m ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
[a] -> (Ptr a -> m b) -> m b
withArray [HaskellDbDatum]
dbDatumPtrListIn \Ptr HaskellDbDatum
dbDatumPtrIn ->
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$
HaskellDbData -> (Ptr HaskellDbData -> IO ()) -> IO ()
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with
(Word32 -> Ptr HaskellDbDatum -> HaskellDbData
HaskellDbData (Int -> Word32
forall a b. (Integral a, Num b) => a -> b
fromIntegral ([PropertyName] -> Int
forall a. [a] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
length [PropertyName]
names)) Ptr HaskellDbDatum
dbDatumPtrIn)
(IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> (Ptr HaskellDbData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellDbData
-> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> IO (Ptr HaskellErrorStack)
forall a. IO a -> IO a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr HaskellErrorStack) -> IO (Ptr HaskellErrorStack))
-> (Ptr HaskellDbData -> IO (Ptr HaskellErrorStack))
-> Ptr HaskellDbData
-> IO (Ptr HaskellErrorStack)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr -> Ptr HaskellDbData -> IO (Ptr HaskellErrorStack)
tango_delete_device_property DeviceProxyPtr
proxyPtr)
lockDevice :: (MonadUnliftIO m) => DeviceProxy -> m ()
lockDevice :: forall (m :: * -> *). MonadUnliftIO m => DeviceProxy -> m ()
lockDevice (DeviceProxy DeviceProxyPtr
proxyPtr) = (m (Ptr HaskellErrorStack) -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (m (Ptr HaskellErrorStack) -> m ())
-> (DeviceProxyPtr -> m (Ptr HaskellErrorStack))
-> DeviceProxyPtr
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> m (Ptr HaskellErrorStack)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr HaskellErrorStack) -> m (Ptr HaskellErrorStack))
-> (DeviceProxyPtr -> IO (Ptr HaskellErrorStack))
-> DeviceProxyPtr
-> m (Ptr HaskellErrorStack)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_lock) DeviceProxyPtr
proxyPtr
unlockDevice :: (MonadUnliftIO m) => DeviceProxy -> m ()
unlockDevice :: forall (m :: * -> *). MonadUnliftIO m => DeviceProxy -> m ()
unlockDevice (DeviceProxy DeviceProxyPtr
proxyPtr) = (m (Ptr HaskellErrorStack) -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (m (Ptr HaskellErrorStack) -> m ())
-> (DeviceProxyPtr -> m (Ptr HaskellErrorStack))
-> DeviceProxyPtr
-> m ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. IO (Ptr HaskellErrorStack) -> m (Ptr HaskellErrorStack)
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr HaskellErrorStack) -> m (Ptr HaskellErrorStack))
-> (DeviceProxyPtr -> IO (Ptr HaskellErrorStack))
-> DeviceProxyPtr
-> m (Ptr HaskellErrorStack)
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_unlock) DeviceProxyPtr
proxyPtr
withLocked :: (MonadUnliftIO m) => DeviceProxy -> m () -> m ()
withLocked :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> m () -> m ()
withLocked DeviceProxy
device m ()
f = m () -> (() -> m ()) -> (() -> m ()) -> m ()
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket (DeviceProxy -> m ()
forall (m :: * -> *). MonadUnliftIO m => DeviceProxy -> m ()
lockDevice DeviceProxy
device) (\()
_ -> DeviceProxy -> m ()
forall (m :: * -> *). MonadUnliftIO m => DeviceProxy -> m ()
unlockDevice DeviceProxy
device) (m () -> () -> m ()
forall a b. a -> b -> a
const m ()
f)
newtype Milliseconds = Milliseconds Int
instance Show Milliseconds where
show :: Milliseconds -> String
show (Milliseconds Int
ms) = Int -> String
forall a. Show a => a -> String
show Int
ms String -> ShowS
forall a. Semigroup a => a -> a -> a
<> String
"ms"
setTimeout :: (MonadUnliftIO m) => DeviceProxy -> Milliseconds -> m ()
setTimeout :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> Milliseconds -> m ()
setTimeout (DeviceProxy DeviceProxyPtr
proxy) (Milliseconds Int
ms) = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> IO (Ptr HaskellErrorStack) -> IO ()
forall a b. (a -> b) -> a -> b
$ DeviceProxyPtr -> CInt -> IO (Ptr HaskellErrorStack)
tango_set_timeout_millis DeviceProxyPtr
proxy (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ms)
getTimeout :: (MonadUnliftIO m) => DeviceProxy -> m Milliseconds
getTimeout :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> m Milliseconds
getTimeout (DeviceProxy DeviceProxyPtr
proxy) = IO Milliseconds -> m Milliseconds
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Milliseconds -> m Milliseconds)
-> IO Milliseconds -> m Milliseconds
forall a b. (a -> b) -> a -> b
$ CInt -> (Ptr CInt -> IO Milliseconds) -> IO Milliseconds
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with CInt
0 \Ptr CInt
intPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr -> Ptr CInt -> IO (Ptr HaskellErrorStack)
tango_get_timeout_millis DeviceProxyPtr
proxy Ptr CInt
intPtr)
CInt
intValue <- Ptr CInt -> IO CInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CInt
intPtr
Milliseconds -> IO Milliseconds
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> Milliseconds
Milliseconds (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
intValue))
pollCommand :: (MonadUnliftIO m) => DeviceProxy -> CommandName -> Milliseconds -> m ()
pollCommand :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> Milliseconds -> m ()
pollCommand (DeviceProxy DeviceProxyPtr
proxy) (CommandName Text
commandName) (Milliseconds Int
ms) = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
commandName \CString
commandNameC -> IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr -> CString -> CInt -> IO (Ptr HaskellErrorStack)
tango_poll_command DeviceProxyPtr
proxy CString
commandNameC (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ms))
stopPollCommand :: (MonadUnliftIO m) => DeviceProxy -> CommandName -> m ()
stopPollCommand :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> m ()
stopPollCommand (DeviceProxy DeviceProxyPtr
proxy) (CommandName Text
commandName) = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
commandName (IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> (CString -> IO (Ptr HaskellErrorStack)) -> CString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr -> CString -> IO (Ptr HaskellErrorStack)
tango_stop_poll_command DeviceProxyPtr
proxy)
pollAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> Milliseconds -> m ()
pollAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> Milliseconds -> m ()
pollAttribute (DeviceProxy DeviceProxyPtr
proxy) (AttributeName Text
attributeName) (Milliseconds Int
ms) = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName \CString
attributeNameC -> IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr -> CString -> CInt -> IO (Ptr HaskellErrorStack)
tango_poll_attribute DeviceProxyPtr
proxy CString
attributeNameC (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int
ms))
stopPollAttribute :: (MonadUnliftIO m) => DeviceProxy -> AttributeName -> m ()
stopPollAttribute :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> AttributeName -> m ()
stopPollAttribute (DeviceProxy DeviceProxyPtr
proxy) (AttributeName Text
attributeName) = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO ()) -> IO ()
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeName (IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (IO (Ptr HaskellErrorStack) -> IO ())
-> (CString -> IO (Ptr HaskellErrorStack)) -> CString -> IO ()
forall b c a. (b -> c) -> (a -> b) -> a -> c
. DeviceProxyPtr -> CString -> IO (Ptr HaskellErrorStack)
tango_stop_poll_attribute DeviceProxyPtr
proxy)
data DisplayLevel = Operator | Expert deriving (Int -> DisplayLevel -> ShowS
[DisplayLevel] -> ShowS
DisplayLevel -> String
(Int -> DisplayLevel -> ShowS)
-> (DisplayLevel -> String)
-> ([DisplayLevel] -> ShowS)
-> Show DisplayLevel
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> DisplayLevel -> ShowS
showsPrec :: Int -> DisplayLevel -> ShowS
$cshow :: DisplayLevel -> String
show :: DisplayLevel -> String
$cshowList :: [DisplayLevel] -> ShowS
showList :: [DisplayLevel] -> ShowS
Show, Int -> DisplayLevel
DisplayLevel -> Int
DisplayLevel -> [DisplayLevel]
DisplayLevel -> DisplayLevel
DisplayLevel -> DisplayLevel -> [DisplayLevel]
DisplayLevel -> DisplayLevel -> DisplayLevel -> [DisplayLevel]
(DisplayLevel -> DisplayLevel)
-> (DisplayLevel -> DisplayLevel)
-> (Int -> DisplayLevel)
-> (DisplayLevel -> Int)
-> (DisplayLevel -> [DisplayLevel])
-> (DisplayLevel -> DisplayLevel -> [DisplayLevel])
-> (DisplayLevel -> DisplayLevel -> [DisplayLevel])
-> (DisplayLevel -> DisplayLevel -> DisplayLevel -> [DisplayLevel])
-> Enum DisplayLevel
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: DisplayLevel -> DisplayLevel
succ :: DisplayLevel -> DisplayLevel
$cpred :: DisplayLevel -> DisplayLevel
pred :: DisplayLevel -> DisplayLevel
$ctoEnum :: Int -> DisplayLevel
toEnum :: Int -> DisplayLevel
$cfromEnum :: DisplayLevel -> Int
fromEnum :: DisplayLevel -> Int
$cenumFrom :: DisplayLevel -> [DisplayLevel]
enumFrom :: DisplayLevel -> [DisplayLevel]
$cenumFromThen :: DisplayLevel -> DisplayLevel -> [DisplayLevel]
enumFromThen :: DisplayLevel -> DisplayLevel -> [DisplayLevel]
$cenumFromTo :: DisplayLevel -> DisplayLevel -> [DisplayLevel]
enumFromTo :: DisplayLevel -> DisplayLevel -> [DisplayLevel]
$cenumFromThenTo :: DisplayLevel -> DisplayLevel -> DisplayLevel -> [DisplayLevel]
enumFromThenTo :: DisplayLevel -> DisplayLevel -> DisplayLevel -> [DisplayLevel]
Enum, DisplayLevel
DisplayLevel -> DisplayLevel -> Bounded DisplayLevel
forall a. a -> a -> Bounded a
$cminBound :: DisplayLevel
minBound :: DisplayLevel
$cmaxBound :: DisplayLevel
maxBound :: DisplayLevel
Bounded, DisplayLevel -> DisplayLevel -> Bool
(DisplayLevel -> DisplayLevel -> Bool)
-> (DisplayLevel -> DisplayLevel -> Bool) -> Eq DisplayLevel
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: DisplayLevel -> DisplayLevel -> Bool
== :: DisplayLevel -> DisplayLevel -> Bool
$c/= :: DisplayLevel -> DisplayLevel -> Bool
/= :: DisplayLevel -> DisplayLevel -> Bool
Eq)
data CommandInfo = CommandInfo
{ CommandInfo -> Text
commandInfoName :: !Text,
CommandInfo -> Int
commandInfoTag :: !Int,
CommandInfo -> HaskellTangoDataType
commandInfoInType :: !HaskellTangoDataType,
CommandInfo -> HaskellTangoDataType
commandInfoOutType :: !HaskellTangoDataType,
CommandInfo -> Text
commandInfoInTypeDesc :: !Text,
CommandInfo -> Text
commandInfoOutTypeDesc :: !Text,
CommandInfo -> DisplayLevel
commandInfoDisplayLevel :: !DisplayLevel
}
deriving (Int -> CommandInfo -> ShowS
[CommandInfo] -> ShowS
CommandInfo -> String
(Int -> CommandInfo -> ShowS)
-> (CommandInfo -> String)
-> ([CommandInfo] -> ShowS)
-> Show CommandInfo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> CommandInfo -> ShowS
showsPrec :: Int -> CommandInfo -> ShowS
$cshow :: CommandInfo -> String
show :: CommandInfo -> String
$cshowList :: [CommandInfo] -> ShowS
showList :: [CommandInfo] -> ShowS
Show)
convertCommandInfo :: HaskellCommandInfo -> IO CommandInfo
convertCommandInfo :: HaskellCommandInfo -> IO CommandInfo
convertCommandInfo (HaskellCommandInfo {CString
cmdName :: HaskellCommandInfo -> CString
cmdName :: CString
cmdName, Int32
cmdTag :: HaskellCommandInfo -> Int32
cmdTag :: Int32
cmdTag, Int32
cmdInType :: HaskellCommandInfo -> Int32
cmdInType :: Int32
cmdInType, Int32
cmdOutType :: HaskellCommandInfo -> Int32
cmdOutType :: Int32
cmdOutType, CString
cmdInTypeDesc :: HaskellCommandInfo -> CString
cmdInTypeDesc :: CString
cmdInTypeDesc, CString
cmdOutTypeDesc :: HaskellCommandInfo -> CString
cmdOutTypeDesc :: CString
cmdOutTypeDesc, CInt
cmdDisplayLevel :: HaskellCommandInfo -> CInt
cmdDisplayLevel :: CInt
cmdDisplayLevel}) =
Text
-> Int
-> HaskellTangoDataType
-> HaskellTangoDataType
-> Text
-> Text
-> DisplayLevel
-> CommandInfo
CommandInfo
(Text
-> Int
-> HaskellTangoDataType
-> HaskellTangoDataType
-> Text
-> Text
-> DisplayLevel
-> CommandInfo)
-> IO Text
-> IO
(Int
-> HaskellTangoDataType
-> HaskellTangoDataType
-> Text
-> Text
-> DisplayLevel
-> CommandInfo)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> CString -> IO Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText CString
cmdName
IO
(Int
-> HaskellTangoDataType
-> HaskellTangoDataType
-> Text
-> Text
-> DisplayLevel
-> CommandInfo)
-> IO Int
-> IO
(HaskellTangoDataType
-> HaskellTangoDataType
-> Text
-> Text
-> DisplayLevel
-> CommandInfo)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> Int -> IO Int
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
cmdTag)
IO
(HaskellTangoDataType
-> HaskellTangoDataType
-> Text
-> Text
-> DisplayLevel
-> CommandInfo)
-> IO HaskellTangoDataType
-> IO
(HaskellTangoDataType
-> Text -> Text -> DisplayLevel -> CommandInfo)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> HaskellTangoDataType -> IO HaskellTangoDataType
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> HaskellTangoDataType
forall a. Enum a => Int -> a
toEnum (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
cmdInType))
IO
(HaskellTangoDataType
-> Text -> Text -> DisplayLevel -> CommandInfo)
-> IO HaskellTangoDataType
-> IO (Text -> Text -> DisplayLevel -> CommandInfo)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> HaskellTangoDataType -> IO HaskellTangoDataType
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> HaskellTangoDataType
forall a. Enum a => Int -> a
toEnum (Int32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral Int32
cmdOutType))
IO (Text -> Text -> DisplayLevel -> CommandInfo)
-> IO Text -> IO (Text -> DisplayLevel -> CommandInfo)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CString -> IO Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText CString
cmdInTypeDesc
IO (Text -> DisplayLevel -> CommandInfo)
-> IO Text -> IO (DisplayLevel -> CommandInfo)
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> CString -> IO Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText CString
cmdOutTypeDesc
IO (DisplayLevel -> CommandInfo)
-> IO DisplayLevel -> IO CommandInfo
forall a b. IO (a -> b) -> IO a -> IO b
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
<*> DisplayLevel -> IO DisplayLevel
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Int -> DisplayLevel
forall a. Enum a => Int -> a
toEnum (CInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral CInt
cmdDisplayLevel))
commandListQuery :: (MonadUnliftIO m) => DeviceProxy -> m [CommandInfo]
commandListQuery :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> m [CommandInfo]
commandListQuery (DeviceProxy DeviceProxyPtr
proxy) = IO [CommandInfo] -> m [CommandInfo]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [CommandInfo] -> m [CommandInfo])
-> IO [CommandInfo] -> m [CommandInfo]
forall a b. (a -> b) -> a -> b
$ HaskellCommandInfoList
-> (Ptr HaskellCommandInfoList -> IO [CommandInfo])
-> IO [CommandInfo]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (Word32 -> Ptr HaskellCommandInfo -> HaskellCommandInfoList
HaskellCommandInfoList Word32
0 Ptr HaskellCommandInfo
forall a. Ptr a
nullPtr) \Ptr HaskellCommandInfoList
infoListPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> Ptr HaskellCommandInfoList -> IO (Ptr HaskellErrorStack)
tango_command_list_query DeviceProxyPtr
proxy Ptr HaskellCommandInfoList
infoListPtr)
HaskellCommandInfoList
infoList <- Ptr HaskellCommandInfoList -> IO HaskellCommandInfoList
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellCommandInfoList
infoListPtr
[HaskellCommandInfo]
converted <- Int -> Ptr HaskellCommandInfo -> IO [HaskellCommandInfo]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellCommandInfoList -> Word32
commandInfoLength HaskellCommandInfoList
infoList)) (HaskellCommandInfoList -> Ptr HaskellCommandInfo
commandInfoSequence HaskellCommandInfoList
infoList)
[CommandInfo]
result <- (HaskellCommandInfo -> IO CommandInfo)
-> [HaskellCommandInfo] -> IO [CommandInfo]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse HaskellCommandInfo -> IO CommandInfo
convertCommandInfo [HaskellCommandInfo]
converted
Ptr HaskellCommandInfoList -> IO ()
tango_free_CommandInfoList Ptr HaskellCommandInfoList
infoListPtr
[CommandInfo] -> IO [CommandInfo]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [CommandInfo]
result
commandQuery :: (MonadUnliftIO m) => DeviceProxy -> CommandName -> m CommandInfo
commandQuery :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> CommandName -> m CommandInfo
commandQuery (DeviceProxy DeviceProxyPtr
proxy) (CommandName Text
commandName) = IO CommandInfo -> m CommandInfo
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO CommandInfo -> m CommandInfo)
-> IO CommandInfo -> m CommandInfo
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO CommandInfo) -> IO CommandInfo
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
commandName \CString
commandNamePtr -> (Ptr HaskellCommandInfo -> IO CommandInfo) -> IO CommandInfo
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr HaskellCommandInfo
commandInfoPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString -> Ptr HaskellCommandInfo -> IO (Ptr HaskellErrorStack)
tango_command_query DeviceProxyPtr
proxy CString
commandNamePtr Ptr HaskellCommandInfo
commandInfoPtr)
HaskellCommandInfo
commandInfoC <- Ptr HaskellCommandInfo -> IO HaskellCommandInfo
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellCommandInfo
commandInfoPtr
CommandInfo
result <- HaskellCommandInfo -> IO CommandInfo
convertCommandInfo HaskellCommandInfo
commandInfoC
Ptr HaskellCommandInfo -> IO ()
tango_free_CommandInfo Ptr HaskellCommandInfo
commandInfoPtr
CommandInfo -> IO CommandInfo
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure CommandInfo
result
getAttributeNames :: (MonadUnliftIO m) => DeviceProxy -> m [AttributeName]
getAttributeNames :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> m [AttributeName]
getAttributeNames (DeviceProxy DeviceProxyPtr
proxy) = IO [AttributeName] -> m [AttributeName]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [AttributeName] -> m [AttributeName])
-> IO [AttributeName] -> m [AttributeName]
forall a b. (a -> b) -> a -> b
$ HaskellTangoVarArray CString
-> (Ptr (HaskellTangoVarArray CString) -> IO [AttributeName])
-> IO [AttributeName]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
a -> (Ptr a -> m b) -> m b
with (Word32 -> Ptr CString -> HaskellTangoVarArray CString
forall a. Word32 -> Ptr a -> HaskellTangoVarArray a
HaskellTangoVarArray Word32
0 Ptr CString
forall a. Ptr a
nullPtr) \Ptr (HaskellTangoVarArray CString)
nameListPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> Ptr (HaskellTangoVarArray CString) -> IO (Ptr HaskellErrorStack)
tango_get_attribute_list DeviceProxyPtr
proxy Ptr (HaskellTangoVarArray CString)
nameListPtr)
HaskellTangoVarArray CString
nameList <- Ptr (HaskellTangoVarArray CString)
-> IO (HaskellTangoVarArray CString)
forall a. Storable a => Ptr a -> IO a
peek Ptr (HaskellTangoVarArray CString)
nameListPtr
[CString]
names <- Int -> Ptr CString -> IO [CString]
forall (m :: * -> *) a.
(MonadIO m, Storable a) =>
Int -> Ptr a -> m [a]
peekArray (Word32 -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral (HaskellTangoVarArray CString -> Word32
forall a. HaskellTangoVarArray a -> Word32
varArrayLength HaskellTangoVarArray CString
nameList)) (HaskellTangoVarArray CString -> Ptr CString
forall a. HaskellTangoVarArray a -> Ptr a
varArrayValues HaskellTangoVarArray CString
nameList)
[AttributeName]
result <- (CString -> IO AttributeName) -> [CString] -> IO [AttributeName]
forall (t :: * -> *) (f :: * -> *) a b.
(Traversable t, Applicative f) =>
(a -> f b) -> t a -> f (t b)
forall (f :: * -> *) a b.
Applicative f =>
(a -> f b) -> [a] -> f [b]
traverse ((Text -> AttributeName
AttributeName (Text -> AttributeName) -> IO Text -> IO AttributeName
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$>) (IO Text -> IO AttributeName)
-> (CString -> IO Text) -> CString -> IO AttributeName
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CString -> IO Text
forall (m :: * -> *). MonadUnliftIO m => CString -> m Text
peekCStringText) [CString]
names
Ptr (HaskellTangoVarArray CString) -> IO ()
tango_free_VarStringArray Ptr (HaskellTangoVarArray CString)
nameListPtr
[AttributeName] -> IO [AttributeName]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure [AttributeName]
result
createDatabaseProxy :: (MonadUnliftIO m) => m DatabaseProxy
createDatabaseProxy :: forall (m :: * -> *). MonadUnliftIO m => m DeviceProxyPtr
createDatabaseProxy = IO DeviceProxyPtr -> m DeviceProxyPtr
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO DeviceProxyPtr -> m DeviceProxyPtr)
-> IO DeviceProxyPtr -> m DeviceProxyPtr
forall a b. (a -> b) -> a -> b
$ (Ptr DeviceProxyPtr -> IO DeviceProxyPtr) -> IO DeviceProxyPtr
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr DeviceProxyPtr
databaseProxyPtrPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (Ptr DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_create_database_proxy Ptr DeviceProxyPtr
databaseProxyPtrPtr)
Ptr DeviceProxyPtr -> IO DeviceProxyPtr
forall a. Storable a => Ptr a -> IO a
peek Ptr DeviceProxyPtr
databaseProxyPtrPtr
deleteDatabaseProxy :: (MonadUnliftIO m) => DatabaseProxy -> m ()
deleteDatabaseProxy :: forall (m :: * -> *). MonadUnliftIO m => DeviceProxyPtr -> m ()
deleteDatabaseProxy DeviceProxyPtr
proxy = IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr -> IO (Ptr HaskellErrorStack)
tango_delete_database_proxy DeviceProxyPtr
proxy))
withDatabaseProxy :: (MonadUnliftIO m) => (DatabaseProxy -> m a) -> m a
withDatabaseProxy :: forall (m :: * -> *) a.
MonadUnliftIO m =>
(DeviceProxyPtr -> m a) -> m a
withDatabaseProxy = m DeviceProxyPtr
-> (DeviceProxyPtr -> m ()) -> (DeviceProxyPtr -> m a) -> m a
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket m DeviceProxyPtr
forall (m :: * -> *). MonadUnliftIO m => m DeviceProxyPtr
createDatabaseProxy DeviceProxyPtr -> m ()
forall (m :: * -> *). MonadUnliftIO m => DeviceProxyPtr -> m ()
deleteDatabaseProxy
databaseSearchByDeviceName :: (MonadUnliftIO m) => DatabaseProxy -> Text -> m [Text]
databaseSearchByDeviceName :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxyPtr -> Text -> m [Text]
databaseSearchByDeviceName DeviceProxyPtr
proxy Text
nameFilter = IO [Text] -> m [Text]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
nameFilter \CString
deviceNamePtr -> (Ptr HaskellDbDatum -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr HaskellDbDatum
dbDatumPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString -> Ptr HaskellDbDatum -> IO (Ptr HaskellErrorStack)
tango_get_device_exported DeviceProxyPtr
proxy CString
deviceNamePtr Ptr HaskellDbDatum
dbDatumPtr)
HaskellDbDatum
dbDatum <- Ptr HaskellDbDatum -> IO HaskellDbDatum
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellDbDatum
dbDatumPtr
Property
result <- HaskellDbDatum -> IO Property
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellDbDatum -> m Property
convertDbDatum HaskellDbDatum
dbDatum
Ptr HaskellDbDatum -> IO ()
tango_free_DbDatum Ptr HaskellDbDatum
dbDatumPtr
[Text] -> IO [Text]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> [Text]
propertyData Property
result)
databaseSearchByClass :: (MonadUnliftIO m) => DatabaseProxy -> Text -> m [Text]
databaseSearchByClass :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxyPtr -> Text -> m [Text]
databaseSearchByClass DeviceProxyPtr
proxy Text
classFilter = IO [Text] -> m [Text]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
classFilter \CString
classNamePtr -> (Ptr HaskellDbDatum -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr HaskellDbDatum
dbDatumPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString -> Ptr HaskellDbDatum -> IO (Ptr HaskellErrorStack)
tango_get_device_exported_for_class DeviceProxyPtr
proxy CString
classNamePtr Ptr HaskellDbDatum
dbDatumPtr)
HaskellDbDatum
dbDatum <- Ptr HaskellDbDatum -> IO HaskellDbDatum
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellDbDatum
dbDatumPtr
Property
result <- HaskellDbDatum -> IO Property
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellDbDatum -> m Property
convertDbDatum HaskellDbDatum
dbDatum
Ptr HaskellDbDatum -> IO ()
tango_free_DbDatum Ptr HaskellDbDatum
dbDatumPtr
[Text] -> IO [Text]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> [Text]
propertyData Property
result)
databaseSearchObjectsByName :: (MonadUnliftIO m) => DatabaseProxy -> Text -> m [Text]
databaseSearchObjectsByName :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxyPtr -> Text -> m [Text]
databaseSearchObjectsByName DeviceProxyPtr
proxy Text
nameFilter = IO [Text] -> m [Text]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
nameFilter \CString
nameFilterPtr -> (Ptr HaskellDbDatum -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr HaskellDbDatum
dbDatumPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString -> Ptr HaskellDbDatum -> IO (Ptr HaskellErrorStack)
tango_get_object_list DeviceProxyPtr
proxy CString
nameFilterPtr Ptr HaskellDbDatum
dbDatumPtr)
HaskellDbDatum
dbDatum <- Ptr HaskellDbDatum -> IO HaskellDbDatum
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellDbDatum
dbDatumPtr
Property
result <- HaskellDbDatum -> IO Property
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellDbDatum -> m Property
convertDbDatum HaskellDbDatum
dbDatum
Ptr HaskellDbDatum -> IO ()
tango_free_DbDatum Ptr HaskellDbDatum
dbDatumPtr
[Text] -> IO [Text]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> [Text]
propertyData Property
result)
databaseSearchObjectPropertiesByName :: (MonadUnliftIO m) => DatabaseProxy -> Text -> Text -> m [Text]
databaseSearchObjectPropertiesByName :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxyPtr -> Text -> Text -> m [Text]
databaseSearchObjectPropertiesByName DeviceProxyPtr
proxy Text
objectName Text
nameFilter = IO [Text] -> m [Text]
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ Text -> (CString -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
objectName \CString
objectNamePtr -> Text -> (CString -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
nameFilter \CString
nameFilterPtr -> (Ptr HaskellDbDatum -> IO [Text]) -> IO [Text]
forall (m :: * -> *) a b.
(MonadUnliftIO m, Storable a) =>
(Ptr a -> m b) -> m b
alloca \Ptr HaskellDbDatum
dbDatumPtr -> do
IO (Ptr HaskellErrorStack) -> IO ()
forall (m :: * -> *).
MonadUnliftIO m =>
m (Ptr HaskellErrorStack) -> m ()
checkResult (DeviceProxyPtr
-> CString
-> CString
-> Ptr HaskellDbDatum
-> IO (Ptr HaskellErrorStack)
tango_get_object_property_list DeviceProxyPtr
proxy CString
objectNamePtr CString
nameFilterPtr Ptr HaskellDbDatum
dbDatumPtr)
HaskellDbDatum
dbDatum <- Ptr HaskellDbDatum -> IO HaskellDbDatum
forall a. Storable a => Ptr a -> IO a
peek Ptr HaskellDbDatum
dbDatumPtr
Property
result <- HaskellDbDatum -> IO Property
forall (m :: * -> *).
MonadUnliftIO m =>
HaskellDbDatum -> m Property
convertDbDatum HaskellDbDatum
dbDatum
Ptr HaskellDbDatum -> IO ()
tango_free_DbDatum Ptr HaskellDbDatum
dbDatumPtr
[Text] -> IO [Text]
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (Property -> [Text]
propertyData Property
result)
data SubscribedEvent = SubscribedEvent (Ptr ()) CInt
type EventCallback m =
AttributeName ->
Bool ->
m ()
subscribeEvent ::
forall m.
(MonadUnliftIO m) =>
DeviceProxy ->
AttributeName ->
EventType ->
Bool ->
EventCallback m ->
m SubscribedEvent
subscribeEvent :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy
-> AttributeName
-> EventType
-> Bool
-> EventCallback m
-> m SubscribedEvent
subscribeEvent (DeviceProxy DeviceProxyPtr
proxyPtr) attributeName :: AttributeName
attributeName@(AttributeName Text
attributeNameText) EventType
eventType Bool
stateless EventCallback m
eventCallback = ((forall a. m a -> IO a) -> IO SubscribedEvent)
-> m SubscribedEvent
forall b. ((forall a. m a -> IO a) -> IO b) -> m b
forall (m :: * -> *) b.
MonadUnliftIO m =>
((forall a. m a -> IO a) -> IO b) -> m b
withRunInIO \forall a. m a -> IO a
run -> do
let realCallback :: Ptr () -> CString -> Bool -> IO ()
realCallback :: DeviceProxyPtr -> CString -> Bool -> IO ()
realCallback DeviceProxyPtr
_ CString
_ Bool
bool = m () -> IO ()
forall a. m a -> IO a
run (EventCallback m
eventCallback AttributeName
attributeName Bool
bool)
FunPtr (DeviceProxyPtr -> CString -> Bool -> IO ())
convertedCallback <- (DeviceProxyPtr -> CString -> Bool -> IO ())
-> IO (FunPtr (DeviceProxyPtr -> CString -> Bool -> IO ()))
createEventCallbackWrapper DeviceProxyPtr -> CString -> Bool -> IO ()
realCallback
DeviceProxyPtr
callbackInTango <- FunPtr (DeviceProxyPtr -> CString -> Bool -> IO ())
-> IO DeviceProxyPtr
tango_create_event_callback FunPtr (DeviceProxyPtr -> CString -> Bool -> IO ())
convertedCallback
Text -> (CString -> IO SubscribedEvent) -> IO SubscribedEvent
forall (m :: * -> *) a.
MonadUnliftIO m =>
Text -> (CString -> m a) -> m a
withCStringText Text
attributeNameText \CString
attributeNameC -> do
CInt
eventId <- DeviceProxyPtr
-> CString -> CInt -> DeviceProxyPtr -> CBool -> IO CInt
tango_subscribe_event DeviceProxyPtr
proxyPtr CString
attributeNameC (Int -> CInt
forall a b. (Integral a, Num b) => a -> b
fromIntegral (EventType -> Int
forall a. Enum a => a -> Int
fromEnum EventType
eventType)) DeviceProxyPtr
callbackInTango (if Bool
stateless then CBool
1 else CBool
0)
SubscribedEvent -> IO SubscribedEvent
forall a. a -> IO a
forall (f :: * -> *) a. Applicative f => a -> f a
pure (DeviceProxyPtr -> CInt -> SubscribedEvent
SubscribedEvent DeviceProxyPtr
callbackInTango CInt
eventId)
unsubscribeEvent :: (MonadUnliftIO m) => DeviceProxy -> SubscribedEvent -> m ()
unsubscribeEvent :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> SubscribedEvent -> m ()
unsubscribeEvent (DeviceProxy DeviceProxyPtr
proxyPtr) (SubscribedEvent DeviceProxyPtr
callbackPtr CInt
eventId) = do
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DeviceProxyPtr -> CInt -> IO ()
tango_unsubscribe_event DeviceProxyPtr
proxyPtr CInt
eventId)
IO () -> m ()
forall a. IO a -> m a
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (DeviceProxyPtr -> IO ()
tango_free_event_callback DeviceProxyPtr
callbackPtr)
withSubscribedEvent ::
(MonadUnliftIO m) =>
DeviceProxy ->
AttributeName ->
EventType ->
Bool ->
EventCallback m ->
m () ->
m ()
withSubscribedEvent :: forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy
-> AttributeName
-> EventType
-> Bool
-> EventCallback m
-> m ()
-> m ()
withSubscribedEvent DeviceProxy
proxy AttributeName
attributeName EventType
eventType Bool
stateless EventCallback m
eventCallback m ()
f =
m SubscribedEvent
-> (SubscribedEvent -> m ()) -> (SubscribedEvent -> m ()) -> m ()
forall (m :: * -> *) a b c.
MonadUnliftIO m =>
m a -> (a -> m b) -> (a -> m c) -> m c
bracket (DeviceProxy
-> AttributeName
-> EventType
-> Bool
-> EventCallback m
-> m SubscribedEvent
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy
-> AttributeName
-> EventType
-> Bool
-> EventCallback m
-> m SubscribedEvent
subscribeEvent DeviceProxy
proxy AttributeName
attributeName EventType
eventType Bool
stateless EventCallback m
eventCallback) (DeviceProxy -> SubscribedEvent -> m ()
forall (m :: * -> *).
MonadUnliftIO m =>
DeviceProxy -> SubscribedEvent -> m ()
unsubscribeEvent DeviceProxy
proxy) (m () -> SubscribedEvent -> m ()
forall a b. a -> b -> a
const m ()
f)