public PrintExecuteViewModel(GCodeManagerViewModel GCodeManagerViewModel,
                                     RealTimeStatusDataModel RealTimeStatusDataModel, CalibrationViewModel CalibrationViewModel,
                                     SerialCommunicationViewModel SerialCommunicationViewModel, SerialCommunicationOutgoingMessagesModel SerialCommunicationOutgoingMessagesModel,
                                     SerialMessageDisplayViewModel SerialMessageDisplayViewModel, PrintViewModel PrintViewModel)
        {
            _gCodeManagerViewModel                    = GCodeManagerViewModel;
            _realTimeStatusDataModel                  = RealTimeStatusDataModel;
            _calibrationViewModel                     = CalibrationViewModel;
            _serialCommunicationViewModel             = SerialCommunicationViewModel;
            _serialCommunicationOutgoingMessagesModel = SerialCommunicationOutgoingMessagesModel;
            _serialMessageDisplayViewModel            = SerialMessageDisplayViewModel;
            _printViewModel = PrintViewModel;

            _gCodeManagerViewModel.GCodeFileUploaded      += new GCodeFileUploadedEventHandler(UpdateUploadedGCode);
            _printViewModel.PrintViewModelRepRapIDChanged += new PrintViewModelRepRapIDChanged(UpdateRepRapIDSet);

            _serialCommunicationViewModel.SerialCommunicationMainModel.SerialConnectionChanged                   += new SerialConnectionChangedEventHandler(UpdateSerialConnection);
            _serialCommunicationViewModel.SerialCommunicationMainModel.SerialCommunicationCompleted              += new SerialCommunicationCompletedEventHandler(UpdatePrintFinished);
            _serialCommunicationViewModel.SerialCommunicationMainModel.SerialCommunicationPrintSequencePaused    += new SerialCommunicationPrintSequencePausedEventHandler(UpdatePrintSequencePaused);
            _serialCommunicationViewModel.SerialCommunicationMainModel.SerialCommunicationMicrocontrollerResumed += new SerialCommunicationMicrocontrollerResumedEventHandler(UpdateMicrocontrollerResumed);

            _realTimeStatusDataModel.RecordSetMotorizedPrintheadExecuted += new RecordSetMotorizedPrintheadExecutedEventHandler(UpdateActivePrintheadType);
            _realTimeStatusDataModel.RecordSetValvePrintheadExecuted     += new RecordSetValvePrintheadExecutedEventHandler(UpdateActivePrintheadType);
            _realTimeStatusDataModel.RecordLimitExecuted += new RecordLimitExecutedEventHandler(UpdateLimitHit);

            _calibrationViewModel.CalibrationModel.CalibrationBegun += new CalibrationBegunEventHandler(UpdateCalibrationBegun);
        }
        public SaveLoadViewModel(GCodeManagerViewModel GCodeManagerViewModel, PrinterViewModel PrinterViewModel, PrintViewModel PrintViewModel, ErrorListViewModel ErrorListViewModel)
        {
            _gCodeManagerViewModel = GCodeManagerViewModel;
            _printerViewModel      = PrinterViewModel;
            _printViewModel        = PrintViewModel;
            _errorListViewModel    = ErrorListViewModel;

            _modiPrintXMLSerializerModel   = new ModiPrintXMLSerializerModel(_gCodeManagerViewModel, _printerViewModel, _printViewModel, _errorListViewModel);
            _modiPrintXMLDeserializerModel = new ModiPrintXMLDeserializerModel(_gCodeManagerViewModel, _printerViewModel, _printerViewModel.GPIOPinListsViewModel, _printViewModel, _errorListViewModel);
        }
Beispiel #3
0
        public ModiPrintXMLSerializerModel(GCodeManagerViewModel GCodeManagerViewModel, PrinterViewModel PrinterViewModel, PrintViewModel PrintViewModel, ErrorListViewModel ErrorListViewModel) : base(ErrorListViewModel)
        {
            //ModiPrint parts.
            _gCodeManagerViewModel = GCodeManagerViewModel;
            _printerViewModel      = PrinterViewModel;
            _printViewModel        = PrintViewModel;

            //XML Serializers.
            _gCodeManagerXMLSerializerModel = new GCodeManagerXMLSerializerModel();
            _printerXMLSerializerModel      = new PrinterXMLSerializerModel();
            _printXMLSerializerModel        = new PrintXMLSerializerModel();
        }
