예제 #1
0
        /// <summary>
        /// Traverses axis in a full range several times.
        /// </summary>
        public static PlanBuilder BackAndForwardAxisTraversal()
        {
            var traverseDelta = 400;
            var builder       = new PlanBuilder();

            for (var i = 0; i < 30; ++i)
            {
                var distance     = Constants.MaxStepsX;
                var acceleration = Coord2DController.CreateAcceleration(Constants.StartDeltaT, traverseDelta)[0];
                var deceleration = Coord2DController.CreateAcceleration(traverseDelta, Constants.StartDeltaT)[0];
                distance -= Math.Abs(acceleration.StepCount);
                distance -= Math.Abs(deceleration.StepCount);

                if (i % 2 == 0)
                {
                    builder.AddXY(acceleration, null);
                    builder.AddConstantSpeedTransitionXY(distance, 0, Speed.FromDeltaT(traverseDelta));
                    builder.AddXY(deceleration, null);
                }
                else
                {
                    builder.AddXY(acceleration.WithReversedDirection(), null);
                    builder.AddConstantSpeedTransitionXY(-distance, 0, Speed.FromDeltaT(traverseDelta));
                    builder.AddXY(deceleration.WithReversedDirection(), null);
                }
            }

            builder.ChangeXYtoUV();
            return(builder);
        }
예제 #2
0
 protected void Initialize()
 {
     _random             = new RandomNumberGenerator(0);
     _dmeBuilder         = new DmeBuilder(_random);
     _designModelBuilder = new DesignModelBuilder(_random);
     _designModelSize    = 50;
     _planBuilder        = new PlanBuilder(_random);
 }
 public void Initialize()
 {
     _random                     = new RandomNumberGenerator(0);
     _dmeBuilder                 = new DmeBuilder(_random);
     _designModelBuilder         = new DesignModelBuilder(_random);
     _planBuilder                = new PlanBuilder(_random);
     _toolCoverageCalculatorMock = new Mock <IToolCoverageCalculator>();
 }
예제 #4
0
        /// <summary>
        /// Demo with several acceleration ramps.
        /// </summary>
        public static PlanBuilder Ramping()
        {
            var builder = new PlanBuilder();

            builder.AddTransitionRPM(-400 * 10, 0, 1000, 500);
            builder.AddTransitionRPM(-400 * 10, 500, 500, 500);
            builder.AddTransitionRPM(-400 * 20, 500, 1500, 0);
            return(builder);
        }
예제 #5
0
        private void AlignHeads_Click(object sender, RoutedEventArgs e)
        {
            var state = Cnc.PlannedState;
            var xSteps = state.X - state.U;
            var ySteps = state.Y - state.V;

            var builder = new PlanBuilder();
            builder.AddRampedLineXY(-xSteps, -ySteps, Constants.MaxPlaneAcceleration, Constants.MaxPlaneSpeed);
            Cnc.SEND(builder.Build());
        }
예제 #6
0
파일: PlanSepc.cs 프로젝트: drunkcod/Flwr
        public void Disposes_results()
        {
            var plan        = new PlanBuilder();
            var aDisposable = new MyDisposable();
            var create      = plan.Add("Create", () => aDisposable);

            plan.Add("Use", (MyDisposable _) => { }, create);

            plan.Build().Invoke();
            Check.That(() => aDisposable.IsDisposed);
        }
예제 #7
0
        /// <summary>
        /// Demo with a single revolution interrupted several times.
        /// </summary>
        public static PlanBuilder InterruptedRevolution()
        {
            var plan         = new PlanBuilder();
            var segmentation = 100;

            for (var i = 0; i < 400 / segmentation; ++i)
            {
                plan.AddRampedLineXY(segmentation, segmentation, Constants.MaxPlaneAcceleration, Constants.MaxPlaneSpeed);
            }

            return(plan);
        }
