コード例 #1
0
        static void SaveState(int frames)
        {
            ResumeState state    = new ResumeState(I.currentlyUsingAutoEnc, frames);
            string      filePath = Path.Combine(I.current.tempFolder, Paths.resumeDir, resumeFilename);

            File.WriteAllText(filePath, state.ToString());
        }
コード例 #2
0
        public static async Task PrepareResumedRun()
        {
            if (!resumeNextRun)
            {
                return;
            }

            string      stateFilepath = Path.Combine(I.current.tempFolder, Paths.resumeDir, resumeFilename);
            ResumeState state         = new ResumeState(File.ReadAllText(stateFilepath));

            string        fileMapFilepath = Path.Combine(I.current.tempFolder, Paths.resumeDir, filenameMapFilename);
            List <string> inputFrameLines = File.ReadAllLines(fileMapFilepath).Where(l => l.Trim().Length > 3).ToList();
            List <string> inputFrames     = inputFrameLines.Select(l => Path.Combine(I.current.framesFolder, l.Split('|')[1])).ToList();

            for (int i = 0; i < state.interpolatedInputFrames; i++)
            {
                IOUtils.TryDeleteIfExists(inputFrames[i]);
                if (i % 1000 == 0)
                {
                    await Task.Delay(1);
                }
            }

            Directory.Move(I.current.interpFolder, I.current.interpFolder + Paths.prevSuffix); // Move existing interp frames
            Directory.CreateDirectory(I.current.interpFolder);                                 // Re-create empty interp folder

            LoadFilenameMap();
        }
コード例 #3
0
        /// <summary>
        /// Creates a new resumestate record.
        /// </summary>
        public async Task <ResumeState> CreateResumeStateAsync(ResumeState resumeState)
        {
            // Validation
            if (resumeState == null)
            {
                return(null);
            }

            // Trimming strings
            if (!string.IsNullOrEmpty(resumeState.Name))
            {
                resumeState.Name = resumeState.Name.Trim();
            }
            if (!string.IsNullOrEmpty(resumeState.DisplayName))
            {
                resumeState.DisplayName = resumeState.DisplayName.Trim();
            }

            // #-#-# {D4775AF3-4BFA-496A-AA82-001028A22DD6}
            // Before creation
            // #-#-#

            resumeState = await this.resumeStateRepository.InsertAsync(resumeState);

            // #-#-# {1972C619-D2F2-48FD-8474-3A69621B1F78}
            // After creation
            // #-#-#

            return(resumeState);
        }
コード例 #4
0
        public async Task <ActionResult <ResumeStateVM> > GetResumeState([FromRoute] Guid id)
        {
            ResumeState resumestate = await this.bll.GetResumeStateByIdAsync(id);

            if (resumestate == null)
            {
                return(NotFound());
            }

            // Mapping
            return(Ok(this.mapper.Map <ResumeState, ResumeStateVM>(resumestate)));
        }
コード例 #5
0
        /// <summary>
        /// Creates a new resume record.
        /// </summary>
        public async Task <Resume> CreateResumeAsync(Resume resume)
        {
            // Validation
            if (resume == null)
            {
                return(null);
            }

            // Before creation

            // Trimming strings
            if (!string.IsNullOrEmpty(resume.DisplayName))
            {
                resume.DisplayName = resume.DisplayName.Trim();
            }
            if (!string.IsNullOrEmpty(resume.JobTitle))
            {
                resume.JobTitle = resume.JobTitle.Trim();
            }
            if (!string.IsNullOrEmpty(resume.Description))
            {
                resume.Description = resume.Description.Trim();
            }

            // Name field
            resume.Name = resume.DisplayName.ToSlug();

            // Default resume state
            if (resume.ResumeStateId == Guid.Empty)
            {
                ResumeState resumeStateActive = await this.resumeStateRepository.GetByNameAsync("active");

                resume.ResumeStateId = resumeStateActive.Id;
                resume.ResumeState   = resumeStateActive;
            }

            // User
            if (resume.UserId == Guid.Empty)
            {
                User currentUser = await this.userManager.GetUserAsync(this.httpContextAccessor.HttpContext.User);

                resume.UserId = currentUser.Id;
                resume.User   = currentUser;
            }

            resume = await this.resumeRepository.InsertAsync(resume);

            // After creation

            return(resume);
        }
