// Extract an unsigned value from an attribute
int EpiphanyXML::ExtractAttr(XMLElement* element, unsigned* uns_p, char* name)
{
	char buf[128];
	XMLVariable* v;

	v = element->FindVariableZ(name);

	// If the variable could not be found, return an error.
	if (!v)
	{
		return -1;
	}

	// Else, convert it to an unsigned.
	v->GetValue(buf);
	*uns_p = strtoul(buf, NULL, 0);
	return 0;
}
// Extract coordinates from a "(y,x)" string
int EpiphanyXML::ExtractCoords(XMLElement* element, unsigned* yid, unsigned* xid)
{
	int valuelen;

	// Given the attribute's name, find it in the element.
	XMLVariable* v = element->FindVariableZ("id");

	if ((!v) || ((valuelen = v->GetValue(0, 0)) == 0))
	{
		return -1;
	}
	else
	{
		int valuelen = v->GetValue(0, 0);
		char buf[valuelen+1];
		v->GetValue(buf);
		return (sscanf(buf, "(%u,%u)", yid, xid) == 2) ? 0: -1;
	}
}
Exemple #3
0
int OpenXML(const char* XMLFile, char *attribute)
{
	XML* xml = new XML(XMLFile);
	XMLElement* root = xml->GetRootElement();
	unsigned int nodeCount = root->GetChildrenNum();
	XMLElement** node = root->GetChildren();

	for (unsigned int i = 0; i < nodeCount; i++) {
        unsigned int leafCount = node[i]->GetChildrenNum();
        XMLElement** leaf = node[i]->GetChildren();

        for (unsigned int j = 0; j < leafCount; j++) {
            XMLVariable* Att = leaf[j]->FindVariableZ(attribute);
            if (Att) {
                char Buf[255];
                Att->GetValue(Buf);
                printf("Attribute %s has value %s\n", attribute, Buf);
            }
        }
	}
	delete xml;
	return 0;
}
// Extract a string value from an attribute
int EpiphanyXML::ExtractAttr(XMLElement* element, char** value, char* attr)
{
	// Given the attribute's name, find it in the element.
	XMLVariable* v = element->FindVariableZ(attr);

	// If the attribute could not be found, set *value to NULL and return an error.
	if (!v)
	{
		*value = NULL;
		return -1;
	}

	// Find the length of the attribute
	int valuelen = v->GetValue(0, 0);

	// Create a new string big enough to hold the attribute's value.
	*value = new char[valuelen+1];

	// Copy the value of the attribute to the provided string pointer.
	v->GetValue(*value);

	return 0;
}
Exemple #5
0
void ProcessController::LoadXML(XMLElement *e)
{
	XMLElement *x = e->FindElementZ("ProcessController", true);

	XMLVariable* y;

	y=x->FindVariableZ("RaftSize", true, "1.33");
	if(y)	RaftSize = y->GetValueFloat();
	y=x->FindVariableZ("RaftBaseLayerCount", true, "1");
	if(y)	RaftBaseLayerCount = y->GetValueInt();
	y=x->FindVariableZ("RaftMaterialPrDistanceRatio", true, "1.7");
	if(y)	RaftMaterialPrDistanceRatio = y->GetValueFloat();
	y=x->FindVariableZ("RaftRotation", true, "90");
	if(y)	RaftRotation = y->GetValueFloat();
	y=x->FindVariableZ("RaftBaseDistance", true, "2.5");
	if(y)	RaftBaseDistance = y->GetValueFloat();
	y=x->FindVariableZ("RaftBaseThickness", true, "1");
	if(y)	RaftBaseThickness = y->GetValueFloat();
	y=x->FindVariableZ("RaftBaseTemperature", true, "190");
	if(y)	RaftBaseTemperature = y->GetValueFloat();
	y=x->FindVariableZ("RaftInterfaceLayerCount", true, "2");
	if(y)	RaftInterfaceLayerCount = y->GetValueInt();
	y=x->FindVariableZ("RaftInterfaceMaterialPrDistanceRatio", true, "1");
	if(y)	RaftInterfaceMaterialPrDistanceRatio = y->GetValueFloat();
	y=x->FindVariableZ("RaftRotationPrLayer", true, "90");
	if(y)	RaftRotationPrLayer = y->GetValueFloat();
	y=x->FindVariableZ("RaftInterfaceDistance", true, "2");
	if(y)	RaftInterfaceDistance = y->GetValueFloat();
	y=x->FindVariableZ("RaftInterfaceThickness", true, "1");
	if(y)	RaftInterfaceThickness = y->GetValueFloat();
	y=x->FindVariableZ("RaftInterfaceTemperature", true, "190");
	if(y)	RaftInterfaceTemperature = y->GetValueFloat();

	// GCode parameters

	char buffer[10000];
	memset(buffer,0,10000);
	x->FindVariableZ("GCodeStartText", true, "; GCode generated by RepSnapper by Kulitorum\nG21                              ;metric is good!\nG90                              ;absolute positioning\nT0                                 ;select new extruder\nG28                               ;go home\nG92 E0                          ;set extruder home\nM104 S73.0                   ;set temperature\nG1 X20 Y20 F500            ;Move away from 0.0, so we use the same reset (in the layer code) for each layer\n\n")->GetValue(buffer);
	GCodeStartText = string(buffer);
	memset(buffer,0,10000);
	x->FindVariableZ("GCodeLayerText", true, "M106                            ;cooler on \nG1 F2000;\nG1 X-250 E0 F2000.0       ;horizontal move\nG1 X-249.9                  ;horizontal move\nG1 X-250.0 E0 F50.0        ;horizontal move\nG92 X0                         ;set x 0\nG1 F2000;\nG1 Y-250 E0 F2000.0       ;horizontal move\nG1 Y-249.9  E0 F200          ;horizontal move\nG1 Y-250.0 F50.0        ;horizontal move\nG92 Y0                         ;set y 0\nG1 F500;\nG1 X20 E20 F500       ;Shield\nG1 X0 E20 F500         ;Shield\nT0                                 ;select new extruder\nG92 E0                         ;zero the extruded length\n")->GetValue(buffer);
	GCodeLayerText = string(buffer);
	memset(buffer,0,10000);
	x->FindVariableZ("GCodeEndText", true, "M107                            ;cooler off\nG1 X0 Y0 E0 F2000.0       ;feed for start of next move\nM104 S0.0                    ;Heater off\n")->GetValue(buffer);
	GCodeEndText = string(buffer);
	memset(buffer,0,10000);
	x->FindVariableZ("Notes", true, "")->GetValue(buffer);
	Notes = string(buffer);

	memset(buffer,0,10000);
	x->FindVariableZ("m_sPortName", true, "COM5")->GetValue(buffer);
	m_sPortName = string(buffer);

	y=x->FindVariableZ("GCodeDrawStart", true, "0");
	if(y)	GCodeDrawStart = y->GetValueFloat();
	y=x->FindVariableZ("GCodeDrawEnd", true, "1");
	if(y)	GCodeDrawEnd = y->GetValueFloat();
	y=x->FindVariableZ("MinPrintSpeedXY", true, "400");
	if(y)	MinPrintSpeedXY = y->GetValueFloat();
	y=x->FindVariableZ("MaxPrintSpeedXY", true, "1500");
	if(y)	MaxPrintSpeedXY = y->GetValueFloat();
	y=x->FindVariableZ("MinPrintSpeedZ", true, "50");
	if(y)	MinPrintSpeedZ = y->GetValueFloat();
	y=x->FindVariableZ("MaxPrintSpeedZ", true, "150");
	if(y)	MaxPrintSpeedZ = y->GetValueFloat();

	y=x->FindVariableZ("DistanceToReachFullSpeed", true, "3");
	if(y)	DistanceToReachFullSpeed = y->GetValueFloat();
	y=x->FindVariableZ("extrusionFactor", true, "1");
	if(y)	extrusionFactor = y->GetValueFloat();

	// Printer parameters
	y=x->FindVariableZ("m_fVolume.x", true, "200");
	if(y)	m_fVolume.x = y->GetValueFloat();
	y=x->FindVariableZ("m_fVolume.y", true, "200");
	if(y)	m_fVolume.y = y->GetValueFloat();
	y=x->FindVariableZ("m_fVolume.z", true, "140");
	if(y)	m_fVolume.z = y->GetValueFloat();
	y=x->FindVariableZ("PrintMargin.x", true, "10");
	if(y)	PrintMargin.x = y->GetValueFloat();
	y=x->FindVariableZ("PrintMargin.y", true, "10");
	if(y)	PrintMargin.y = y->GetValueFloat();
	y=x->FindVariableZ("PrintMargin.z", true, "0");
	if(y)	PrintMargin.z = y->GetValueFloat();
	y=x->FindVariableZ("ExtrudedMaterialWidth", true, "0.7");
	if(y)	ExtrudedMaterialWidth = y->GetValueFloat();


	// STL parameters
	y=x->FindVariableZ("LayerThickness", true, "0.4");
	if(y)	LayerThickness = y->GetValueFloat();
	y=x->FindVariableZ("CuttingPlaneValue", true, "0.5");
	if(y)	CuttingPlaneValue = y->GetValueFloat();

	// CuttingPlane
	y=x->FindVariableZ("InfillDistance", true, "2");
	if(y)	InfillDistance = y->GetValueFloat();
	y=x->FindVariableZ("InfillRotation", true, "90");
	if(y)	InfillRotation = y->GetValueFloat();
	y=x->FindVariableZ("InfillRotationPrLayer", true, "90");
	if(y)	InfillRotationPrLayer = y->GetValueFloat();
	y=x->FindVariableZ("ShellOnly", true, "0");
	if(y)	ShellOnly = y->GetValueFloat();
	y=x->FindVariableZ("ShellCount", true, "1");
	if(y)	ShellCount = y->GetValueFloat();
	y=x->FindVariableZ("EnableAcceleration", true, "1");
	if(y)	EnableAcceleration = (bool)y->GetValueInt();
	y=x->FindVariableZ("UseIncrementalEcode", true, "0");
	if(y)	UseIncrementalEcode= (bool)y->GetValueInt();
	y=x->FindVariableZ("Use3DGcode", true, "0");
	if(y)	Use3DGcode= (bool)y->GetValueInt();
	
	y=x->FindVariableZ("FileLogginEnabled", true, "1");
	if(y)	FileLogginEnabled= (bool)y->GetValueInt();
	y=x->FindVariableZ("TempReadingEnabled", true, "1");
	if(y)	TempReadingEnabled= (bool)y->GetValueInt();
	y=x->FindVariableZ("ClearLogfilesWhenPrintStarts", true, "1");
	if(y)	ClearLogfilesWhenPrintStarts= (bool)y->GetValueInt();

	// GUI... ?
	y=x->FindVariableZ("DisplayEndpoints", true, "0");
	if(y)	DisplayEndpoints = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayNormals", true, "0");
	if(y)	DisplayNormals = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayWireframe", true, "0");
	if(y)	DisplayWireframe = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayWireframeShaded", true, "1");
	if(y)	DisplayWireframeShaded = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayPolygons", true, "1");
	if(y)	DisplayPolygons = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayAllLayers", true, "0");
	if(y)	DisplayAllLayers = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayinFill", true, "1");
	if(y)	DisplayinFill = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayDebuginFill", true, "0");
	if(y)	DisplayDebuginFill = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayDebug", true, "0");
	if(y)	DisplayDebug = (bool)y->GetValueInt();
	y=x->FindVariableZ("DisplayCuttingPlane", true, "0");
	if(y)	DisplayCuttingPlane =(bool)y->GetValueInt();
	y=x->FindVariableZ("DrawVertexNumbers", true, "0");
	if(y)	DrawVertexNumbers = (bool)y->GetValueInt();
	y=x->FindVariableZ("DrawLineNumbers", true, "0");
	if(y)	DrawLineNumbers = (bool)y->GetValueInt();

	y=x->FindVariableZ("PolygonVal", true, "0.5");
	if(y)	PolygonVal = y->GetValueFloat();
	y=x->FindVariableZ("PolygonSat", true, "1");
	if(y)	PolygonSat = y->GetValueFloat();
	y=x->FindVariableZ("PolygonHue", true, "0.54");
	if(y)	PolygonHue = y->GetValueFloat();
	y=x->FindVariableZ("WireframeVal", true, "1");
	if(y)	WireframeVal = y->GetValueFloat();
	y=x->FindVariableZ("WireframeSat", true, "1");
	if(y)	WireframeSat = y->GetValueFloat();
	y=x->FindVariableZ("WireframeHue", true, "0.08");
	if(y)	WireframeHue = y->GetValueFloat();
	y=x->FindVariableZ("NormalsSat", true, "1");
	if(y)	NormalsSat = y->GetValueFloat();
	y=x->FindVariableZ("NormalsVal", true, "1");
	if(y)	NormalsVal = y->GetValueFloat();
	y=x->FindVariableZ("NormalsHue", true, "0.23");
	if(y)	NormalsHue = y->GetValueFloat();
	y=x->FindVariableZ("EndpointsSat", true, "1");
	if(y)	EndpointsSat = y->GetValueFloat();
	y=x->FindVariableZ("EndpointsVal", true, "1");
	if(y)	EndpointsVal = y->GetValueFloat();
	y=x->FindVariableZ("EndpointsHue", true, "0.45");
	if(y)	EndpointsHue = y->GetValueFloat();
	y=x->FindVariableZ("GCodeExtrudeHue", true, "0.18");
	if(y)	GCodeExtrudeHue = y->GetValueFloat();
	y=x->FindVariableZ("GCodeExtrudeSat", true, "1");
	if(y)	GCodeExtrudeSat = y->GetValueFloat();
	y=x->FindVariableZ("GCodeExtrudeVal", true, "1");
	if(y)	GCodeExtrudeVal = y->GetValueFloat();
	y=x->FindVariableZ("GCodeMoveHue", true, "1");
	if(y)	GCodeMoveHue = y->GetValueFloat();
	y=x->FindVariableZ("GCodeMoveSat", true, "0.95");
	if(y)	GCodeMoveSat = y->GetValueFloat();
	y=x->FindVariableZ("GCodeMoveVal", true, "1");
	if(y)	GCodeMoveVal = y->GetValueFloat();
	y=x->FindVariableZ("Highlight", true, "0.7");
	if(y)	Highlight = y->GetValueFloat();
	y=x->FindVariableZ("NormalsLength", true, "10");
	if(y)	NormalsLength = y->GetValueFloat();
	y=x->FindVariableZ("EndPointSize", true, "8");
	if(y)	EndPointSize = y->GetValueFloat();

	y=x->FindVariableZ("TempUpdateSpeed", true, "3");
	if(y)	TempUpdateSpeed = y->GetValueFloat();


	y=x->FindVariableZ("DisplayGCode", true, "1");
	if(y)	DisplayGCode = (bool)y->GetValueInt();
	y=x->FindVariableZ("LuminanceShowsSpeed", true, "1");
	if(y)	LuminanceShowsSpeed = (bool)y->GetValueInt();

	y=x->FindVariableZ("RaftEnable", true, "1");
	if(y)	RaftEnable = (bool)y->GetValueInt();
	y=x->FindVariableZ("ApronEnable", true, "0");
	if(y)	ApronEnable = (bool)y->GetValueInt();
	y=x->FindVariableZ("ApronPreview", true, "1");
	if(y)	ApronPreview = (bool)y->GetValueInt();
	y=x->FindVariableZ("ApronSize", true, "1.33");
	if(y)	ApronSize = (bool)y->GetValueFloat();
	y=x->FindVariableZ("ApronHeight", true, "7");
	if(y)	ApronHeight = (bool)y->GetValueFloat();
	y=x->FindVariableZ("ApronCoverageX", true, "60");
	if(y)	ApronCoverageX = (bool)y->GetValueFloat();
	y=x->FindVariableZ("ApronCoverageY", true, "60");
	if(y)	ApronCoverageY = (bool)y->GetValueFloat();
	y=x->FindVariableZ("ApronDistanceToObject", true, "0.5");
	if(y)	ApronDistanceToObject = (bool)y->GetValueFloat();
	y=x->FindVariableZ("ApronInfillDistance", true, "2");
	if(y)	ApronInfillDistance = (bool)y->GetValueFloat();

	y=x->FindVariableZ("ShrinkNice", true, "0");
	if(y)	m_ShrinkQuality = (bool)y->GetValueInt() ? SHRINK_NICE : SHRINK_FAST;


	/*
	ImageProcessingSettings();
	UserCurve[0] = UserCurve[1] = 0.0f;
	UserCurve[2] = UserCurve[3] = 0.250f;
	UserCurve[4] = UserCurve[5] = 0.50f;
	UserCurve[6] = UserCurve[7] = 0.750f;
	UserCurve[8] = UserCurve[9] = 1.0f;
	XMLElement *x = e->FindElementZ("RED_ProcessingSettings", true);


	Detail = R3DSDK::ImageDetail::ImageDetailHigh;
	OLPFCompensation = R3DSDK::ImageOLPFCompensation::ImageOLPFCompHigh;
	Denoise = R3DSDK::ImageDenoise::ImageDenoiseMaximum;

	XMLVariable* y;

	char buffer[100];
	memset(buffer,0,100);
	x->FindVariableZ("GammaCurve", true, "None")->GetValue(buffer);
	string GammaC(buffer);
	for(uint i=0;i<ImageProcessingLimits::GammaCurveCount;i++)
	{
		string ThisCurveName(ImageProcessingLimits::GammaCurveLabels[i]);
		if(GammaC == ThisCurveName)
			GammaCurve = ImageProcessingLimits::GammaCurveMap[i];
	}

	memset(buffer,0,100);
	x->FindVariableZ("ColorSpace", true, "None")->GetValue(buffer);
	string ColSp(buffer);
	for(uint i=0;i<ImageProcessingLimits::ColorSpaceCount;i++)
	{
		string ThisCurveName(ImageProcessingLimits::ColorSpaceLabels[i]);
		if(ColSp == ThisCurveName)
			ColorSpace = ImageProcessingLimits::ColorSpaceMap[i];
	}

	y=x->FindVariableZ("ISO", false, "320");
	if(y)
		ISO				= y->GetValueInt();	
	y=x->FindVariableZ("Kelvin", false, "3200");
	if(y)
		Kelvin				= y->GetValueFloat();	
	y = x->FindVariableZ("Tint", false, "0");
	if(y)
		Tint					= y->GetValueFloat();	
	y = x->FindVariableZ("ExposureCompensation", false, "0");
	if(y)
		ExposureCompensation	=y->GetValueFloat();	
	y = x->FindVariableZ("GainRed", false, "1");
	if(y)
		GainRed				= y->GetValueFloat();	
	y = x->FindVariableZ("GainGreen", false, "1");
	if(y)
		GainGreen			= y->GetValueFloat();	
	y = x->FindVariableZ("GainBlue", false, "1");
	if(y)
		GainBlue			= y->GetValueFloat();	
	y = x->FindVariableZ("Saturation", false, "1");
	if(y)
		Saturation			= y->GetValueFloat();	
	y = x->FindVariableZ("Contrast", false, "1");
	if(y)
		Contrast			= y->GetValueFloat();	
	y = x->FindVariableZ("Brightness", false, "1");
	if(y)
		Brightness			= y->GetValueFloat();	
	y = x->FindVariableZ("DRX", false, "0");
	if(y)
		DRX					= y->GetValueFloat();	

	y = x->FindVariableZ("CustomPDLogGamma", false, "0");
	if(y)
		CustomPDLogGamma			= y->GetValueFloat();	

	y = x->FindVariableZ("UserCurve0", false, "0.00");
	if(y)
		UserCurve[0]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve1", false, "0.00");
	if(y)
		UserCurve[1]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve2", false, "0.25");
	if(y)
		UserCurve[2]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve3", false, "0.25");
	if(y)
		UserCurve[3]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve4", false, "0.50");
	if(y)
		UserCurve[4]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve5", false, "0.50");
	if(y)
		UserCurve[5]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve6", false, "0.75");
	if(y)
		UserCurve[6]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve7", false, "0.75");
	if(y)
		UserCurve[7]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve8", false, "1.00");
	if(y)
		UserCurve[8]  = y->GetValueFloat();	
	y = x->FindVariableZ("UserCurve9", false, "1.00");
	if(y)
		UserCurve[9]  = y->GetValueFloat();	*/
}