예제 #1
0
            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);
            }
예제 #2
0
            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);
            }