コード例 #6
0
        public async Task <ActionResult <ResumeStateVM> > DeleteResumeState([FromRoute] Guid id)
        {
            // Retrieve existing resumestate
            ResumeState resumestate = await this.bll.GetResumeStateByIdAsync(id);

            if (resumestate == null)
            {
                return(NotFound());
            }

            await this.bll.DeleteResumeStateAsync(resumestate);

            // Mapping
            return(Ok(this.mapper.Map <ResumeState, ResumeStateVM>(resumestate)));
        }
コード例 #7
0
        public async Task <ActionResult <ResumeStateVM> > UpdateResumeState([FromRoute] Guid id, [FromBody] ResumeStateVM resumeStateVM)
        {
            // Validation
            if (!ModelState.IsValid || id != resumeStateVM.Id)
            {
                return(BadRequest(ModelState));
            }

            // Mapping
            ResumeState resumeState = this.mapper.Map <ResumeStateVM, ResumeState>(resumeStateVM);

            resumeState = await this.bll.UpdateResumeStateAsync(resumeState);

            // Mapping
            return(Ok(this.mapper.Map <ResumeState, ResumeStateVM>(resumeState)));
        }
コード例 #8
0
        /// <summary>
        /// Updates an existing resumestate record by Id.
        /// </summary>
        public async Task <ResumeState> UpdateResumeStateAsync(ResumeState resumeStateUpdate)
        {
            // Validation
            if (resumeStateUpdate == null)
            {
                return(null);
            }

            // Retrieve existing
            ResumeState resumeState = await this.resumeStateRepository.GetByIdAsync(resumeStateUpdate.Id);

            if (resumeState == null)
            {
                return(null);
            }

            // Trimming strings
            if (!string.IsNullOrEmpty(resumeStateUpdate.Name))
            {
                resumeStateUpdate.Name = resumeStateUpdate.Name.Trim();
            }
            if (!string.IsNullOrEmpty(resumeStateUpdate.DisplayName))
            {
                resumeStateUpdate.DisplayName = resumeStateUpdate.DisplayName.Trim();
            }

            // Mapping
            resumeState.Name        = resumeStateUpdate.Name;
            resumeState.DisplayName = resumeStateUpdate.DisplayName;

            // #-#-# {B5914243-E57E-41AE-A7C8-553F2F93267B}
            // Before update
            // #-#-#

            resumeState = await this.resumeStateRepository.UpdateAsync(resumeState);

            // #-#-# {983B1B6C-14A7-4925-8571-D77447DF0ADA}
            // After update
            // #-#-#

            return(resumeState);
        }
コード例 #9
0
        public async Task <ActionResult <ResumeStateVM> > CreateResumeState([FromBody] ResumeStateVM resumestateVM)
        {
            // Validation
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            // Mapping
            ResumeState resumestate = this.mapper.Map <ResumeStateVM, ResumeState>(resumestateVM);

            resumestate = await this.bll.CreateResumeStateAsync(resumestate);

            // Mapping
            return(CreatedAtAction(
                       "GetResumeState",
                       new { id = resumestate.Id },
                       this.mapper.Map <ResumeState, ResumeStateVM>(resumestate)
                       ));
        }
コード例 #10
0
        /// <summary>
        /// Deletes an existing resumestate record.
        /// </summary>
        public async Task <ResumeState> DeleteResumeStateAsync(ResumeState resumeState)
        {
            // Validation
            if (resumeState == null)
            {
                return(null);
            }

            // #-#-# {FE1A99E0-482D-455B-A8C1-3C2C11FACA58}
            // Before deletion
            // #-#-#

            await this.resumeStateRepository.DeleteAsync(resumeState);

            // #-#-# {F09857C0-44E7-4E6C-B3E6-883C0D28E1A6}
            // After deletion
            // #-#-#

            return(resumeState);
        }
