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
FieldsModifier and TypeFieldDescriptionstatic longSeconds of epoch start since UTC time start. -
Method Summary
Modifier and TypeMethodDescriptionstatic final voidappendShortErrorReport(Throwable t, Appendable buffer) appendShortErrorReport.static TimestampconvertTimestamp(gov.aps.jca.dbr.TimeStamp ts) Converts CA timestamp to DAL timestamp.static ObjectconvertToDBRValue(Object value, gov.aps.jca.dbr.DBRType type) Convert java object to DBR value of provided DBR type.static final booleandeepEquals(Object o1, Object o2) deepEquals.static final BitSetfromLong(long value) Convertslongvalue toBitSet.static voidPuts value ofObjectparameter to theChannel.static voidPuts value ofObjectparameter to theChannel.static ObjectsuggestDefaultValue(gov.aps.jca.dbr.DBRType type) Tries to create dummy default value for provided DBRType.static ObjectsuggestDefaultValue(gov.aps.jca.dbr.DBRType type, int count) Tries to create dummy default value for provided DBRTypestatic DataTypetoDataType(gov.aps.jca.dbr.DBR dbr) Get DBR type from java object.static DataTypetoDataType(gov.aps.jca.dbr.DBRType type, int count) toDataType.static DatetoDate(gov.aps.jca.dbr.TimeStamp ts) Converts CA timestamp to UTC Java time.static gov.aps.jca.dbr.DBRTypeGet DBR type from java object.static ObjecttoDBRValue(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 doubleReturns double value if possible orDouble.NaNintReturns integer value if possible orInteger.MIN_VALUEstatic <T> TtoJavaValue(gov.aps.jca.dbr.DBR dbr, Class<T> javaType, gov.aps.jca.dbr.DBRType originalType) Convert DBR to Java object.static longReturns double value if possible orDouble.NaNstatic final longConvertsBitSettolongvalue if possible.static final MetaDatatoMetaData(gov.aps.jca.Channel channel, gov.aps.jca.dbr.DBR dbr) toMetaData.static final StringChecks the given type and constructs the data type name, that the given type is associated with.static final StatustoStatus(gov.aps.jca.dbr.DBR dbr) toStatus.static StringtoString.static gov.aps.jca.dbr.DBRTypetoTimeDBRType(gov.aps.jca.dbr.DBRType type) Get TIME DBR type.static gov.aps.jca.dbr.DBRTypetoTimeDBRType(DataType type) Get TIME DBR type.static TimestamptoTimestamp(gov.aps.jca.dbr.DBR dbr) Tries to extract timestamp from DBR.static gov.aps.jca.dbr.TimeStamptoTimeStamp(long utc) Converts Java (UTC) time to EPICS CA Timestamp.static longtoUTC(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- aDBRTypeobject- 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- aDBRTypeobject- Returns:
- converted java object.
-
toDBRType
Get DBR type from java object.- Parameters:
type- aDataTypeobject- Returns:
- DBR type.
- Throws:
gov.aps.jca.CAException- remote exceptionNullPointerException- parameter is null
-
toDataType
Get DBR type from java object.- Parameters:
dbr- aDBRobject- Returns:
- DBR type.
- Throws:
NullPointerException- parameter is null
-
toDataType
toDataType.
- Parameters:
type- aDBRTypeobjectcount- a int- Returns:
- a
DataTypeobject
-
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- aDBRTypeobject- 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- aObjectobject- Returns:
- double value if possible or
Double.NaN
-
toLong
Returns double value if possible orDouble.NaN- Parameters:
v- aObjectobject- Returns:
- double value if possible or
Double.NaN
-
toInteger
Returns integer value if possible orInteger.MIN_VALUE- Parameters:
v- aObjectobject- 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
ConvertsBitSettolongvalue if possible.- Parameters:
value- theBitSetobject- Returns:
- long representatnion of the bit set
-
fromLong
Convertslongvalue toBitSet.- Parameters:
value- the long value- Returns:
- the
BitSetcorresponding to the value
-
put
Puts value ofObjectparameter to theChannel.- Parameters:
channel- theChannelto put value to.value- theObjectparameter 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 ofObjectparameter to theChannel.- Parameters:
channel- theChannelto put value to.value- theObjectparameter to put to theChannel.listener- thePutListenerto use (ifnullno 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- aThrowableobject- Returns:
- the datatype
-
appendShortErrorReport
appendShortErrorReport.
- Parameters:
t- aThrowableobjectbuffer- aAppendableobject- Throws:
IOException- if any.
-
toMetaData
toMetaData.
- Parameters:
channel- aChannelobjectdbr- aDBRobject- Returns:
- a
MetaDataobject
-
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- aDBRobject- Returns:
- a
Statusobject
-
deepEquals
deepEquals.
-