Package de.offis.mosaik.api.SimpyIoSocket

Examples of de.offis.mosaik.api.SimpyIoSocket.Request


     *
     * @throws Exception
     */
    @SuppressWarnings("unchecked")
    public void run() throws Exception {
        Request req;
        Object result;

        eventloop: while (!this.stop) {
            req = this.sock.recvRequest();

            switch (req.method) {
            case "init":
                final String sid = (String) req.args.get(0);
                result = this.sim.init(sid, req.kwargs);
                break;

            case "create":
                final int num = ((Number) req.args.get(0)).intValue();
                final String model = (String) req.args.get(1);
                result = this.sim.create(num, model, req.kwargs);
                break;

            case "step":
                final long time = ((Number) req.args.get(0)).longValue();
                final JSONObject inputs = (JSONObject) req.args.get(1);
                result = this.sim.step(time, inputs);
                break;

            case "get_data":
                final JSONObject outputs = (JSONObject) req.args.get(0);
                result = this.sim.getData(outputs);
                break;

            case "stop":
                this.stop = true;
                break eventloop;

            default:
                throw new RuntimeException("Unkown method: " + req.method);
            }
            req.reply(result);
        }
        this.sock.close();
    }
View Full Code Here

TOP

Related Classes of de.offis.mosaik.api.SimpyIoSocket.Request

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.