コード例 #11
0
        public override string ReadLine()
        {
            string nextCommand = queuedCommands.ReadLine();

            if (nextCommand != null)
            {
                return(nextCommand);
            }

            switch (resumeState)
            {
            // heat the extrude to remove it from the part
            case ResumeState.RemoveHeating:
                // TODO: make sure we heat up all the extruders that we need to (all that are used)
                queuedCommands.Add("G21; set units to millimeters");
                queuedCommands.Add("M107; fan off");
                queuedCommands.Add("T0; set the active extruder to 0");
                queuedCommands.Add("G90; use absolute coordinates");
                queuedCommands.Add("G92 E0; reset the expected extruder position");
                queuedCommands.Add("M82; use absolute distance for extrusion");
                queuedCommands.Add("M109 S{0}".FormatWith(ActiveSliceSettings.Instance.ExtruderTemperature(0)));

                resumeState = ResumeState.Raising;
                return("");

            // remove it from the part
            case ResumeState.Raising:
                queuedCommands.Add("M114 ; get current position");
                queuedCommands.Add("G91 ; move relative");
                queuedCommands.Add("G1 Z10 F{0}".FormatWith(MovementControls.ZSpeed));
                queuedCommands.Add("G90 ; move absolute");
                resumeState = ResumeState.Homing;
                return("");

            // if top homing, home the extruder
            case ResumeState.Homing:
                if (ActiveSliceSettings.Instance.ActiveValue("z_homes_to_max") == "1")
                {
                    queuedCommands.Add("G28");
                }
                else
                {
                    // home x
                    queuedCommands.Add("G28 X0");
                    // home y
                    queuedCommands.Add("G28 Y0");
                    // move to the place we can home z from
                    Vector2 resumePositionXy = ActiveSliceSettings.Instance.ActiveVector2("resume_position_before_z_home");
                    queuedCommands.Add("G1 X{0:0.000}Y{1:0.000}F{2}".FormatWith(resumePositionXy.x, resumePositionXy.y, MovementControls.XSpeed));
                    // home z
                    queuedCommands.Add("G28 Z0");
                }
                resumeState = ResumeState.FindingResumeLayer;
                return("");

            // This is to resume printing if an out a filament occurs.
            // Help the user move the extruder down to just touching the part
            case ResumeState.FindingResumeLayer:
                if (false)                         // help the user get the head to the right position
                {
                    // move to above the completed print
                    // move over a know good part of the model at the current top layer (extrude vertex from gcode)
                    // let the user move down until they like the height
                    // calculate that position and continue
                }
                else                         // we are resuming because of disconnect or reset, skip this
                {
                    resumeState = ResumeState.SkippingGCode;
                    goto case ResumeState.SkippingGCode;
                }

            case ResumeState.SkippingGCode:
                // run through the gcode that the device expected looking for things like temp
                // and skip everything else until we get to the point we left off last time
                while (internalStream.FileStreaming.PercentComplete(internalStream.LineIndex) < percentDone)
                {
                    string line = internalStream.ReadLine();

                    lastDestination = GetPosition(line, lastDestination);

                    // check if the line is something we want to send to the printer (like a temp)
                    if (line.StartsWith("M109") ||
                        line.StartsWith("M104") ||
                        line.StartsWith("T") ||
                        line.StartsWith("M106") ||
                        line.StartsWith("M107"))
                    {
                        return(line);
                    }
                }

                resumeState = ResumeState.PrimingAndMovingToStart;
                return("");

            case ResumeState.PrimingAndMovingToStart:
            {
                // let's prime the extruder, move to a good position over the part, then start printing
                queuedCommands.Add("G1 E5");
                queuedCommands.Add("G1 E4");
                if (ActiveSliceSettings.Instance.ActiveValue("z_homes_to_max") == "0")                                 // we are homed to the bed
                {
                    // move to the height we can resume printing from
                    Vector2 resumePositionXy = ActiveSliceSettings.Instance.ActiveVector2("resume_position_before_z_home");
                    queuedCommands.Add(CreateMovementLine(new PrinterMove(new VectorMath.Vector3(resumePositionXy.x, resumePositionXy.y, lastDestination.position.z + 5), 0, MovementControls.ZSpeed)));
                    // move just above the actual print position
                    queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position + new VectorMath.Vector3(0, 0, 5), 0, MovementControls.XSpeed)));
                    // move down to part
                    queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, MovementControls.ZSpeed)));
                }
                else
                {
                    // move to the actual print position
                    queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, MovementControls.ZSpeed)));
                }
                // extrude back to our filament start
                queuedCommands.Add("G1 E5");
                /// reset the printer to know where the filament should be
                queuedCommands.Add("G92 E{0}".FormatWith(lastDestination.extrusion));
                resumeState = ResumeState.PrintingSlow;
            }
                return("");

            case ResumeState.PrintingSlow:
            {
                string lineToSend = internalStream.ReadLine();
                if (lineToSend != null &&
                    lineToSend.StartsWith("; LAYER:"))
                {
                    if (lineToSend != null &&
                        LineIsMovement(lineToSend))
                    {
                        PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
                        PrinterMove moveToSend  = currentMove;

                        double feedRate;

                        string firstLayerSpeed = ActiveSliceSettings.Instance.ActiveValue("resume_first_layer_speed");
                        if (!double.TryParse(firstLayerSpeed, out feedRate))
                        {
                            feedRate = 10;
                        }
                        feedRate *= 60;

                        moveToSend.feedRate = feedRate;

                        lineToSend      = CreateMovementLine(moveToSend, lastDestination);
                        lastDestination = currentMove;
                        return(lineToSend);
                    }

                    return(lineToSend);
                }
            }

                resumeState = ResumeState.PrintingToEnd;
                return("");

            case ResumeState.PrintingToEnd:
                return(internalStream.ReadLine());
            }

            return(null);
        }
