예제 #1
0
            public MoterModel(IMyMotorStator moter, MotorOperationDataEntity entity)
            {
                MyMotor         = moter;
                this.DataEntity = entity;

                nowTime = DateTime.UtcNow;
                befTime = DateTime.UtcNow;
            }
예제 #2
0
            public static void setDataEntityToMotorCustomData(MotorOperationDataEntity dataEntity, ref IMyMotorStator motorStator)
            {
                string text = "";

                text += "Angle:" + dataEntity.GetTargetAngle().ToString();
                text.AddNewLine();

                text += "Velocity:" + dataEntity.GetVelocity().ToString();
                text.AddNewLine();
                text += "Reverce:" + dataEntity.GetReverce().ToString();
                motorStator.CustomData = text;
            }
예제 #3
0
            public bool Update(MotorOperationDataEntity dataEntity = null)
            {
                nowTime = DateTime.UtcNow;
                if (dataEntity != null)
                {
                    this.DataEntity = dataEntity;
                }
                else
                {
                    this.DataEntity = MotorOperationFormatter.getDataEntityFromMoterCustomData(MyMotor, this.DataEntity);
                }


                return(fastMove());
            }
예제 #4
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);
            }
예제 #5
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);
            }
예제 #6
0
 public void setData(MoterModel moter, MotorOperationDataEntity dataEntity)
 {
     this.entiityDictionaly[moter] = dataEntity;
 }
 public void setValue(MoterModel moterModel, MotorOperationDataEntity dataEntity)
 {
     entiityDictionaly[moterModel] = dataEntity;
 }