Skip to content

Commit

Permalink
put into final form
Browse files Browse the repository at this point in the history
  • Loading branch information
carltimmer committed Jan 10, 2025
1 parent 6d06eec commit 705e882
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 4 deletions.
16 changes: 14 additions & 2 deletions java/org/jlab/coda/jevio/test/ReadWriteV4Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ static EvioBank generateEvioBank(ByteOrder order, int tag, int num) {

void writeFile(String filename, int tag, int num) {

System.out.println("--------------------------------------------");
System.out.println("---------- Write to file --------------");
System.out.println("--------------------------------------------");

ByteOrder order = ByteOrder.LITTLE_ENDIAN;

// Create a "first event"
Expand Down Expand Up @@ -109,6 +113,10 @@ void writeFile(String filename, int tag, int num) {


static void readFile(String finalFilename) throws IOException, EvioException {
System.out.println("--------------------------------------------");
System.out.println("---------- Read from file --------------");
System.out.println("--------------------------------------------");

EvioReader reader = new EvioReader(finalFilename);
ByteOrder order = reader.getByteOrder();

Expand Down Expand Up @@ -145,6 +153,10 @@ static void readFile(String finalFilename) throws IOException, EvioException {

void writeAndReadBuffer(int tag, int num) throws IOException {

System.out.println("--------------------------------------------");
System.out.println("---------- Write to buf --------------");
System.out.println("--------------------------------------------");

ByteOrder order = ByteOrder.LITTLE_ENDIAN;
ByteBuffer buffer = ByteBuffer.allocate(200000);
buffer.order(order);
Expand Down Expand Up @@ -316,15 +328,15 @@ public static void main(String args[]) {

ReadWriteV4Test tester = new ReadWriteV4Test();

//tester.writeFile(filename_j, 1, 1);
tester.writeFile(filename_j, 1, 1);
tester.readFile(filename_j);

// File cFile = new File(filename_c);
// if (cFile.exists()) {
// tester.readFile(filename_c);
// }

//tester.writeAndReadBuffer(1, 1);
tester.writeAndReadBuffer(1, 1);
}
catch (Exception e) {
e.printStackTrace();
Expand Down
20 changes: 18 additions & 2 deletions src/test/ReadWriteV4Test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ namespace evio {

void writeFile(string finalFilename, uint16_t tag, uint8_t num) {

std::cout << std::endl;
std::cout << "--------------------------------------------" << std::endl;
std::cout << "---------- Write to file --------------" << std::endl;
std::cout << "--------------------------------------------" << std::endl;

ByteOrder outputOrder = ByteOrder::ENDIAN_LITTLE;

// Create a "first event"
Expand Down Expand Up @@ -125,6 +130,12 @@ namespace evio {


void readFile(string finalFilename) {

std::cout << std::endl;
std::cout << "--------------------------------------------" << std::endl;
std::cout << "---------- Read from file --------------" << std::endl;
std::cout << "--------------------------------------------" << std::endl;

EvioReader reader(finalFilename);
ByteOrder & order = reader.getByteOrder();

Expand Down Expand Up @@ -160,6 +171,11 @@ namespace evio {

void writeAndReadBuffer(uint16_t tag, uint8_t num) {

std::cout << std::endl;
std::cout << "--------------------------------------------" << std::endl;
std::cout << "---------- Write to buf --------------" << std::endl;
std::cout << "--------------------------------------------" << std::endl;

ByteOrder order = ByteOrder::ENDIAN_LITTLE;
std::shared_ptr<ByteBuffer> buffer = std::make_shared<ByteBuffer>(200000);
buffer->order(order);
Expand Down Expand Up @@ -347,15 +363,15 @@ int main(int argc, char **argv) {

evio::ReadWriteTest tester;

//tester.writeFile(filename_c, 1,1);
tester.writeFile(filename_c, 1,1);
tester.readFile(filename_c);

// std::ifstream file(filename_j);
// if (file) {
// tester.readFile(filename_j);
// }

//tester.writeAndReadBuffer(1,1);
tester.writeAndReadBuffer(1,1);

// Buffers ...
cout << endl << endl << "----------------------------------------" << endl << endl;
Expand Down

0 comments on commit 705e882

Please sign in to comment.