コード例 #12
0
		public override string ReadLine()
		{
			string nextCommand = queuedCommands.ReadLine();
			if (nextCommand != null)
			{
				return nextCommand;
			}
			
			switch (resumeState)
			{
				// heat the extrude to remove it from the part
				case ResumeState.RemoveHeating:
					// TODO: make sure we heat up all the extruders that we need to (all that are used)
					queuedCommands.Add("G21; set units to millimeters");
					queuedCommands.Add("M107; fan off");
					queuedCommands.Add("T0; set the active extruder to 0");
					queuedCommands.Add("G90; use absolute coordinates");
					queuedCommands.Add("G92 E0; reset the expected extruder position");
					queuedCommands.Add("M82; use absolute distance for extrusion");
					queuedCommands.Add("M109 S{0}".FormatWith(ActiveSliceSettings.Instance.GetExtruderTemperature(1)));

					resumeState = ResumeState.Raising;
					return "";

				// remove it from the part
				case ResumeState.Raising:
					queuedCommands.Add("M114 ; get current position");
					queuedCommands.Add("G91 ; move relative");
					queuedCommands.Add("G1 Z10 F{0}".FormatWith(MovementControls.ZSpeed));
					queuedCommands.Add("G90 ; move absolute");
					resumeState = ResumeState.Homing;
					return "";

				// if top homing, home the extruder
				case ResumeState.Homing:
					if (ActiveSliceSettings.Instance.GetActiveValue("z_homes_to_max") == "1")
					{
						queuedCommands.Add("G28");
					}
					else
					{
						// home x
						queuedCommands.Add("G28 X0");
						// home y
						queuedCommands.Add("G28 Y0");
						// move to the place we can home z from
						Vector2 resumePositionXy = ActiveSliceSettings.Instance.GetActiveVector2("resume_position_before_z_home");
						queuedCommands.Add("G1 X{0:0.000}Y{1:0.000}F{2}".FormatWith(resumePositionXy.x, resumePositionXy.y, MovementControls.XSpeed));
						// home z
						queuedCommands.Add("G28 Z0");
					}
					resumeState = ResumeState.FindingResumeLayer;
					return "";
					
				// This is to resume printing if an out a filament occurs. 
				// Help the user move the extruder down to just touching the part
				case ResumeState.FindingResumeLayer:
					if (false) // help the user get the head to the right position
					{
						// move to above the completed print
						// move over a know good part of the model at the current top layer (extrude vertex from gcode)
						// let the user move down until they like the height
						// calculate that position and continue
					}
					else // we are resuming because of disconnect or reset, skip this
					{
						resumeState = ResumeState.SkippingGCode;
						goto case ResumeState.SkippingGCode;
					}

				case ResumeState.SkippingGCode:
					// run through the gcode that the device expected looking for things like temp
					// and skip everything else until we get to the point we left off last time
					while (internalStream.FileStreaming.PercentComplete(internalStream.LineIndex) < percentDone)
					{
						string line = internalStream.ReadLine();

						lastDestination = GetPosition(line, lastDestination);

						// check if the line is something we want to send to the printer (like a temp)
						if (line.StartsWith("M109")
							|| line.StartsWith("M104")
							|| line.StartsWith("T")
							|| line.StartsWith("M106")
							|| line.StartsWith("M107"))
						{
							return line;
						}
					}
					
					resumeState = ResumeState.PrimingAndMovingToStart;
					return "";

				case ResumeState.PrimingAndMovingToStart:
					{
						// let's prime the extruder, move to a good position over the part, then start printing
						queuedCommands.Add("G1 E5");
						queuedCommands.Add("G1 E4");
						if (ActiveSliceSettings.Instance.GetActiveValue("z_homes_to_max") == "0") // we are homed to the bed
						{
							// move to the height we can resume printing from
							Vector2 resumePositionXy = ActiveSliceSettings.Instance.GetActiveVector2("resume_position_before_z_home");
							queuedCommands.Add(CreateMovementLine(new PrinterMove(new VectorMath.Vector3(resumePositionXy.x, resumePositionXy.y, lastDestination.position.z + 5), 0, MovementControls.ZSpeed)));
							// move just above the actual print position
							queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position + new VectorMath.Vector3(0, 0, 5), 0, MovementControls.XSpeed)));
							// move down to part
							queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, MovementControls.ZSpeed)));
						}
						else
						{
							// move to the actual print position
							queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, MovementControls.ZSpeed)));
						}
						// extrude back to our filament start
						queuedCommands.Add("G1 E5");
						/// reset the printer to know where the filament should be
						queuedCommands.Add("G92 E{0}".FormatWith(lastDestination.extrusion));
						resumeState = ResumeState.PrintingSlow;
					}
					return "";

				case ResumeState.PrintingSlow:
					{
						string lineToSend = internalStream.ReadLine();
						if (!lineToSend.StartsWith("; LAYER:"))
						{
							if (lineToSend != null
								&& LineIsMovement(lineToSend))
							{
								PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
								PrinterMove moveToSend = currentMove;

								double feedRate;

								string firstLayerSpeed = ActiveSliceSettings.Instance.GetActiveValue("resume_first_layer_speed");
								if (!double.TryParse(firstLayerSpeed, out feedRate))
								{
									feedRate = 10;
								}
								feedRate *= 60;

								moveToSend.feedRate = feedRate;

								lineToSend = CreateMovementLine(moveToSend, lastDestination);
								lastDestination = currentMove;
								return lineToSend;
							}

							return lineToSend;
						}
					}

					resumeState = ResumeState.PrintingToEnd;
					return "";

				case ResumeState.PrintingToEnd:
					return internalStream.ReadLine();
			}

			return null;
		}
