/// <summary> /// Deserializes an XML file with Valve Printhead Type properties then stores those properties into the input Valve PrintheadType. /// </summary> /// <param name="xmlReader"></param> /// <param name="printheadTypeViewModel"></param> public override void DeserializePrintheadType(XmlReader xmlReader, PrintheadTypeViewModel printheadTypeViewModel) { ValvePrintheadTypeViewModel valvePrintheadTypeViewModel = (ValvePrintheadTypeViewModel)printheadTypeViewModel; 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 "ValvePrintheadType" element is reached. if ((xmlReader.Name == "ValvePrintheadType") && (xmlReader.NodeType == XmlNodeType.EndElement)) { return; } switch (xmlReader.Name) { case "ValvePin": valvePrintheadTypeViewModel.AttachedValveGPIOPinViewModel = base._microcontrollerViewModel.FindPin(xmlReader.ReadElementContentAsInt()); valvePrintheadTypeViewModel.ExecuteRefreshPinBySettingListCommand("ValveGPIOPinViewModelList"); break; break; default: base.ReportErrorUnrecognizedElement(xmlReader); break; } } } }
/// <summary> /// Deserializes an XML file with Valve Printhead Type properties then stores those properties into the input Valve PrintheadType. /// </summary> /// <param name="xml"></param> /// <param name="printheadTypeViewModel"></param> public override void DeserializePrintheadType(XmlReader xmlReader, PrintheadTypeViewModel printheadTypeViewModel) { CustomPrintheadTypeViewModel customPrintheadTypeViewModel = (CustomPrintheadTypeViewModel)printheadTypeViewModel; //Reading this XML is unnecessary until Custom Printhead Type is implemented. //For now, reading this XML while it has no child elements would actually break the reader. /* * 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 "CustomPrintheadType" element is reached. * if ((xmlReader.Name == "CustomPrintheadType") && (xmlReader.NodeType == XmlNodeType.EndElement)) * { * return; * } * * switch (xmlReader.Name) * { * default: * base.ReportXMLReaderError(xmlReader); * break; * } * } * } */ }
/// <summary> /// Writes Custom Printhead Type properties into XML. /// </summary> /// <param name="printheadTypeViewModel"></param> /// <returns></returns> public override void SerializePrintheadType(XmlWriter xmlWriter, PrintheadTypeViewModel printheadTypeViewModel) { if (printheadTypeViewModel != null) { CustomPrintheadTypeViewModel customPrintheadTypeViewModel = (CustomPrintheadTypeViewModel)printheadTypeViewModel; //Outmost element should be "CustomPrintheadType". xmlWriter.WriteStartElement("CustomPrintheadType"); //Close outmost element "CustomPrintheadType". xmlWriter.WriteEndElement(); } }
/// <summary> /// Writes Motorized Printhead Type properties into XML. /// </summary> /// <param name="printheadTypeViewModel"></param> /// <returns></returns> public override void SerializePrintheadType(XmlWriter xmlWriter, PrintheadTypeViewModel printheadTypeViewModel) { if (printheadTypeViewModel != null) { MotorizedPrintheadTypeViewModel motorizedPrintheadTypeViewModel = (MotorizedPrintheadTypeViewModel)printheadTypeViewModel; //Outmost element should be "MotorizedPrintheadType". xmlWriter.WriteStartElement("MotorizedPrintheadType"); //Motor Step Pin. if (motorizedPrintheadTypeViewModel.AttachedMotorStepGPIOPinViewModel != null) { xmlWriter.WriteElementString("MotorStepPin", motorizedPrintheadTypeViewModel.AttachedMotorStepGPIOPinViewModel.PinID.ToString()); } //Motor Direction Pin. if (motorizedPrintheadTypeViewModel.AttachedMotorDirectionGPIOPinViewModel != null) { xmlWriter.WriteElementString("MotorDirectionPin", motorizedPrintheadTypeViewModel.AttachedMotorDirectionGPIOPinViewModel.PinID.ToString()); } //Step Pulse Time. xmlWriter.WriteElementString("StepPulseTime", motorizedPrintheadTypeViewModel.StepPulseTime.ToString()); //Limit Switch Pin. if (motorizedPrintheadTypeViewModel.AttachedLimitSwitchGPIOPinViewModel != null) { xmlWriter.WriteElementString("LimitSwitchPin", motorizedPrintheadTypeViewModel.AttachedLimitSwitchGPIOPinViewModel.PinID.ToString()); } //Max Speed. xmlWriter.WriteElementString("MaxSpeed", motorizedPrintheadTypeViewModel.MaxSpeed.ToString()); //Max Acceleration. xmlWriter.WriteElementString("MaxAcceleration", motorizedPrintheadTypeViewModel.MaxAcceleration.ToString()); //mm per Step. xmlWriter.WriteElementString("MmPerStep", motorizedPrintheadTypeViewModel.MmPerStep.ToString()); //Max Position. xmlWriter.WriteElementString("MaxPosition", motorizedPrintheadTypeViewModel.MaxPosition.ToString()); //Min Position. xmlWriter.WriteElementString("MinPosition", motorizedPrintheadTypeViewModel.MinPosition.ToString()); //Close outmost element "MotorizedPrintheadType". xmlWriter.WriteEndElement(); } }
/// <summary> /// Writes Valve Printhead Type properties into XML. /// </summary> /// <param name="printheadTypeViewModel"></param> /// <returns></returns> public override void SerializePrintheadType(XmlWriter xmlWriter, PrintheadTypeViewModel printheadTypeViewModel) { if (printheadTypeViewModel != null) { ValvePrintheadTypeViewModel valvePrintheadTypeViewModel = (ValvePrintheadTypeViewModel)printheadTypeViewModel; //Outmost element should be "ValvePrintheadType". xmlWriter.WriteStartElement("ValvePrintheadType"); //Valve Pin. if (valvePrintheadTypeViewModel.AttachedValveGPIOPinViewModel != null) { xmlWriter.WriteElementString("ValvePin", valvePrintheadTypeViewModel.AttachedValveGPIOPinViewModel.PinID.ToString()); } //Close outmost element "ValvePrintheadType". xmlWriter.WriteEndElement(); } }
public abstract void SerializePrintheadType(XmlWriter xmlWriter, PrintheadTypeViewModel printheadTypeViewModel);
public abstract void DeserializePrintheadType(XmlReader xmlReader, PrintheadTypeViewModel printheadTypeViewModel);
/// <summary> /// Deserializes an XML file with Motorized Printhead Type properties then stores those properties into the input Valve PrintheadType. /// </summary> /// <param name="xml"></param> /// <param name="printheadTypeViewModel"></param> public override void DeserializePrintheadType(XmlReader xmlReader, PrintheadTypeViewModel printheadTypeViewModel) { MotorizedPrintheadTypeViewModel motorizedPrintheadTypeViewModel = (MotorizedPrintheadTypeViewModel)printheadTypeViewModel; 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 "MotorizedPrintheadType" element is reached. if ((xmlReader.Name == "MotorizedPrintheadType") && (xmlReader.NodeType == XmlNodeType.EndElement)) { return; } switch (xmlReader.Name) { case "MotorStepPin": motorizedPrintheadTypeViewModel.AttachedMotorStepGPIOPinViewModel = base._microcontrollerViewModel.FindPin(xmlReader.ReadElementContentAsInt()); motorizedPrintheadTypeViewModel.ExecuteRefreshPinBySettingListCommand("MotorStepPinViewModelList"); break; case "MotorDirectionPin": motorizedPrintheadTypeViewModel.AttachedMotorDirectionGPIOPinViewModel = base._microcontrollerViewModel.FindPin(xmlReader.ReadElementContentAsInt()); motorizedPrintheadTypeViewModel.ExecuteRefreshPinBySettingListCommand("MotorDirectionPinViewModelList"); break; case "StepPulseTime": motorizedPrintheadTypeViewModel.StepPulseTime = xmlReader.ReadElementContentAsInt(); break; case "LimitSwitchPin": motorizedPrintheadTypeViewModel.AttachedLimitSwitchGPIOPinViewModel = base._microcontrollerViewModel.FindPin(xmlReader.ReadElementContentAsInt()); motorizedPrintheadTypeViewModel.ExecuteRefreshPinBySettingListCommand("LimitSwitchPinViewModelList"); break; case "MaxSpeed": motorizedPrintheadTypeViewModel.MaxSpeed = xmlReader.ReadElementContentAsDouble(); break; case "MaxAcceleration": motorizedPrintheadTypeViewModel.MaxAcceleration = xmlReader.ReadElementContentAsDouble(); break; case "MmPerStep": motorizedPrintheadTypeViewModel.MmPerStep = xmlReader.ReadElementContentAsDouble(); break; case "MaxPosition": motorizedPrintheadTypeViewModel.MaxPosition = xmlReader.ReadElementContentAsDouble(); break; case "MinPosition": motorizedPrintheadTypeViewModel.MinPosition = xmlReader.ReadElementContentAsDouble(); break; default: base.ReportErrorUnrecognizedElement(xmlReader); break; } } } }