public static CanAddr convertLatAddrToCanAddr(LatAddr lAddr) { CanAddr result = new CanAddr(); LatAddr tmp = new LatAddr(lAddr); byte curTup = 0x00; int i = 0; while ((tmp.A != tmp.B || tmp.A != tmp.C) && (i < Config.TREE_DEPTH)) { curTup = (byte) ((tmp.A + (2 * tmp.B) + (4 * tmp.C)) % 7); curTup &= TUPLE_MASK; result.setTuple(curTup, i); tmp.A = tmp.A - ((curTup >> 0) & 0x01); tmp.B = tmp.B - ((curTup >> 1) & 0x01); tmp.C = tmp.C - ((curTup >> 2) & 0x01); int a = tmp.A; int b = tmp.B; int c = tmp.C; tmp.A = ((4*a)+b+(2*c))/7; tmp.B = ((2*a)+(4*b)+c)/7; tmp.C = (a+(2*b)+(4*c))/7; i++; } return result; }
// Use this for initialization void Start() { Tile t = SpaceTree.getTile(new CanAddr()); t.curTemp = 300; //SpaceTree.setState(new CanAddr(), (byte) 0x02); CanAddr cAddr = new CanAddr(); cAddr.setTuple (3, 3); //SpaceTree.setState(cAddr, 0x04); this.StartCoroutine(SimUpdate(0.1f)); }