Beispiel #1
0
        /// <summary>
        /// Finds the appropriate WritePrinthead method and returns the converted GCode output.
        /// </summary>
        /// <param name="printheadModel"></param>
        /// <returns></returns>
        public string SetWritePrinthead(PrintheadModel printheadModel)
        {
            string convertedGCode = "";

            try
            {
                switch (printheadModel.PrintheadType)
                {
                case PrintheadType.Motorized:
                    convertedGCode = _writeSetPrintheadModel.WriteSetMotorDrivenPrinthead(printheadModel);
                    break;

                case PrintheadType.Valve:
                    convertedGCode = _writeSetPrintheadModel.WriteSetValvePrinthead(printheadModel);
                    break;

                case PrintheadType.Custom:
                    //To Do:
                    break;

                case PrintheadType.Unset:
                    //To Do: Stop everything something's wrong
                    break;

                default:
                    //To Do: Stop everything something's wrong
                    break;
                }
            }
            catch when(printheadModel == null)  //Catch unset Printhead.
            {
                //This should have been caught earlier.
                convertedGCode = "";
            }
        /// <summary>
        /// Takes manual input parameters for a set of valve printhead command and outputs the command to the serial port.
        /// </summary>
        /// <param name="printheadName"></param>
        public void ProcessManualSetValvePrintheadCommand(string printheadName)
        {
            try
            {
                List <string> outgoingMessagesList = new List <string>();

                PrintheadModel          printheadModel          = _printerModel.FindPrinthead(printheadName);
                ValvePrintheadTypeModel valvePrintheadTypeModel = (ValvePrintheadTypeModel)printheadModel.PrintheadTypeModel;
                string setPrintheadString = _writeSetPrintheadModel.WriteSetValvePrinthead(valvePrintheadTypeModel.AttachedValveGPIOPinModel.PinID);
                outgoingMessagesList.Add(setPrintheadString);

                //Send GCode for the Z Axis attached to the Printhead.
                AxisModel axisModel       = printheadModel.AttachedZAxisModel;
                int       zAxisLimitPinID = (axisModel.AttachedLimitSwitchGPIOPinModel == null) ? GlobalValues.PinIDNull : axisModel.AttachedLimitSwitchGPIOPinModel.PinID;
                string    setAxisString   = _writeSetAxisModel.WriteSetAxis(axisModel.AxisID, axisModel.AttachedMotorStepGPIOPinModel.PinID, axisModel.AttachedMotorDirectionGPIOPinModel.PinID,
                                                                            axisModel.StepPulseTime, zAxisLimitPinID, axisModel.MaxSpeed, axisModel.MaxAcceleration, axisModel.MmPerStep);

                outgoingMessagesList.Add(SerialMessageCharacters.SerialCommandSetCharacter + "RetractZ");
                outgoingMessagesList.Add(setAxisString);
                _serialCommunicationOutgoingMessagesModel.QueueNextProspectiveOutgoingMessage(outgoingMessagesList);
            }
            catch (NullReferenceException e)
            {
                _errorListViewModel.AddError("", "Printhead or z actuator needs to be set in Printer Settings before setting printhead in Control Menu.");
            }
            catch
            {
                _errorListViewModel.AddError("", "Unknown error while setting valve printhead.");
            }
        }