int EndReaction() { if (nreact >= MAXREACT) { fprintf(stderr, "Too many reactions. Maximum of this version is %i\n", MAXREACT); return (1); } reaction[nreact].educt = educt + oldneduct; reaction[nreact].product = product + oldnproduct; reaction[nreact].neduct = neduct - oldneduct; reaction[nreact].nproduct = nproduct - oldnproduct; reaction[nreact].netot = netot; #ifdef FULLM reaction[nreact].nm = nm; reaction[nreact].nox = nox; reaction[nreact].nn2 = nn2; nm = nox = nn2 = 0; #endif ConvertUnits(); oldneduct = neduct; oldnproduct = nproduct; netot = 0; fixedconc = 1.; nreact++; return (0); }
///////////////////////////////////////////////////////////////////////////// // GetField() // Return requested field as a double (function return value) or as a text // string (*pstr) in the units requested (eUnit). Set 'bStrUnits' to true // to have units appended to text string. // // Note: numeric return values are cached; asking for the same field more // than once incurs minimal overhead. double cTle::GetField(eField fld, eUnits units, /* = U_NATIVE */ string *pstr /* = NULL */, bool bStrUnits /* = false */) const { assert((FLD_FIRST <= fld) && (fld < FLD_LAST)); assert((U_FIRST <= units) && (units < U_LAST)); if (pstr) { // Return requested field in string form. *pstr = m_Field[fld]; if (bStrUnits) { *pstr += GetUnits(fld); } TrimLeft (*pstr); TrimRight(*pstr); return 0.0; } else { // Return requested field in floating-point form. // Return cache contents if it exists, else populate cache FldKey key = Key(units, fld); if (m_mapCache.find(key) == m_mapCache.end()) { // Value not in cache; add it double valNative = atof(m_Field[fld].c_str()); double valConv = ConvertUnits(valNative, fld, units); m_mapCache[key] = valConv; return valConv; } else { // return cached value return m_mapCache[key]; } } }
void GCodeInterpreter::G00(GCodeLine& line) { Point end; if(coordType == ABS) { end = Point( ConvertUnits(line.GetParam('X')), ConvertUnits(line.GetParam('Y')), ConvertUnits(line.GetParam('Z'))); } else { end = currentPosition + Point( ConvertUnits(line.GetParam('X')), ConvertUnits(line.GetParam('Y')), ConvertUnits(line.GetParam('Z'))); } unique_ptr<PathPart> part(new PathPartRapid(currentPosition, end, rapidFeed/60.0, workingPlane, GetPathOffsets(), line.line)); AddPathSegment(part); currentPosition = end; }
void GCodeInterpreter::CircleFunction(GCodeLine& line, PathPartType type) { unique_ptr<PathPart> part; Point end; if(coordType == ABS) { //Absolute coordinates end = Point( ConvertUnits(line.GetParam('X')), ConvertUnits(line.GetParam('Y')), ConvertUnits(line.GetParam('Z'))); } else { end = currentPosition + Point( ConvertUnits(line.GetParam('X')), ConvertUnits(line.GetParam('Y')), ConvertUnits(line.GetParam('Z'))); } if(line.ParamExists('R')) { part = unique_ptr<PathPart>(new PathPartCircle(currentPosition, end, ConvertUnits(line.GetParam('R')), workingPlane, standardFeed/60, type, GetPathOffsets(), line.line)); } else { Point center; if(arcCoordType == INC) { center = currentPosition + Point( ConvertUnits(line.GetParam('I')), ConvertUnits(line.GetParam('J')), ConvertUnits(line.GetParam('K'))); } else { center = Point( ConvertUnits(line.GetParam('I')), ConvertUnits(line.GetParam('J')), ConvertUnits(line.GetParam('K'))); } part = unique_ptr<PathPart>(new PathPartCircle(currentPosition, end, center, standardFeed/60, type, GetPathOffsets(), line.line)); } currentPosition = end; AddPathSegment(part); }