Beispiel #4
0
        public MainViewModel()
        {
            //Error Handling.
            _errorListViewModel = new ErrorListViewModel();

            //Printer Model.
            _printerModel = new PrinterModel();

            //Print Model.
            _printModel = new PrintModel(_printerModel);

            //Serial Communication Incoming and Outgoing Message Interpreter.
            _realTimeStatusDataModel = new RealTimeStatusDataModel(_printerModel);

            //Serial Communication.
            _serialCommunicationOutgoingMessagesModel = new SerialCommunicationOutgoingMessagesModel();
            _serialCommunicationMainModel             = new SerialCommunicationMainModel(_serialCommunicationOutgoingMessagesModel, _printerModel, _printModel, _realTimeStatusDataModel, _errorListViewModel);
            _serialMessageDisplayViewModel            = new SerialMessageDisplayViewModel();
            _serialCommunicationViewModel             = new SerialCommunicationViewModel(_serialCommunicationMainModel, _serialCommunicationOutgoingMessagesModel, _serialMessageDisplayViewModel);

            //Printer View Model.
            _printerViewModel = new PrinterViewModel(_printerModel, _serialCommunicationMainModel.SerialCommunicationCommandSetsModel);

            //Print View Model.
            _printViewModel = new PrintViewModel(_printModel, _serialMessageDisplayViewModel);

            //Real Time Status.
            _realTimeStatusSerialInterpreterModel = new RealTimeStatusSerialInterpreterModel(_serialCommunicationMainModel, _printerModel, _printerViewModel, _realTimeStatusDataModel, _errorListViewModel);
            _realTimeStatusDataViewModel          = new RealTimeStatusDataViewModel(_realTimeStatusDataModel, _printerViewModel, _serialCommunicationMainModel.SerialCommunicationCommandSetsModel, _errorListViewModel);

            //Manual Commmands and Calibration.
            _manualControlModel     = new ManualControlModel(_printerModel, _serialCommunicationOutgoingMessagesModel, _realTimeStatusDataModel, _errorListViewModel);
            _calibrationModel       = new CalibrationModel(_realTimeStatusDataModel, _printerModel, _serialCommunicationOutgoingMessagesModel, _errorListViewModel);
            _manualControlViewModel = new ManualControlViewModel(_manualControlModel, _realTimeStatusDataViewModel, _printerViewModel);
            _calibrationViewModel   = new CalibrationViewModel(_calibrationModel, _manualControlViewModel, _realTimeStatusDataViewModel, _printerViewModel);

            //GCode.
            _uploadedGCodeModel    = new GCodeModel();
            _gCodeFileManagerModel = new GCodeFileManagerModel(_uploadedGCodeModel, _errorListViewModel);
            _gCodeConverterModel   = new GCodeConverterModel(_printerModel, _printModel, _realTimeStatusDataModel, _errorListViewModel);
            _gcodeManagerViewModel = new GCodeManagerViewModel(_gCodeFileManagerModel, _gCodeConverterModel, _printViewModel);

            //Printing.
            _printExecuteViewModel = new PrintExecuteViewModel(_gcodeManagerViewModel, _realTimeStatusDataModel, _calibrationViewModel, _serialCommunicationViewModel, _serialCommunicationOutgoingMessagesModel, _serialMessageDisplayViewModel, _printViewModel);

            //Settings.
            _saveLoadViewModel = new SaveLoadViewModel(_gcodeManagerViewModel, _printerViewModel, _printViewModel, _errorListViewModel);

            //Unset Main Window.
            _unsetMainViewModel = new UnsetMainViewModel();
        }
Beispiel #5
0
        public ModiPrintXMLDeserializerModel(GCodeManagerViewModel GCodeManagerViewModel, PrinterViewModel PrinterViewModel, GPIOPinListsViewModel GPIOPinListsViewModel, PrintViewModel PrintViewModel,
                                             ErrorListViewModel ErrorListViewModel) : base(ErrorListViewModel)
        {
            //ModiPrint parts.
            _gCodeManagerViewModel = GCodeManagerViewModel;
            _printerViewModel      = PrinterViewModel;
            _gPIOPinListsViewModel = GPIOPinListsViewModel;
            _printViewModel        = PrintViewModel;

            //XML Serializers.
            _gCodeManagerXMLDeserializerModel = new GCodeManagerXMLDeserializerModel(_errorListViewModel);
            _printerXMLDeserializerModel      = new PrinterXMLDeserializerModel(_gPIOPinListsViewModel, _printerViewModel, _errorListViewModel);
            _printXMLDeserializerModel        = new PrintXMLDeserializerModel(_printerViewModel, _errorListViewModel);
        }
        /// <summary>
        /// Write GCodeManagerViewModel properties into XML.
        /// </summary>
        /// <param name="gCodeManagerViewModel"></param>
        /// <returns></returns>
        public void SerializeGCodeManager(XmlWriter xmlWriter, GCodeManagerViewModel gCodeManagerViewModel)
        {
            //Outmost element should be "GCodeManager".
            xmlWriter.WriteStartElement("GCodeManager");

            //Uploaded g-code.
            xmlWriter.WriteElementString("UploadedGCode", gCodeManagerViewModel.UploadedGCodeModel.GCodeStr);

            //Uploaded g-code type.
            xmlWriter.WriteElementString("UploadedGCodeType", gCodeManagerViewModel.UploadedGCodeType.ToString());

            //GCode File Name.
            xmlWriter.WriteElementString("GCodeFileName", gCodeManagerViewModel.GCodeFileName);

            //End "GCodeManager" outmost element.
            xmlWriter.WriteEndElement();
        }
        /// <summary>
        /// Reads GCodeManagerViewModel properties from XML and loads a GCodeManagerViewModel with said properties.
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="gCodeManagerViewModel"></param>
        public void DeserializeGCode(XmlReader xmlReader, GCodeManagerViewModel gCodeManagerViewModel)
        {
            //Read through each element of the XML string and populate each property of the GCodeManager.
            while (xmlReader.Read())
            {
                //Skip through newlines (this program's XML Writer uses newlines).
                if ((xmlReader.Name != "\n") && (!String.IsNullOrWhiteSpace(xmlReader.Name)))
                {
                    //End method if the end of "GCodeManager" element is reached.
                    if ((xmlReader.Name == "GCodeManager") && (xmlReader.NodeType == XmlNodeType.EndElement))
                    {
                        return;
                    }

                    switch (xmlReader.Name)
                    {
                    case "UploadedGCode":
                        gCodeManagerViewModel.UploadedGCodeModel.GCodeStr = xmlReader.ReadElementContentAsString();
                        gCodeManagerViewModel.UpdateRepRapIDList();
                        gCodeManagerViewModel.OnGCodeFileUploaded();
                        break;

                    case "UploadedGCodeType":
                        gCodeManagerViewModel.UploadedGCodeType = (GCodeType)Enum.Parse(typeof(GCodeType), xmlReader.ReadElementContentAsString(), false);
                        break;

                    case "GCodeFileName":
                        gCodeManagerViewModel.GCodeFileName = xmlReader.ReadElementContentAsString();
                        break;

                    default:
                        base.ReportErrorUnrecognizedElement(xmlReader);
                        break;
                    }
                }
            }
        }