コード例 #13
0
        public RJMMutation(
            DocumentBLL documentBLL,
            DocumentTypeBLL documentTypeBLL,
            ResumeBLL resumeBLL,
            ResumeStateBLL resumeStateBLL,
            SkillBLL skillBLL,
            SkillAliasBLL skillAliasBLL,
            JobBLL jobBLL,
            JobStateBLL jobStateBLL
            )
        {
            this.AuthorizeWith("Authorized");

            // Documents
            //FieldAsync<DocumentType>(
            //    "createDocument",
            //    arguments: new QueryArguments(
            //        new QueryArgument<NonNullGraphType<DocumentInputType>>
            //        {
            //            Name = "document"
            //        }
            //    ),
            //    resolve: async context =>
            //    {
            //        Document document = context.GetArgument<Document>("document");

            //        return await context.TryAsyncResolve(
            //            async c => await documentBLL.CreateDocumentAsync(document)
            //        );
            //    }
            //);

            FieldAsync <GraphQLTypes.DocumentType>(
                "updateDocument",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <GraphQLTypes.DocumentInputType> >
            {
                Name = "document"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Document document = context.GetArgument <Document>("document");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.UpdateDocumentAsync(document)
                           ));
            }
                );

            FieldAsync <GraphQLTypes.DocumentType>(
                "linkResumeToDocument",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.LinkResumeToDocumentAsync(documentResume)
                           ));
            }
                );

            FieldAsync <GraphQLTypes.DocumentType>(
                "unlinkResumeFromDocument",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.UnlinkResumeFromDocumentAsync(documentResume)
                           ));
            }
                );

            FieldAsync <GraphQLTypes.DocumentType>(
                "removeDocument",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await documentBLL.DeleteDocumentByIdAsync(id)
                           ));
            }
                );

            // DocumentTypes
            FieldAsync <DocumentTypeType>(
                "createDocumentType",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentTypeInputType> >
            {
                Name = "documentType"
            }
                    ),
                resolve: async context =>
            {
                APIModels.DocumentType documentType = context.GetArgument <APIModels.DocumentType>("documentType");

                return(await context.TryAsyncResolve(
                           async c => await documentTypeBLL.CreateDocumentTypeAsync(documentType)
                           ));
            }
                );

            FieldAsync <DocumentTypeType>(
                "updateDocumentType",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <DocumentTypeInputType> >
            {
                Name = "documentType"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                APIModels.DocumentType documentType = context.GetArgument <APIModels.DocumentType>("documentType");

                return(await context.TryAsyncResolve(
                           async c => await documentTypeBLL.UpdateDocumentTypeAsync(documentType)
                           ));
            }
                );

            FieldAsync <DocumentTypeType>(
                "removeDocumentType",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await documentTypeBLL.DeleteDocumentTypeByIdAsync(id)
                           ));
            }
                );

            // Resumes
            FieldAsync <ResumeType>(
                "createResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeInputType> >
            {
                Name = "resume"
            }
                    ),
                resolve: async context =>
            {
                Resume resume = context.GetArgument <Resume>("resume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.CreateResumeAsync(resume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "updateResume",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <ResumeInputType> >
            {
                Name = "resume"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Resume resume = context.GetArgument <Resume>("resume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.UpdateResumeAsync(resume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "linkDocumentToResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.LinkDocumentToResumeAsync(documentResume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "unlinkDocumentFromResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <DocumentResumeInputType> >
            {
                Name = "documentResume"
            }
                    ),
                resolve: async context =>
            {
                DocumentResume documentResume = context.GetArgument <DocumentResume>("documentResume");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.UnlinkDocumentFromResumeAsync(documentResume)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "linkSkillToResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.LinkSkillToResumeAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "unlinkSkillFromResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.UnlinkSkillFromResumeAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <ResumeType>(
                "removeResume",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await resumeBLL.DeleteResumeByIdAsync(id)
                           ));
            }
                );

            // ResumeStates
            FieldAsync <ResumeStateType>(
                "createResumeState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeStateInputType> >
            {
                Name = "resumeState"
            }
                    ),
                resolve: async context =>
            {
                ResumeState resumeState = context.GetArgument <ResumeState>("resumeState");

                return(await context.TryAsyncResolve(
                           async c => await resumeStateBLL.CreateResumeStateAsync(resumeState)
                           ));
            }
                );

            FieldAsync <ResumeStateType>(
                "updateResumeState",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <ResumeStateInputType> >
            {
                Name = "resumeState"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                ResumeState resumeState = context.GetArgument <ResumeState>("resumeState");

                return(await context.TryAsyncResolve(
                           async c => await resumeStateBLL.UpdateResumeStateAsync(resumeState)
                           ));
            }
                );

            FieldAsync <ResumeStateType>(
                "removeResumeState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await resumeStateBLL.DeleteResumeStateByIdAsync(id)
                           ));
            }
                );

            // Skills
            FieldAsync <SkillType>(
                "createSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <SkillInputType> >
            {
                Name = "skill"
            }
                    ),
                resolve: async context =>
            {
                Skill skill = context.GetArgument <Skill>("skill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.CreateSkillAsync(skill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "updateSkill",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <SkillInputType> >
            {
                Name = "skill"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Skill skill = context.GetArgument <Skill>("skill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.UpdateSkillAsync(skill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "linkResumeToSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.LinkResumeToSkillAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "unlinkResumeFromSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <ResumeSkillInputType> >
            {
                Name = "resumeSkill"
            }
                    ),
                resolve: async context =>
            {
                ResumeSkill resumeSkill = context.GetArgument <ResumeSkill>("resumeSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.UnlinkResumeFromSkillAsync(resumeSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "linkJobToSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.LinkJobToSkillAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "unlinkJobFromSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.UnlinkJobFromSkillAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <SkillType>(
                "removeSkill",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await skillBLL.DeleteSkillByIdAsync(id)
                           ));
            }
                );

            // SkillAliases
            FieldAsync <SkillAliasType>(
                "createSkillAlias",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <SkillAliasInputType> >
            {
                Name = "skillAlias"
            }
                    ),
                resolve: async context =>
            {
                SkillAlias skillAlias = context.GetArgument <SkillAlias>("skillAlias");

                return(await context.TryAsyncResolve(
                           async c => await skillAliasBLL.CreateSkillAliasAsync(skillAlias)
                           ));
            }
                );

            FieldAsync <SkillAliasType>(
                "updateSkillAlias",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <SkillAliasInputType> >
            {
                Name = "skillAlias"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                SkillAlias skillAlias = context.GetArgument <SkillAlias>("skillAlias");

                return(await context.TryAsyncResolve(
                           async c => await skillAliasBLL.UpdateSkillAliasAsync(skillAlias)
                           ));
            }
                );

            FieldAsync <SkillAliasType>(
                "removeSkillAlias",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await skillAliasBLL.DeleteSkillAliasByIdAsync(id)
                           ));
            }
                );

            // Jobs
            FieldAsync <JobType>(
                "createJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobInputType> >
            {
                Name = "job"
            }
                    ),
                resolve: async context =>
            {
                Job job = context.GetArgument <Job>("job");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.CreateJobAsync(job)
                           ));
            }
                );

            FieldAsync <JobType>(
                "updateJob",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <JobInputType> >
            {
                Name = "job"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                Job job = context.GetArgument <Job>("job");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.UpdateJobAsync(job)
                           ));
            }
                );

            FieldAsync <JobType>(
                "linkSkillToJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.LinkSkillToJobAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <JobType>(
                "unlinkSkillFromJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobSkillInputType> >
            {
                Name = "jobSkill"
            }
                    ),
                resolve: async context =>
            {
                JobSkill jobSkill = context.GetArgument <JobSkill>("jobSkill");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.UnlinkSkillFromJobAsync(jobSkill)
                           ));
            }
                );

            FieldAsync <JobType>(
                "removeJob",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await jobBLL.DeleteJobByIdAsync(id)
                           ));
            }
                );

            // JobStates
            FieldAsync <JobStateType>(
                "createJobState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <JobStateInputType> >
            {
                Name = "jobState"
            }
                    ),
                resolve: async context =>
            {
                JobState jobState = context.GetArgument <JobState>("jobState");

                return(await context.TryAsyncResolve(
                           async c => await jobStateBLL.CreateJobStateAsync(jobState)
                           ));
            }
                );

            FieldAsync <JobStateType>(
                "updateJobState",
                arguments: new QueryArguments(
                    //new QueryArgument<NonNullGraphType<IdGraphType>>
                    //{
                    //    Name = "id"
                    //},
                    new QueryArgument <NonNullGraphType <JobStateInputType> >
            {
                Name = "jobState"
            }
                    ),
                resolve: async context =>
            {
                //Guid id = context.GetArgument<Guid>("id");
                JobState jobState = context.GetArgument <JobState>("jobState");

                return(await context.TryAsyncResolve(
                           async c => await jobStateBLL.UpdateJobStateAsync(jobState)
                           ));
            }
                );

            FieldAsync <JobStateType>(
                "removeJobState",
                arguments: new QueryArguments(
                    new QueryArgument <NonNullGraphType <IdGraphType> >
            {
                Name = "id"
            }
                    ),
                resolve: async context =>
            {
                Guid id = context.GetArgument <Guid>("id");

                return(await context.TryAsyncResolve(
                           async c => await jobStateBLL.DeleteJobStateByIdAsync(id)
                           ));
            }
                );
        }
