1
2
3
4
5 package org.epics.pvmanager.sim;
6
7 import java.util.List;
8 import java.util.logging.Logger;
9 import org.epics.pvmanager.ChannelWriteCallback;
10 import org.epics.pvmanager.MultiplexedChannelHandler;
11 import org.epics.pvmanager.util.FunctionParser;
12 import org.epics.vtype.ValueFactory;
13
14
15
16
17
18 class ConstantChannelHandler extends MultiplexedChannelHandler<Object, Object> {
19
20 private static final Logger log = Logger.getLogger(ConstantChannelHandler.class.getName());
21
22 public ConstantChannelHandler(String channelName) {
23 super(channelName);
24 List<Object> tokens = FunctionParser.parseFunctionWithScalarOrArrayArguments(channelName,
25 "Wrong syntax. Correct examples: const(3.14), const(\"Bob\"), const(1,2,3), const(\"ON\", \"OFF\"");
26 processMessage((Object) ValueFactory.toVTypeChecked(tokens.get(1)));
27 }
28
29 @Override
30 public void connect() {
31 processConnection(new Object());
32 }
33
34 @Override
35 public void disconnect() {
36 processConnection(null);
37 }
38
39 @Override
40 protected boolean saveMessageAfterDisconnect() {
41 return true;
42 }
43
44 @Override
45 public void write(Object newValue, ChannelWriteCallback callback) {
46 throw new UnsupportedOperationException("Can't write to simulation channel.");
47 }
48 }