Beispiel #8
0
        /// <summary>
        /// Loads saved XML user inputs containing properties of the Printer, Print, and GCode.
        /// </summary>
        /// <param name="xml"></param>
        /// <param name="printerViewModel"></param>
        /// <param name="printViewModel"></param>
        /// <param name="gCodeManagerViewModel"></param>
        public void DeserializeModiPrint(string xml, PrinterViewModel printerViewModel, PrintViewModel printViewModel, GCodeManagerViewModel gCodeManagerViewModel)
        {
            using (base._stringReader = new StringReader(xml))
            {
                using (base._xmlReader = XmlReader.Create(base._stringReader, base._xmlReaderSettings))
                {
                    //Ensure that the outmost element is "ModiPrint".
                    if (!(base._xmlReader.Read()) ||
                        !(base._xmlReader.Name == "ModiPrint") ||
                        !(base._xmlReader.NodeType == XmlNodeType.Element))
                    {
                        return;
                    }

                    //Read through each line of the XML.
                    while (base._xmlReader.Read())
                    {
                        //Skip through newlines (this program's XML Writer uses newlines).
                        if ((base._xmlReader.Name != "\n") && (!String.IsNullOrWhiteSpace(base._xmlReader.Name)))
                        {
                            //End method if the end of "ModiPrint" element is reached.
                            if ((base._xmlReader.Name == "ModiPrint") && (base._xmlReader.NodeType == XmlNodeType.EndElement))
                            {
                                return;
                            }

                            //Deserialize and populate each property of the Print.
                            switch (base._xmlReader.Name)
                            {
                            case "GCodeManager":
                                _gCodeManagerXMLDeserializerModel.DeserializeGCode(base._xmlReader, _gCodeManagerViewModel);
                                break;

                            case "Printer":
                                _printerXMLDeserializerModel.DeserializePrinter(base._xmlReader, _printerViewModel);
                                break;

                            case "Print":
                                _printXMLDeserializerModel.DeserializePrint(base._xmlReader, _printViewModel);
                                break;

                            default:
                                base.ReportErrorUnrecognizedElement(base._xmlReader);
                                break;
                            }
                        }
                    }
                }
            }
        }
Beispiel #9
0
        /// <summary>
        /// Writes this program's user input into XML.
        /// </summary>
        /// <param name="printerViewModel"></param>
        /// <param name="printViewModel"></param>
        /// <param name="gCodeManagerViewModel"></param>
        /// <returns></returns>
        public string SerializeModiPrint(PrinterViewModel printerViewModel, PrintViewModel printViewModel, GCodeManagerViewModel gCodeManagerViewModel)
        {
            using (base._stringWriter = new StringWriter())
            {
                using (base._xmlWriter = XmlWriter.Create(base._stringWriter, base._xmlWriterSettings))
                {
                    //Outmost element should be "ModiPrint".
                    base._xmlWriter.WriteStartElement("ModiPrint");

                    //GCode.
                    _gCodeManagerXMLSerializerModel.SerializeGCodeManager(base._xmlWriter, _gCodeManagerViewModel);

                    //Printer.
                    //It's very important to set the Printer before the Print, or else a lot of Printer equipment will not be found to set the Print.
                    _printerXMLSerializerModel.SerializePrinter(base._xmlWriter, _printerViewModel);

                    //Print.
                    _printXMLSerializerModel.SerializePrint(base._xmlWriter, _printViewModel);

                    //End outmost element "ModiPrint".
                    base._xmlWriter.WriteEndElement();
                }

                return(base._stringWriter.ToString());
            }
        }