public override bool IsTransferable(ACommand c) { if (c is GetMotorsAnswerCommand) { var c2 = (GetMotorsAnswerCommand)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 GetMotorsAnswerCommandV1_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[] { 2, 3, 4, 5, 6 }, rest, out paramsDouble) && Parser.TryParse(new int[] { 0, 1 }, rest, out paramsInt)) { deserialized = new MotorV1_0(paramsInt[0], paramsInt[1], paramsDouble[0], paramsDouble[1], paramsDouble[2], paramsDouble[3], paramsDouble[4]); return(true); } } } deserialized = null; return(false); }
public override bool IsDeserializeable(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 GetMotorsAnswerCommandV1_0(motors)); return(true); } } return(false); }