80 package adInterfaceMCC.actor;
85 import ptolemy.kernel.CompositeEntity;
86 import ptolemy.kernel.util.IllegalActionException;
87 import ptolemy.kernel.util.NameDuplicationException;
88 import ptolemy.kernel.util.Settable;
89 import ptolemy.actor.TypedIOPort;
90 import ptolemy.data.type.BaseType;
91 import ptolemy.data.Token;
92 import ptolemy.data.IntToken;
93 import ptolemy.data.expr.Parameter;
94 import java.util.ArrayList;
117 throws IllegalActionException,NameDuplicationException {
118 super(container, name);
121 input =
new TypedIOPort(
this,
"input",
true,
false);
122 input.setMultiport(
true);
128 input_tokenConsumptionRate.setExpression(
"1");
129 input_tokenConsumptionRate.setVisibility(Settable.NOT_EDITABLE);
130 input_tokenConsumptionRate.setTypeEquals(BaseType.INT);
131 input_tokenConsumptionRate.setPersistent(
false);
146 public boolean prefire() throws IllegalActionException {
147 Token rateToken = input_tokenConsumptionRate.getToken();
148 int required = ((IntToken) rateToken).intValue();
152 for (
int i = 0;
i < input.getWidth();
i++) {
153 if (!
input.hasToken(
i, required)) {
155 _debug(
"Called prefire(), "
156 +
" input tokenConsumptionRate = " + required
157 +
", input.hasToken(" +
i +
", " + required
158 +
") is false, prefire() returning false");
164 return super.prefire();
177 final int size = input.getWidth();
179 int old_size = prop_arr.size();
180 for (
int i = 0;
i < prop_arr.size();
i++)
182 if (
prop_arr.get(
i).getApplicationTag().equals(
"READ")){
183 old_size = old_size -1;
188 String em =
"The number of input '" + size +
"' is ";
193 em +=
"than the number"
194 +
LS +
"of properties found in the configuration file '" + new_size +
"'.";
195 throw new IllegalActionException(em);
207 final int n = input.getWidth();
208 Token inp[] =
new Token[n];
219 public ArrayList<ADInterfaceMCCObjectType>
addPropertyValue(Token[] inp)
throws IllegalActionException
221 ArrayList<ADInterfaceMCCObjectType> proparr =
new ArrayList<ADInterfaceMCCObjectType>();
222 ArrayList<ADInterfaceMCCObjectType> proparr_write =
new ArrayList<ADInterfaceMCCObjectType>();
224 for (
int i = 0;
i < prop_arr.size();
i++)
226 if (
prop_arr.get(
i).getApplicationTag().equals(
"WRITE")){
227 proparr_write.add(prop_arr.get(
i));
230 for (
int i = 0;
i < proparr_write.size();
i++) {
233 String boardNumber = bcp.getBoardNumber();
234 String channelNumber = bcp.getChannelNumber();
235 String channelGain = bcp.getChannelGain();
236 String channelValue = inp[
i].toString();
237 String channelOptions = bcp.getChannelOptions();
238 String apptag = bcp.getApplicationTag();
241 proparr.add(bcp_new);
277 public void fire() throws IllegalActionException {
306 bcvtbhome +
FS +
"lib" +
FS +
"ptII" +
FS +
"adInterfaceMCC" +
FS +
"ADInterfaceMCC.xsd";
This class reads the XML configuration file and stores the data in the ADInterfaceMCCObjectType data ...
static final String bcvtbhome
String that points to root directory of the BCVTB.
ArrayList< ProcessBuilder > proc_arr
Arraylist containing processes to be executed in console.
void prepareTokensToSend()
Get tokens to send for the next timestep.
static ArrayList< ADInterfaceMCCObjectType > prop_add_arr
ADInterfaceMCCObjectType after adding the value from Ptolemy.
static final String LS
Line Seperator.
Parameter input_tokenConsumptionRate
void setSchemaFileName()
Sets the schema file name.
ArrayList< ADInterfaceMCCObjectType > prop_arr
Arraylist containing ADInterfaceMCCObjectType read from configuration file.
static final String FS
File seperator.
boolean prefire()
Return true if the number of available tokens on the input port is at least the declared consumption ...
ADInterfaceMCCWriter(CompositeEntity container, String name)
Construct an actor with the given container and name.
This file compiles the BSD socket interface for Simulink It is called by ant On it requires the Microsoft compiler since matlab requires the size of output arrays to be fixed If more elements are required
void checkNumberOfInput()
Check if the number of input tokens of the actor is equal to the number of properties read from the c...
String schemaFileName
Schema file path.
ArrayList< ADInterfaceMCCObjectType > addPropertyValue(Token[] inp)
Replace the property value in ADInterfaceMCCObjectType with tokens from Ptolemy.
Token[] consumeToken()
consume token, store the token in an array.
void validateAttributes()
Validate application tag.
This actor writes to ADInterfaceMCC devices.
void removeToken()
Remove tokens in previous time step.
void initialize()
Initialize variables and check for errors.
This is an abstract base class for actors that generates an output stream.
void fire()
At each timestep write properties to ADInterfaceMCC devices.
void sendToken()
Sends the error signal to the errorSignal port, the error message to the errorMessage port...