예제 #8
0
        public SyncPlan BuildPlan(IEnumerable <string> paths, Mask mask)
        {
            Analyze(paths, mask);
            PlanBuilder builder = new PlanBuilder(_tager, mask);
            var         plan    = builder.Build(NotSynchronizedFiles.Keys);

            foreach (var errorFile in builder.ErrorFiles)
            {
                ErrorFiles.Add(errorFile.Key, errorFile.Value);
            }
            return(plan);
        }
예제 #9
0
        private void GoToZeros_Click(object sender, RoutedEventArgs e)
        {
            var state = Cnc.PlannedState;
            var stepsU = _positionOffsetU - state.U;
            var stepsV = _positionOffsetV - state.V;
            var stepsX = _positionOffsetX - state.X;
            var stepsY = _positionOffsetY - state.Y;

            var planner = new PlanBuilder();
            planner.AddRampedLineUVXY(stepsU, stepsV, stepsX, stepsY, Constants.MaxPlaneAcceleration, Constants.MaxPlaneSpeed);
            Cnc.SEND(planner.Build());
        }
예제 #10
0
        private void executePlan()
        {
            if (!Cnc.IsHomeCalibrated)
            {
                ShowError("Calibration is required!");
                return;
            }

            disableMotionCommands();
            Workspace.DisableChanges();

            var builder = new PlanBuilder();
            var point   = Workspace.EntryPoint;

            var state = Cnc.PlannedState;
            var initU = point.PositionC1 - state.U;
            var initV = point.PositionC2 - state.V;
            var initX = point.PositionC1 - state.X;
            var initY = point.PositionC2 - state.Y;


            builder.AddRampedLineUVXY(initU, initV, initX, initY, Configuration.MaxPlaneAcceleration, getTransitionSpeed());
            try
            {
                Workspace.BuildPlan(builder);
            }
            catch (PlanningException ex)
            {
                planCompleted();
                ShowError(ex.Message);
                return;
            }
            //builder.AddRampedLineUVXY(-initU, -initV, -initX, -initY, Constants.MaxPlaneAcceleration, getTransitionSpeed());

            var plan = builder.Build();

            if (!Cnc.SEND(plan))
            {
                planCompleted();
                ShowError("Plan overflows the workspace!");
                return;
            }

            Cnc.OnInstructionQueueIsComplete += planCompleted;
            _planStart     = DateTime.Now;
            _isPlanRunning = true;

            if (!plan.Any())
            {
                planCompleted();
            }
        }
예제 #11
0
        /// <summary>
        /// Draws a square filled with diagonals - uses 45 degree acceleration methods
        /// </summary>
        public static PlanBuilder DrawSquareWithDiagonals()
        {
            var speed            = Constants.MaxPlaneSpeed;
            var acceleration     = Constants.MaxPlaneAcceleration; //new Acceleration(Constants.MaxPlaneAcceleration.Speed,Constants.MaxPlaneAcceleration.Ticks*10);
            var squareSize       = 6000;
            var diagonalDistance = 300;



            var builder = new PlanBuilder();

            //do a square border
            builder.AddRampedLineXY(squareSize, 0, acceleration, speed);
            builder.AddRampedLineXY(0, squareSize, acceleration, speed);
            builder.AddRampedLineXY(-squareSize, 0, acceleration, speed);
            builder.AddRampedLineXY(0, -squareSize, acceleration, speed);
            //left right diagonals
            var diagonalCount = squareSize / diagonalDistance;

            for (var i = 0; i < diagonalCount * 2; ++i)
            {
                var diagLength = (diagonalCount - Math.Abs(i - diagonalCount)) * diagonalDistance;

                if (i % 2 == 0)
                {
                    builder.AddRampedLineXY(-diagLength, diagLength, acceleration, speed);
                    if (i < diagonalCount)
                    {
                        builder.AddRampedLineXY(0, diagonalDistance, acceleration, speed);
                    }
                    else
                    {
                        builder.AddRampedLineXY(diagonalDistance, 0, acceleration, speed);
                    }
                }
                else
                {
                    builder.AddRampedLineXY(diagLength, -diagLength, acceleration, speed);
                    if (i < diagonalCount)
                    {
                        builder.AddRampedLineXY(diagonalDistance, 0, acceleration, speed);
                    }
                    else
                    {
                        builder.AddRampedLineXY(0, diagonalDistance, acceleration, speed);
                    }
                }
            }

            return(builder);
        }
