Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Benchmark/myPVAClient_Scalar.java
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
57 lines (43 sloc)
1.89 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Benchmark; | |
import org.epics.pvaClient.PvaClient; | |
import org.epics.pvaClient.PvaClientPut; | |
import org.epics.pvaClient.PvaClientPutData; | |
public class myPVAClient_Scalar { | |
public static void main(String[] args) { | |
String providerName = "pva"; | |
PvaClient pva = PvaClient.get(providerName); | |
String recordName = "myScalarDouble"; | |
long timeAtStartOfWhile, timePassedInWhileLoop; | |
double oneSecond = Math.pow(10, 9); // duration of 1 s in nano seconds | |
double putThisManySamples = 1000.0; | |
try { | |
PvaClientPut put = pva.channel(recordName, providerName).put(); | |
PvaClientPutData putData = put.getData(); | |
double[] delaysBetweenTwoSamples = new double[]{0.1}; //, 0.1, 0.01}; | |
double value = 0.0; | |
for (double delay : delaysBetweenTwoSamples) { | |
timeAtStartOfWhile = System.nanoTime(); | |
timePassedInWhileLoop = 0; | |
while (timePassedInWhileLoop <= putThisManySamples * oneSecond) { | |
value++; | |
putData.putDouble(value); | |
put.put(); | |
if (delay > 0) { | |
try { | |
Thread.sleep((long) (delay * 1000.0)); | |
} catch (InterruptedException e) { | |
e.printStackTrace(); | |
} | |
} | |
timePassedInWhileLoop = System.nanoTime() - timeAtStartOfWhile; | |
} // end of WHILE loop | |
} // end of FOR loop | |
} catch (RuntimeException e) { | |
System.err.println("exception " + e.getMessage()); | |
e.printStackTrace(System.err); | |
System.exit(1);; | |
} | |
System.out.println("\n_____putting data to the PV " + recordName + " is done_______"); | |
pva.destroy(); | |
} | |
} |