Skip to content

Commit

Permalink
Merge 61f12c0 into 50b2268
Browse files Browse the repository at this point in the history
  • Loading branch information
balazsracz committed Mar 27, 2021
2 parents 50b2268 + 61f12c0 commit 262dffe
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions src/org/openlcb/cdi/impl/DemoReadWriteAccess.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.openlcb.cdi.impl;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
Expand All @@ -12,6 +14,9 @@
import org.jdom2.input.SAXBuilder;
import org.openlcb.implementations.MemoryConfigurationService;

import javax.swing.SwingUtilities;
import javax.swing.Timer;

/**
* Helper class for various demo and test code to put in as a fake into the ConfigRepresentation constructor.
* Created by bracz on 11/20/16.
Expand All @@ -30,10 +35,18 @@ public void doWrite(long address, int space, byte[] data, MemoryConfigurationSer
public void doRead(long address, int space, int length, MemoryConfigurationService.McsReadHandler handler) {
byte[] resp = new byte[length];
for (int i = 0; i < resp.length; ++i) {
resp[i] = (byte)(((address + i) % 91) + 32);
resp[i] = 0;//(byte)(((address + i) % 91) + 32);
}
handler.handleReadData(null, space, address, resp);
logger.log(Level.INFO, "read {0} {1}", new Object[]{address, space});
Timer t = new Timer(40, new ActionListener() {
@Override
public void actionPerformed(ActionEvent actionEvent) {
handler.handleReadData(null, space, address, resp);
logger.log(Level.ALL, "read {0} {1}", new Object[]{address, space});
System.out.println(address);
}
});
t.setRepeats(false);
t.start();
}

static public ConfigRepresentation demoRepFromSample(Element root) {
Expand Down

0 comments on commit 262dffe

Please sign in to comment.