Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
ics-software
phoebus
Commits
405c77d1
Unverified
Commit
405c77d1
authored
Feb 25, 2022
by
Kay Kasemir
Committed by
GitHub
Feb 25, 2022
Browse files
Merge pull request #2149 from ControlSystemStudio/pva_cvt_2145
PVA: Allow setting all array types from double[]
parents
fb023c8d
97cbe31b
Pipeline
#106862
passed with stage
in 11 minutes and 33 seconds
Changes
7
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
core/pva/src/main/java/org/epics/pva/data/Convert.java
0 → 100644
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2022 Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
******************************************************************************/
package
org.epics.pva.data
;
/** Array converters
* @author Kay Kasemir
*/
public
class
Convert
{
public
static
float
[]
toFloat
(
final
double
[]
array
)
{
final
float
[]
cvt
=
new
float
[
array
.
length
];
for
(
int
i
=
0
;
i
<
cvt
.
length
;
++
i
)
cvt
[
i
]
=
(
float
)
array
[
i
];
return
cvt
;
}
public
static
long
[]
toLong
(
final
double
[]
array
)
{
final
long
[]
cvt
=
new
long
[
array
.
length
];
for
(
int
i
=
0
;
i
<
cvt
.
length
;
++
i
)
cvt
[
i
]
=
(
long
)
array
[
i
];
return
cvt
;
}
public
static
int
[]
toInt
(
final
double
[]
array
)
{
final
int
[]
cvt
=
new
int
[
array
.
length
];
for
(
int
i
=
0
;
i
<
cvt
.
length
;
++
i
)
cvt
[
i
]
=
(
int
)
array
[
i
];
return
cvt
;
}
public
static
short
[]
toShort
(
final
double
[]
array
)
{
final
short
[]
cvt
=
new
short
[
array
.
length
];
for
(
int
i
=
0
;
i
<
cvt
.
length
;
++
i
)
cvt
[
i
]
=
(
short
)
array
[
i
];
return
cvt
;
}
public
static
byte
[]
toByte
(
final
double
[]
array
)
{
final
byte
[]
cvt
=
new
byte
[
array
.
length
];
for
(
int
i
=
0
;
i
<
cvt
.
length
;
++
i
)
cvt
[
i
]
=
(
byte
)
array
[
i
];
return
cvt
;
}
}
core/pva/src/main/java/org/epics/pva/data/PVAByteArray.java
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2019-202
0
Oak Ridge National Laboratory.
* Copyright (c) 2019-202
2
Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
...
...
@@ -61,6 +61,10 @@ public class PVAByteArray extends PVAData implements PVAArray
final
byte
[]
other
=
((
PVAByteArray
)
new_value
).
value
;
value
=
Arrays
.
copyOf
(
other
,
other
.
length
);
}
else
if
(
new_value
instanceof
PVADoubleArray
)
set
(
Convert
.
toByte
(((
PVADoubleArray
)
new_value
).
get
()));
else
if
(
new_value
instanceof
double
[])
set
(
Convert
.
toByte
((
double
[])
new_value
));
else
if
(
new_value
instanceof
byte
[])
set
(((
byte
[])
new_value
));
else
if
(
new_value
instanceof
List
)
...
...
core/pva/src/main/java/org/epics/pva/data/PVAData.java
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2019 Oak Ridge National Laboratory.
* Copyright (c) 2019
-2022
Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
...
...
@@ -41,6 +41,10 @@ public abstract class PVAData
* This method allows setting the value from
* generic {@link Object}.
*
* <p>Not all types are supported,
* but the matching type as well as double and String
* generally are.
*
* @param new_value New value for this data item
* @throws Exception on error, including incompatible data type
*/
...
...
core/pva/src/main/java/org/epics/pva/data/PVAFloatArray.java
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2019-202
0
Oak Ridge National Laboratory.
* Copyright (c) 2019-202
2
Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
...
...
@@ -49,9 +49,13 @@ public class PVAFloatArray extends PVAData implements PVAArray
{
if
(
new_value
instanceof
PVAFloatArray
)
{
final
float
[]
other
=
((
PVAFloatArray
)
new_value
).
value
;
final
float
[]
other
=
((
PVAFloatArray
)
new_value
).
get
()
;
value
=
Arrays
.
copyOf
(
other
,
other
.
length
);
}
else
if
(
new_value
instanceof
PVADoubleArray
)
set
(
Convert
.
toFloat
(((
PVADoubleArray
)
new_value
).
get
()));
else
if
(
new_value
instanceof
double
[])
set
(
Convert
.
toFloat
((
double
[])
new_value
));
else
if
(
new_value
instanceof
float
[])
set
(((
float
[])
new_value
));
else
if
(
new_value
instanceof
List
)
...
...
core/pva/src/main/java/org/epics/pva/data/PVAIntArray.java
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2019-202
0
Oak Ridge National Laboratory.
* Copyright (c) 2019-202
2
Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
...
...
@@ -61,6 +61,10 @@ public class PVAIntArray extends PVAData implements PVAArray
final
int
[]
other
=
((
PVAIntArray
)
new_value
).
value
;
value
=
Arrays
.
copyOf
(
other
,
other
.
length
);
}
else
if
(
new_value
instanceof
PVADoubleArray
)
set
(
Convert
.
toInt
(((
PVADoubleArray
)
new_value
).
get
()));
else
if
(
new_value
instanceof
double
[])
set
(
Convert
.
toInt
((
double
[])
new_value
));
else
if
(
new_value
instanceof
int
[])
set
(((
int
[])
new_value
));
else
if
(
new_value
instanceof
List
)
...
...
core/pva/src/main/java/org/epics/pva/data/PVALongArray.java
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2019-202
0
Oak Ridge National Laboratory.
* Copyright (c) 2019-202
2
Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
...
...
@@ -61,6 +61,10 @@ public class PVALongArray extends PVAData implements PVAArray
final
long
[]
other
=
((
PVALongArray
)
new_value
).
value
;
value
=
Arrays
.
copyOf
(
other
,
other
.
length
);
}
else
if
(
new_value
instanceof
PVADoubleArray
)
set
(
Convert
.
toLong
(((
PVADoubleArray
)
new_value
).
get
()));
else
if
(
new_value
instanceof
double
[])
set
(
Convert
.
toLong
((
double
[])
new_value
));
else
if
(
new_value
instanceof
long
[])
set
(((
long
[])
new_value
));
else
if
(
new_value
instanceof
List
)
...
...
core/pva/src/main/java/org/epics/pva/data/PVAShortArray.java
View file @
405c77d1
/*******************************************************************************
* Copyright (c) 2019-202
0
Oak Ridge National Laboratory.
* Copyright (c) 2019-202
2
Oak Ridge National Laboratory.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
...
...
@@ -61,6 +61,10 @@ public class PVAShortArray extends PVAData implements PVAArray
final
short
[]
other
=
((
PVAShortArray
)
new_value
).
value
;
value
=
Arrays
.
copyOf
(
other
,
other
.
length
);
}
else
if
(
new_value
instanceof
PVADoubleArray
)
set
(
Convert
.
toShort
(((
PVADoubleArray
)
new_value
).
get
()));
else
if
(
new_value
instanceof
double
[])
set
(
Convert
.
toShort
((
double
[])
new_value
));
else
if
(
new_value
instanceof
short
[])
set
(((
short
[])
new_value
));
else
if
(
new_value
instanceof
List
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment