Package org.scictrl.csshell.epics
Class EPICSUtilities
java.lang.Object
org.scictrl.csshell.epics.EPICSUtilities
Convenience method for work with JCA and CAJ.
- Author:
- igor@scictrl.com
-
Field Summary
Modifier and TypeFieldDescriptionstatic long
Seconds of epoch start since UTC time start. -
Method Summary
Modifier and TypeMethodDescriptionstatic final void
appendShortErrorReport
(Throwable t, Appendable buffer) appendShortErrorReport.static Timestamp
convertTimestamp
(gov.aps.jca.dbr.TimeStamp ts) Converts CA timestamp to DAL timestamp.static Object
convertToDBRValue
(Object value, gov.aps.jca.dbr.DBRType type) Convert java object to DBR value of provided DBR type.static final boolean
deepEquals
(Object o1, Object o2) deepEquals.static final BitSet
fromLong
(long value) Convertslong
value toBitSet
.static void
Puts value ofObject
parameter to theChannel
.static void
Puts value ofObject
parameter to theChannel
.static Object
suggestDefaultValue
(gov.aps.jca.dbr.DBRType type) Tries to create dummy default value for provided DBRType.static Object
suggestDefaultValue
(gov.aps.jca.dbr.DBRType type, int count) Tries to create dummy default value for provided DBRTypestatic DataType
toDataType
(gov.aps.jca.dbr.DBR dbr) Get DBR type from java object.static DataType
toDataType
(gov.aps.jca.dbr.DBRType type, int count) toDataType.static Date
toDate
(gov.aps.jca.dbr.TimeStamp ts) Converts CA timestamp to UTC Java time.static gov.aps.jca.dbr.DBRType
Get DBR type from java object.static Object
toDBRValue
(Object value, gov.aps.jca.dbr.DBRType originalType) Convert java object to DBR value, it does expect that Java value is already of right data type, so only repackaging is necessary, no deep value conversion is done.static double
Returns double value if possible orDouble.NaN
int
Returns integer value if possible orInteger.MIN_VALUE
static <T> T
toJavaValue
(gov.aps.jca.dbr.DBR dbr, Class<T> javaType, gov.aps.jca.dbr.DBRType originalType) Convert DBR to Java object.static long
Returns double value if possible orDouble.NaN
static final long
ConvertsBitSet
tolong
value if possible.static final MetaData
toMetaData
(gov.aps.jca.Channel channel, gov.aps.jca.dbr.DBR dbr) toMetaData.static final String
Checks the given type and constructs the data type name, that the given type is associated with.static final Status
toStatus
(gov.aps.jca.dbr.DBR dbr) toStatus.static String
toString.static gov.aps.jca.dbr.DBRType
toTimeDBRType
(gov.aps.jca.dbr.DBRType type) Get TIME DBR type.static gov.aps.jca.dbr.DBRType
toTimeDBRType
(DataType type) Get TIME DBR type.static Timestamp
toTimestamp
(gov.aps.jca.dbr.DBR dbr) Tries to extract timestamp from DBR.static gov.aps.jca.dbr.TimeStamp
toTimeStamp
(long utc) Converts Java (UTC) time to EPICS CA Timestamp.static long
toUTC
(gov.aps.jca.dbr.TimeStamp ts) Converts CA timestamp to UTC Java time.
-
Field Details
-
TS_EPOCH_SEC_PAST_1970
public static long TS_EPOCH_SEC_PAST_1970Seconds of epoch start since UTC time start.
-
-
Method Details
-
suggestDefaultValue
Tries to create dummy default value for provided DBRType.- Parameters:
type
- aDBRType
object- Returns:
- new dummy default, basically 0 or empty string wrapped in corresponding primitive data type
-
suggestDefaultValue
Tries to create dummy default value for provided DBRType- Parameters:
type
- the DBRType to which returned dummy should correspondcount
- the requested value count, must be larger than 0- Returns:
- new dummy default, basically 0 or empty string wrapped in corresponding primitive data type
-
toJavaValue
public static <T> T toJavaValue(gov.aps.jca.dbr.DBR dbr, Class<T> javaType, gov.aps.jca.dbr.DBRType originalType) Convert DBR to Java object.- Type Parameters:
T
- a T class- Parameters:
dbr
- DBR to convet.javaType
- type to convert to.originalType
- aDBRType
object- Returns:
- converted java object.
-
toDBRType
Get DBR type from java object.- Parameters:
type
- aDataType
object- Returns:
- DBR type.
- Throws:
gov.aps.jca.CAException
- remote exceptionNullPointerException
- parameter is null
-
toDataType
Get DBR type from java object.- Parameters:
dbr
- aDBR
object- Returns:
- DBR type.
- Throws:
NullPointerException
- parameter is null
-
toDataType
toDataType.
- Parameters:
type
- aDBRType
objectcount
- a int- Returns:
- a
DataType
object
-
toDBRValue
Convert java object to DBR value, it does expect that Java value is already of right data type, so only repackaging is necessary, no deep value conversion is done.- Parameters:
value
- java object to convert.originalType
- aDBRType
object- Returns:
- DBR value.
- Throws:
NullPointerException
- parameter is null
-
convertToDBRValue
Convert java object to DBR value of provided DBR type.- Parameters:
value
- java object to convert.type
- the channel field type of converted value- Returns:
- Object value.
- Throws:
NullPointerException
- parameter is null
-
toString
toString.
-
toDouble
Returns double value if possible orDouble.NaN
- Parameters:
v
- aObject
object- Returns:
- double value if possible or
Double.NaN
-
toLong
Returns double value if possible orDouble.NaN
- Parameters:
v
- aObject
object- Returns:
- double value if possible or
Double.NaN
-
toInteger
Returns integer value if possible orInteger.MIN_VALUE
- Parameters:
v
- aObject
object- Returns:
- integer value if possible or
Integer.MIN_VALUE
-
toTimeDBRType
Get TIME DBR type.- Parameters:
type
- DBR type.- Returns:
- TIME DBR type
- Throws:
gov.aps.jca.CAException
- remote exceptionNullPointerException
- parameter is null
-
toTimeDBRType
public static gov.aps.jca.dbr.DBRType toTimeDBRType(gov.aps.jca.dbr.DBRType type) Get TIME DBR type.- Parameters:
type
- DBR type.- Returns:
- TIME DBR type or input type if failed to convert to TIME.
- Throws:
NullPointerException
- parameter is null
-
toUTC
public static long toUTC(gov.aps.jca.dbr.TimeStamp ts) Converts CA timestamp to UTC Java time.- Parameters:
ts
- CA timestamp- Returns:
- Java UTC
-
convertTimestamp
Converts CA timestamp to DAL timestamp.- Parameters:
ts
- CA timestamp- Returns:
- DAL timestamp
-
toDate
Converts CA timestamp to UTC Java time.- Parameters:
ts
- CA timestamp- Returns:
- Java UTC
-
toLong
ConvertsBitSet
tolong
value if possible.- Parameters:
value
- theBitSet
object- Returns:
- long representatnion of the bit set
-
fromLong
Convertslong
value toBitSet
.- Parameters:
value
- the long value- Returns:
- the
BitSet
corresponding to the value
-
put
Puts value ofObject
parameter to theChannel
.- Parameters:
channel
- theChannel
to put value to.value
- theObject
parameter to put to theChannel
.- Throws:
gov.aps.jca.CAException
- remote exceptionNullPointerException
- parameter is null
-
put
public static void put(gov.aps.jca.Channel channel, Object value, gov.aps.jca.event.PutListener listener) throws gov.aps.jca.CAException Puts value ofObject
parameter to theChannel
.- Parameters:
channel
- theChannel
to put value to.value
- theObject
parameter to put to theChannel
.listener
- thePutListener
to use (ifnull
no listener is used)- Throws:
gov.aps.jca.CAException
- remote exceptionNullPointerException
- parameter is null
-
toShortErrorReport
Checks the given type and constructs the data type name, that the given type is associated with.- Parameters:
t
- aThrowable
object- Returns:
- the datatype
-
appendShortErrorReport
appendShortErrorReport.
- Parameters:
t
- aThrowable
objectbuffer
- aAppendable
object- Throws:
IOException
- if any.
-
toMetaData
toMetaData.
- Parameters:
channel
- aChannel
objectdbr
- aDBR
object- Returns:
- a
MetaData
object
-
toTimestamp
Tries to extract timestamp from DBR. If this fails, then current time is returned.- Parameters:
dbr
- reciving DBR- Returns:
- timestamp from DBR if possible or current local time
-
toTimeStamp
public static gov.aps.jca.dbr.TimeStamp toTimeStamp(long utc) Converts Java (UTC) time to EPICS CA Timestamp.- Parameters:
utc
- JAva time- Returns:
- EPICS CA TimeStamp
-
toStatus
toStatus.
- Parameters:
dbr
- aDBR
object- Returns:
- a
Status
object
-
deepEquals
deepEquals.
-