예제 #12
0
 private void Execute(IEnumerable <InstructionCNC> plan, bool duplicateUV = true)
 {
     if (duplicateUV)
     {
         var builder = new PlanBuilder();
         builder.Add(plan);
         builder.DuplicateXYtoUV();
         _cnc.SEND(builder.Build());
     }
     else
     {
         _cnc.SEND(plan);
     }
 }
예제 #13
0
        /// <summary>
        /// A single revolution with a lot of forward/backward direction changes.
        /// </summary>
        /// <returns></returns>
        public static PlanBuilder BackAndForwardRevolution()
        {
            var plan         = new PlanBuilder();
            var overShoot    = 100;
            var segmentation = 4;

            for (var i = 0; i < 400 / segmentation; ++i)
            {
                plan.AddRampedLineXY(-overShoot, -overShoot, Constants.MaxPlaneAcceleration, Constants.MaxPlaneSpeed);
                plan.AddRampedLineXY(segmentation + overShoot, segmentation + overShoot, Constants.MaxPlaneAcceleration, Constants.MaxPlaneSpeed);
            }

            return(plan);
        }
예제 #14
0
        /// <summary>
        /// Builds plan configured by the workspace.
        /// ASSUMING the starting position be correctly set up on <see cref="EntryPoint"/>.
        /// </summary>
        internal void BuildPlan(PlanBuilder plan)
        {
            var speedPoints = new List <Speed4Dstep>();

            _entryPoint.Build(this, speedPoints, null);

            var planPoints    = speedPoints.Select(p => p.Point).ToList();
            var segmentSpeeds = speedPoints.Select(p => Tuple.Create(p.SpeedUV, p.SpeedXY)).ToArray();

            //scheduler needs referential point
            planPoints.Insert(0, _entryPoint.CutPoints.First());

            var scheduler      = new StraightLinePlanner4D(CuttingSpeed);
            var trajectoryPlan = scheduler.CreateConstantPlan(new Trajectory4D(planPoints), segmentSpeeds);

            plan.Add(trajectoryPlan.Build());
        }
예제 #15
0
        internal static AccelerationInstruction[] CreateAcceleration(int speed, int desiredSpeed)
        {
            var canSkipAcceleration = speed == desiredSpeed;

            canSkipAcceleration |= Math.Abs(speed) >= Configuration.StartDeltaT && Math.Abs(desiredSpeed) >= Configuration.StartDeltaT;
            if (canSkipAcceleration)
            {
                //no acceleration is required
                return(new AccelerationInstruction[0]);
            }

            if (Math.Abs(Math.Sign(speed) - Math.Sign(desiredSpeed)) > 1)
            {
                throw new NotImplementedException("Stop and run in other direction");
            }

            var stepCount = desiredSpeed > 0 ? (Int16)5000 : (Int16)(-5000);

            if (desiredSpeed == 0)
            {
                stepCount = speed > 0 ? (Int16)5000 : (Int16)(-5000);
            }

            speed        = Math.Abs(speed);
            desiredSpeed = Math.Abs(desiredSpeed);
            if (speed == 0)
            {
                speed = Configuration.StartDeltaT;
            }

            if (desiredSpeed == 0)
            {
                desiredSpeed = Configuration.StartDeltaT;
            }

            var acceleration = PlanBuilder.CalculateBoundedAcceleration((UInt16)speed, (UInt16)desiredSpeed, stepCount);

            return(new AccelerationInstruction[] { acceleration });
        }
