public String toString() { String result = "AgillaTSReqMsg:\n"; result += "\top = 0x" + Integer.toHexString(op) + " (" + getString(op) + ")\n"; result += "\tdest = " + dest + "\n"; result += "\treply = " + reply + "\n\ttemplate = "; if (template == null) result += template; else result += template.toString().replaceAll("\n", "\n\t"); return result; }
public net.tinyos.message.Message toTOSMsg() { AgillaTSReqMsg msg = new AgillaTSReqMsg(); msg.set_dest(dest); msg.set_reply(reply); msg.set_op(op); msg.set_template_flags(template.flags()); msg.set_template_size(template.getSize()); short dataIndex = 0; for (int i = 0; i < template.size(); i++) { AgillaStackVariable sv = template.getField(i); short[] bytes = sv.toBytes(); msg.setElement_template_data(dataIndex++, sv.getType()); // save type for (int j = 0; j < sv.getSize(); j++) { msg.setElement_template_data(dataIndex++, bytes[j]); // save var } } return msg; }
public AgillaTSReqMsgJ(AgillaTSReqMsg msg) { this.dest = msg.get_dest(); this.reply = msg.get_reply(); this.op = msg.get_op(); this.template = new Tuple(msg.get_template_flags()); short[] tupleData = msg.get_template_data(); int byteIndex = 0; for (int i = 0; i < msg.get_template_size(); i++) { AgillaStackVariable sv = VarUtil.getField(byteIndex, tupleData); template.addField(sv); byteIndex += sv.getSize() + 1; // add one for sv type } }