コード例 #14
0
        /// <summary>
        /// Deletes an existing resumestate record by Id.
        /// </summary>
        public async Task <ResumeState> DeleteResumeStateByIdAsync(Guid resumeStateId)
        {
            ResumeState resumeState = await this.resumeStateRepository.GetByIdAsync(resumeStateId);

            return(await this.DeleteResumeStateAsync(resumeState));
        }
コード例 #15
0
        public override string ReadLine()
        {
            // Send any commands that are queue before moving on to the internal stream.
            string nextCommand = queuedCommands.ReadLine();

            if (nextCommand != null)
            {
                return(nextCommand);
            }

            switch (resumeState)
            {
            // heat the extrude to remove it from the part
            case ResumeState.RemoveHeating:
                // TODO: make sure we heat up all the extruders that we need to (all that are used)
                queuedCommands.Add("G21; set units to millimeters");
                queuedCommands.Add("M107; fan off");
                queuedCommands.Add("T0; set the active extruder to 0");
                queuedCommands.Add("G90; use absolute coordinates");
                queuedCommands.Add("G92 E0; reset the expected extruder position");
                queuedCommands.Add("M82; use absolute distance for extrusion");
                queuedCommands.Add("M109 S{0}".FormatWith(ActiveSliceSettings.Instance.Helpers.ExtruderTemperature(0)));

                resumeState = ResumeState.Raising;
                return("");

            // remove it from the part
            case ResumeState.Raising:
                queuedCommands.Add("M114 ; get current position");
                queuedCommands.Add("G91 ; move relative");
                queuedCommands.Add("G1 Z10 F{0}".FormatWith(MovementControls.ZSpeed));
                queuedCommands.Add("G90 ; move absolute");
                resumeState = ResumeState.Homing;
                return("");

            // if top homing, home the extruder
            case ResumeState.Homing:
                if (ActiveSliceSettings.Instance.GetValue <bool>(SettingsKey.z_homes_to_max))
                {
                    queuedCommands.Add("G28");
                }
                else
                {
                    // home x
                    queuedCommands.Add("G28 X0");
                    // home y
                    queuedCommands.Add("G28 Y0");
                    // move to the place we can home z from
                    Vector2 resumePositionXy = ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.resume_position_before_z_home);
                    queuedCommands.Add("G1 X{0:0.000}Y{1:0.000}F{2}".FormatWith(resumePositionXy.x, resumePositionXy.y, MovementControls.XSpeed));
                    // home z
                    queuedCommands.Add("G28 Z0");
                }
                resumeState = ResumeState.FindingResumeLayer;
                return("");

            // This is to resume printing if an out a filament occurs.
            // Help the user move the extruder down to just touching the part
            case ResumeState.FindingResumeLayer:
                if (false)                         // help the user get the head to the right position
                {
                    // move to above the completed print
                    // move over a know good part of the model at the current top layer (extrude vertex from gcode)
                    // let the user move down until they like the height
                    // calculate that position and continue
                }
                else                         // we are resuming because of disconnect or reset, skip this
                {
                    resumeState = ResumeState.SkippingGCode;
                    goto case ResumeState.SkippingGCode;
                }

            case ResumeState.SkippingGCode:
                // run through the gcode that the device expected looking for things like temp
                // and skip everything else until we get to the point we left off last time
                int commandCount = 0;
                boundsOfSkippedLayers = RectangleDouble.ZeroIntersection;
                while (internalStream.FileStreaming.PercentComplete(internalStream.LineIndex) < percentDone)
                {
                    string line = internalStream.ReadLine();
                    commandCount++;

                    // make sure we don't parse comments
                    if (line.Contains(";"))
                    {
                        line = line.Split(';')[0];
                    }
                    lastDestination = GetPosition(line, lastDestination);

                    if (commandCount > 100)
                    {
                        boundsOfSkippedLayers.ExpandToInclude(lastDestination.position.Xy);
                        if (boundsOfSkippedLayers.Bottom < 10)
                        {
                            int a = 0;
                        }
                    }

                    // check if the line is something we want to send to the printer (like a temp)
                    if (line.StartsWith("M109") ||
                        line.StartsWith("M104") ||
                        line.StartsWith("T") ||
                        line.StartsWith("M106") ||
                        line.StartsWith("M107"))
                    {
                        return(line);
                    }
                }

                resumeState = ResumeState.PrimingAndMovingToStart;

                // make sure we always- pick up the last movement
                boundsOfSkippedLayers.ExpandToInclude(lastDestination.position.Xy);
                return("");

            case ResumeState.PrimingAndMovingToStart:
            {
                if (ActiveSliceSettings.Instance.GetValue("z_homes_to_max") == "0")                                 // we are homed to the bed
                {
                    // move to the height we can resume printing from
                    Vector2 resumePositionXy = ActiveSliceSettings.Instance.GetValue <Vector2>(SettingsKey.resume_position_before_z_home);
                    queuedCommands.Add(CreateMovementLine(new PrinterMove(new VectorMath.Vector3(resumePositionXy.x, resumePositionXy.y, lastDestination.position.z), 0, MovementControls.ZSpeed)));
                }

                double extruderWidth = ActiveSliceSettings.Instance.GetValue <double>(SettingsKey.nozzle_diameter);
                // move to a position outside the printed bounds
                queuedCommands.Add(CreateMovementLine(new PrinterMove(
                                                          new Vector3(boundsOfSkippedLayers.Left - extruderWidth * 2, boundsOfSkippedLayers.Bottom + boundsOfSkippedLayers.Height / 2, lastDestination.position.z),
                                                          0, MovementControls.XSpeed)));

                // let's prime the extruder
                queuedCommands.Add("G1 E10 F{0}".FormatWith(MovementControls.EFeedRate(0))); // extrude 10
                queuedCommands.Add("G1 E9");                                                 // and retract a bit

                // move to the actual print position
                queuedCommands.Add(CreateMovementLine(new PrinterMove(lastDestination.position, 0, MovementControls.XSpeed)));

                /// reset the printer to know where the filament should be
                queuedCommands.Add("G92 E{0}".FormatWith(lastDestination.extrusion));
                resumeState = ResumeState.PrintingSlow;
            }
                return("");

            case ResumeState.PrintingSlow:
            {
                string lineToSend = internalStream.ReadLine();
                if (lineToSend == null)
                {
                    return(null);
                }

                if (!GCodeFile.IsLayerChange(lineToSend))
                {
                    // have not seen the end of this layer so keep printing slow
                    if (LineIsMovement(lineToSend))
                    {
                        PrinterMove currentMove = GetPosition(lineToSend, lastDestination);
                        PrinterMove moveToSend  = currentMove;

                        moveToSend.feedRate = resumeFeedRate;

                        lineToSend      = CreateMovementLine(moveToSend, lastDestination);
                        lastDestination = currentMove;
                        return(lineToSend);
                    }

                    return(lineToSend);
                }
            }

                // we only fall through to here after seeing the next "; Layer:"
                resumeState = ResumeState.PrintingToEnd;
                return("");

            case ResumeState.PrintingToEnd:
                return(internalStream.ReadLine());
            }

            return(null);
        }