예제 #16
0
        public Plan ToSDKPlan()
        {
            if (sdkPlan != null)
            {
                return(sdkPlan);
            }
            else if (apiPlan != null)
            {
                PlanBuilder builder = PlanBuilder.NewPlan(apiPlan.Name)
                                      .WithContract(apiPlan.Contract)
                                      .WithData(apiPlan.Data)
                                      .WithId(apiPlan.Id)
                                      .WithCycle(apiPlan.Cycle)
                                      .WithDescription(apiPlan.Description)
                                      .WithFeatures(apiPlan.Features)
                                      .WithGroup(apiPlan.Group)
                                      .WithOriginal(apiPlan.Original)
                                      .WithPrice(new PriceConverter(apiPlan.Price).ToSDKPrice());
                if (apiPlan.FreeCycles != null)
                {
                    builder.WithFreeCycles(apiPlan.FreeCycles.Count, apiPlan.FreeCycles.Cycle);
                }

                if (apiPlan.Quotas != null && apiPlan.Quotas.Count > 0)
                {
                    foreach (API.Quota quota in apiPlan.Quotas)
                    {
                        builder.WithQuota(quota.Cycle, quota.Limit, quota.Scope, quota.Target);
                    }
                }

                return(builder.Build());
            }
            else
            {
                return(null);
            }
        }
예제 #17
0
        private void setElevation(CenterCutState newState)
        {
            if (_state == newState)
            {
                //there is nothing to do
                return;
            }

            var elevationFactor = _state - newState;

            _state = newState;

            refreshStateButtons();

            var elevation      = double.Parse(Elevation.Text);
            var elevationSteps = (int)Math.Round(elevation / Configuration.MilimetersPerStep) * elevationFactor;

            var builder = new PlanBuilder();

            builder.AddRampedLineUVXY(elevationSteps, 0, -elevationSteps, 0, Configuration.MaxPlaneAcceleration, Configuration.MaxPlaneSpeed);
            var plan = builder.Build();

            _panel.Cnc.SEND(plan);
        }
예제 #18
0
 private void Execute(PlanBuilder plan, bool duplicateUV = true)
 {
     Execute(plan.Build(), duplicateUV);
 }
