public override bool IsTransferable(ACommand c) { if (c is GetMotorsAnwerCommand) { var c2 = (GetMotorsAnwerCommand)c; MotorV1_0[] motors = new MotorV1_0[c2.MOTORS.Length]; for (int i = 0; i < motors.Length; i++) { motors[i] = new MotorV1_0(c2.MOTORS[i]); } cache.Cached(c, new GetMotorsAnwerCommandV1_0(motors)); return(true); } return(false); }
public static bool Deserialize(String orig, Deep deep, out MotorV1_0 deserialized) { string[] rest; if (ProtocolV1_0Utils.GetParams(orig, NAME, deep, out rest)) { if (rest.Length == 7) { ProtocolDouble[] paramsDouble; int[] paramsInt; if (Parser.TryParse(new int[] { 0, 1, 2, 3, 4 }, rest, out paramsDouble) && Parser.TryParse(new int[] { 5, 6 }, rest, out paramsInt)) { deserialized = new MotorV1_0(paramsDouble[0], paramsDouble[1], paramsDouble[2], paramsDouble[3], paramsDouble[4], paramsInt[0], paramsInt[1]); return(true); } } } deserialized = null; return(false); }
public override Boolean IsDeserializable(String s) { s = s.Trim(); string[] rest; if (ProtocolV1_0Utils.GetParams(s, NAME, ProtocolV1_0Utils.DEFAULT, out rest)) { if (rest.Length == 1 && ProtocolV1_0Utils.Deserialize(rest[0], out rest, ProtocolV1_0Utils.DEFAULT.NEXT)) { MotorV1_0[] motors = new MotorV1_0[rest.Length]; for (int i = 0; i < motors.Length; i++) { if (!MotorV1_0.Deserialize(rest[i], ProtocolV1_0Utils.DEFAULT.NEXT.NEXT, out motors[i])) { return(false); } } cache.Cached(s, new GetMotorsAnwerCommandV1_0(motors)); return(true); } } return(false); }