view src/main/java/alice/test/codesegment/remote/RemoteIncrement.java @ 655:1c93e82e05c6 default tip

fix timestamp
author suruga
date Sat, 17 Feb 2018 00:33:00 +0900
parents e321c5ec9b58
children
line wrap: on
line source

package alice.test.codesegment.remote;

import alice.codesegment.CodeSegment;
import alice.datasegment.CommandType;
import alice.datasegment.Receiver;
import org.msgpack.type.ValueFactory;

public class RemoteIncrement extends CodeSegment {

    public Receiver num = ids.create(CommandType.TAKE);//true でCompressedDSMからtake
    public Receiver nullValue = ids.create(CommandType.TAKE);//true でCompressedDSMからtake

    RemoteIncrement() {
        num.setKey("compressedlocal", "num");
        nullValue.setKey("null-value");
    }

    /**
     * Increment DataSegment value up to 10
     */
    @Override
    public void run() {
        String z = "";
        if (num.isCompressed()){
            z = "zMP";
        }
        int num = this.num.asInteger();
        if ( nullValue.getVal() == null ) {
            System.out.println("get null value");
        }
        ods.put("null-value", ValueFactory.createNilValue());

        System.out.println("[CodeSegment" + z + "] " + num++);
        if (num == 10) System.exit(0);

        RemoteIncrement cs = new RemoteIncrement();

        if ( num % 2 == 0 )
            ods.put("compressedremote", "num", num);
        else
            ods.put("remote", "num", num);

        cs.num.setKey("compressedlocal", "num");
    }

}