예제 #19
0
        public void withSpecifiedValues()
        {
            AccountBuilder accountBuilder = AccountBuilder.NewAccount()
                                            .WithName(ACC_NAME)
                                            .WithId(ACC_ID)
                                            .WithOwner(ACC_OWNER)
                                            .WithLogoUrl(ACC_LOGOURL)
                                            .WithData(ACC_DATA)
                                            .WithCompany(CompanyBuilder.NewCompany(ACC_CO_NAME)
                                                         .WithAddress(AddressBuilder.NewAddress()
                                                                      .WithAddress1(ACC_CO_ADDR_ADDR1)
                                                                      .WithAddress2(ACC_CO_ADDR_ADDR2)
                                                                      .WithCity(ACC_CO_ADDR_CITY)
                                                                      .WithCountry(ACC_CO_ADDR_COUNTRY)
                                                                      .WithState(ACC_CO_ADDR_STATE)
                                                                      .WithZipCode(ACC_CO_ADDR_ZIP).Build())
                                                         .WithId(ACC_CO_ID)
                                                         .WithData(ACC_CO_DATA)
                                                         .Build())
                                            .WithCustomField(CustomFieldBuilder.CustomFieldWithId(ACC_FIELD_ID)
                                                             .WithDefaultValue(ACC_FIELD_DEF_VLE)
                                                             .IsRequired(ACC_FIELD_IS_REQUIRED)
                                                             .WithTranslation(TranslationBuilder.NewTranslation(ACC_FIELD_TRANSL_LANG).Build())
                                                             .Build())
                                            .WithLicense(LicenseBuilder.NewLicense()
                                                         .CreatedOn(ACC_LIC_CREATED)
                                                         .WithPaidUntil(ACC_LIC_PAIDUNTIL)
                                                         .WithStatus(ACC_LIC_STATUS)
                                                         .WithTransaction(ACC_LIC_TRANS_CREATED,
                                                                          CreditCardBuilder.NewCreditCard()
                                                                          .WithCvv(ACC_LIC_TRANS_CC_CVV)
                                                                          .WithName(ACC_LIC_TRANS_CC_NAME)
                                                                          .WithNumber(ACC_LIC_TRANS_CC_NUM)
                                                                          .WithType(ACC_LIC_TRANS_CC_TYPE)
                                                                          .WithExpiration(ACC_LIC_TRANS_CC_EXP_MONTH, ACC_LIC_TRANS_CC_EXP_YEAR)
                                                                          .Build(),
                                                                          PriceBuilder.NewPrice()
                                                                          .WithAmount(ACC_LIC_TRANS_PRICE_AMOUNT)
                                                                          .WithCurrency(ACC_LIC_TRANS_PRICE_CURR_ID, ACC_LIC_TRANS_PRICE_CURR_NAME,
                                                                                        ACC_LIC_TRANS_PRICE_CURR_DATA)
                                                                          .Build())
                                                         .WithPlan(PlanBuilder.NewPlan(ACC_LIC_PLAN_ID)
                                                                   .WithId(ACC_LIC_PLAN_NAME)
                                                                   .WithContract(ACC_LIC_PLAN_CONTRACT)
                                                                   .WithDescription(ACC_LIC_PLAN_DES)
                                                                   .WithGroup(ACC_LIC_PLAN_GRP)
                                                                   .WithCycle(ACC_LIC_PLAN_CYC)
                                                                   .WithOriginal(ACC_LIC_PLAN_ORI)
                                                                   .WithData(ACC_LIC_PLAN_DATA)
                                                                   .WithFreeCycles(ACC_LIC_PLAN_CYC_COUNT, ACC_LIC_PLAN_CYC_CYCLE)
                                                                   .WithQuota(ACC_LIC_PLAN_QUOTA_CYCLE, ACC_LIC_PLAN_QUOTA_LIMIT, ACC_LIC_PLAN_QUOTA_SCOPE,
                                                                              ACC_LIC_PLAN_QUOTA_TARGET)
                                                                   .WithFeatures(ACC_LIC_PLAN_FEAT)
                                                                   .WithPrice(PriceBuilder.NewPrice()
                                                                              .WithAmount(ACC_LIC_PLAN_PRICE_AMOUNT)
                                                                              .WithCurrency(ACC_LIC_PLAN_PRICE_CURR_ID, ACC_LIC_PLAN_PRICE_CURR_NAME,
                                                                                            ACC_LIC_PLAN_PRICE_CURR_DATA)
                                                                              .Build())
                                                                   .Build())
                                                         .Build())
                                            .WithAccountProviders(new List <Provider>()
            {
                ProviderBuilder.NewProvider(ACC_PROV_DOC_NAME)
                .WithData(ACC_PROV_DOC_DATA)
                .WithId(ACC_PROV_DOC_ID)
                .WithProvides(ACC_PROV_DOC_NAME)
                .Build()
            }, new List <Provider>()
            {
                ProviderBuilder.NewProvider(ACC_PROV_USR_NAME)
                .WithData(ACC_PROV_USR_DATA)
                .WithId(ACC_PROV_USR_ID)
                .WithProvides(ACC_PROV_USR_PROVIDES)
                .Build()
            });

            Account account = accountBuilder.Build();

            Assert.AreEqual(ACC_NAME, account.Name);
            Assert.AreEqual(ACC_CO_ID, account.Company.Id);
            Assert.AreEqual(ACC_CO_ADDR_ADDR1, account.Company.Address.Address1);

            Assert.AreEqual(1, account.CustomFields.Count);
            Assert.AreEqual(ACC_FIELD_DEF_VLE, account.CustomFields[0].Value);
            Assert.AreEqual(1, account.CustomFields[0].Translations.Count);
            Assert.AreEqual(ACC_FIELD_TRANSL_LANG, account.CustomFields[0].Translations[0].Language);

            Assert.AreEqual(1, account.Licenses.Count);
            Assert.AreEqual(ACC_LIC_STATUS, account.Licenses[0].Status);
            Assert.AreEqual(1, account.Licenses[0].Transactions.Count);
            Assert.AreEqual(ACC_LIC_TRANS_CC_NUM, account.Licenses[0].Transactions[0].CreditCard.Number);
            Assert.AreEqual(ACC_LIC_TRANS_PRICE_AMOUNT, account.Licenses[0].Transactions[0].Price.Amount);
            Assert.AreEqual(ACC_LIC_PLAN_CONTRACT, account.Licenses[0].Plan.Contract);
            Assert.AreEqual(ACC_LIC_PLAN_PRICE_AMOUNT, account.Licenses[0].Plan.Price.Amount);

            Assert.AreEqual(1, account.Providers.Documents.Count);
            Assert.AreEqual(ACC_PROV_DOC_NAME, account.Providers.Documents[0].Name);
            Assert.AreEqual(1, account.Providers.Users.Count);
            Assert.AreEqual(ACC_PROV_USR_NAME, account.Providers.Users[0].Name);
        }
