Ejemplo n.º 1
0
        /// <summary>
        /// Translates raw task queued message for a Set Valve Printhead command into a readable phrase.
        /// Sets the Real Time Status based on the message.
        /// </summary>
        /// <param name="incomingMessage"></param>
        /// <returns></returns>
        public void InterpretSetValvePrintheadQueued(string incomingMessage)
        {
            string taskQueuedMessage = "Set Valve Printhead: ";           //Return string.
            string printheadName     = "Unknown Valve Printhead";         //Name of the Printhead. Labelled as unknown if Axis cannot be found.

            double[] parameterValues = ParseDoubleArray(incomingMessage); //Array of numerical values in incomingMessage.

            int valvePinID = (int)parameterValues[0];

            //Search for the PrintheadModel with the matching Valve Pin ID then return the Printhead Name.
            foreach (PrintheadModel printheadModel in _printerModel.PrintheadModelList)
            {
                if (printheadModel.PrintheadType == PrintheadType.Valve)
                {
                    ValvePrintheadTypeModel valvePrintheadTypeModel = (ValvePrintheadTypeModel)printheadModel.PrintheadTypeModel;
                    if (valvePinID == valvePrintheadTypeModel.AttachedValveGPIOPinModel.PinID)
                    {
                        printheadName = printheadModel.Name;
                        break;
                    }
                }
            }

            taskQueuedMessage += printheadName;

            //Set Real Time Status parameters based on this incomingMessage.
            if (printheadName != "Unknown Valve Printhead")
            {
                _realTimeStatusDataModel.RecordTaskQueued(taskQueuedMessage);
                _printerViewModel.FindPrinthead(printheadName).PrintheadStatus = PrintheadStatus.BeingSet;
            }
        }
        /// <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.");
            }
        }
Ejemplo n.º 3
0
 public ValvePrintheadTypeViewModel(ValvePrintheadTypeModel ValvePrintheadTypeModel, GPIOPinListsViewModel GPIOPinListsViewModel) : base(ValvePrintheadTypeModel, GPIOPinListsViewModel)
 {
     _valvePrintheadTypeModel = ValvePrintheadTypeModel;
 }