void CMSaveSimulation::get_data_from_simulation() { outlen = 0; outtimesteps = 0; state = 0; CMString str; _precision = sim.GetOptionInt(L"precision"); _costPrecision = sim.GetOptionInt(L"costprecision"); _accum->GetPeriod(outbeg,outend,outincunits,outincsteps); _outtrials = sim.Trials(); trialbeg = 0; trialend = _outtrials - 1; outincunits = simincunits; outincsteps = 1; simtimesteps = 1+CMTime::Diff(outend,outbeg,simincunits,simincsteps); outtimesteps = 1+CMTime::Diff(outend,outbeg,outincunits,outincsteps); fieldwidth = outlen > 0 ? outlen : 9; switch (outincunits) { case CM_SECOND: timestepwidth=14; break; case CM_MINUTE: timestepwidth=12; break; case CM_HOUR: timestepwidth=10; break; case CM_DAY: timestepwidth=8; break; case CM_WEEK: timestepwidth=8; break; case CM_YEAR: timestepwidth=4; break; default: timestepwidth=6; break; } reldetailtargets = 0; reldetailindex = new unsigned[reliability->Targets()>0 ? reliability->Targets() : 1]; maxtargetlength=0; for (unsigned i = 0; i < reliability->Targets(); i++) { CMReliabilityTarget* target = reliability->Target(i); unsigned j = target->GetString().length(); maxtargetlength = cmmax(maxtargetlength, (int)j); for (j = 0; j < i; j++) if (target->SameCurveAs(*reliability->Target(j))) break; if (j == i) reldetailindex[reldetailtargets++] = i; } realization_records = (trialend-trialbeg+1) * outtimesteps; summary_records = simtimesteps * accumindex.Count(); relseries_records = reliability->Targets() * simtimesteps; reldetail_records = reldetailtargets * outtimesteps; str = sim.GetOption(L"outputsortby"); if (str.is_null() || str==L"trial") state |= rSortByTrial; }
void CMVariableOrConstant::Set(const CMString& str) { if (str.is_null()) type = Null; else { if (isnumber(str.c_str())) { type = Constant; u.c = _wtof(str.c_str()); } else { u.v = CMVariable::Find(str); type = (u.v==0) ? Null : Variable; } } }
void CMVSingleExpression::read_body(wistream& s) { CMString str; CMString expr; while(!s.eof()) { str.read_line(s); if (str.is_null() || str[0] == L'*') continue; if (str(0,wcslen(vardef_end)) == vardef_end) break; expr += str.strip(CMString::stripType::Trailing, L'\r'); } SetExpression(expr.c_str()); if (expression.Fail()) { SetState(vsFailed,1); ReportError(XBadVardef,expression.GetString()); } }