예제 #20
0
        /// <summary>
        /// plan ::= "(" [ "(" <docstring> ]
        ///                ( ( "(" <competence> | <action-pattern> )*
        ///                 "(" <drive-collection>
        ///                 ( "(" <competence> | <action-pattern> )*
        ///               )
        ///                | ( "(" <competence> )
        ///                | ( "(" <action-pattern> )
        ///            ")"
        /// </summary>
        /// <returns>A plan builder object representing the parsed plan.</returns>
        protected internal PlanBuilder Plan()
        {
            PlanBuilder planBuilder = new PlanBuilder();

            // this method cheats a bit by counting the action-pattern
            // and competences and also drive-collections to check when things are
            // allowed were.
            if (!Match(new string[] { "LPAREN", }))
            {
                Error(string.Format("Plan needs to start with '(' rather than '{0}'", token.value));
            }
            NextToken();
            // action pattern, competence, docstring, drive collection
            int ap = 0, c = 0, d = 0, dc = 0;

            while (true)
            {
                if (!Match(new string[] { "LPAREN", "RPAREN" }))
                {
                    Error(string.Format("Expected '(' as start of documentation / " +
                                        "competence / action-pattern / drive-collection, or " +
                                        "')' to end plan, instead of '{0}'", token.value));
                }
                if (Match(new string[] { "RPAREN", }))
                {
                    // end of plan
                    NextToken();
                    break;
                }
                NextToken();
                // check for documentation
                if (Match(new string[] { "DOC", }))
                {
                    if (ap + c + dc + d > 0)
                    {
                        Error("Documentation only allowed as first " +
                              "element in plan");
                    }
                    d += 1;
                    planBuilder.setDocString(GetDocString());
                    // print docString();
                }
                // check for competence
                else if (Match(new string[] { "C", }))
                {
                    c++;
                    planBuilder.addCompetence(GetCompetence());
                    // print competence()
                }
                // check for action-pattern
                else if (Match(new string[] { "AP", }))
                {
                    ap++;
                    planBuilder.addActionPattern(GetActionPattern());
                    // print actionPattern();
                }
                // check for drive-collection
                else if (Match(new string[] { "DC", "RDC", "SDC", "SRDC" }))
                {
                    if (dc > 0)
                    {
                        Error("Only a single drive-collection allowed");
                    }
                    dc++;
                    planBuilder.SetDriveCollection(GetDriveCollection());
                    // print
                }
                else
                {
                    Error(string.Format("Expected docstring / competence / action " +
                                        "pattern or drive collection instead of '{0}'", token.value));
                }
            }

            // the plan was closed
            if (token is Token)
            {
                Error(string.Format("Illegal token '{0}' after end of plan", token.value));
            }
            if (dc == 0 && (ap + c) != 1)
            {
                Error("Illegal plan: A plan without a drive-collection " +
                      "only allows for a SINLGE action-pattern OR a SINGLE competence");
            }

            // everything is fine
            return(planBuilder);
        }