public static MotorOperationDataEntity getDataEntityFromMoterCustomData(IMyMotorStator motor, MotorOperationDataEntity dataEntity) { string text = motor.CustomData; var arr = text.Split(Environment.NewLine.ToArray(), StringSplitOptions.None); foreach (var item in arr) { var array = item.Split(':'); switch (array[0]) { case "Angle": dataEntity.SetTargetAngle(float.Parse(array[1])); break; case "Velocity": dataEntity.SetVelocity(float.Parse(array[1])); break; case "Reverce": dataEntity.SetReverce(bool.Parse(array[1])); break; default: break; } } return(dataEntity); }
public static MotorOperationDataEntity setToDataEntityFromValue(MotorOperationDataEntity dataEntity, float?targetAngle = null, float?velocity = null, bool?reverce = null) { if (targetAngle != null) { dataEntity.SetTargetAngle((float)targetAngle); } if (velocity != null) { dataEntity.SetVelocity((float)velocity); } if (reverce != null) { dataEntity.SetReverce((bool)reverce); } return(dataEntity); }