Fixes
This commit is contained in:
parent
0773e0f018
commit
12807410f2
3292
cobertura.xml
3292
cobertura.xml
File diff suppressed because it is too large
Load Diff
@ -154,6 +154,11 @@ class Calc
|
|||||||
$edge->getCalcValue(),
|
$edge->getCalcValue(),
|
||||||
$orgCv . ' = ' . $cv,
|
$orgCv . ' = ' . $cv,
|
||||||
);
|
);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $option->getId() . '_' . $collection->getName(),
|
||||||
|
unParsed: $edge->getCalcValue(),
|
||||||
|
));
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,8 @@ use PSC\Library\Calc\Engine;
|
|||||||
use PSC\Library\Calc\General\Type\Edge;
|
use PSC\Library\Calc\General\Type\Edge;
|
||||||
use PSC\Library\Calc\General\Type\EdgeCollection;
|
use PSC\Library\Calc\General\Type\EdgeCollection;
|
||||||
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
use PSC\Library\Calc\General\Type\EdgeCollectionContainer;
|
||||||
|
use PSC\Library\Calc\Model\Part;
|
||||||
|
use PSC\Library\Calc\Model\PartType;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
use PSC\Library\Calc\Option\Type\Checkbox;
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
||||||
@ -56,16 +58,19 @@ class CalcValues
|
|||||||
private function calcRec($options, $price = 0): float
|
private function calcRec($options, $price = 0): float
|
||||||
{
|
{
|
||||||
foreach ($options as $option) {
|
foreach ($options as $option) {
|
||||||
|
|
||||||
if ($option instanceof Row) {
|
if ($option instanceof Row) {
|
||||||
foreach($option->getColumns() as $col) {
|
foreach ($option->getColumns() as $col) {
|
||||||
$price = $this->calcRec($col->getOptions(), $price);
|
$price = $this->calcRec($col->getOptions(), $price);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($option instanceof Select || $option instanceof Checkbox) {
|
if ($option instanceof Select || $option instanceof Checkbox) {
|
||||||
foreach($option->getSelectedOptions() as $opt) {
|
foreach ($option->getSelectedOptions() as $opt) {
|
||||||
if ($opt->isValid()) {
|
if ($opt->isValid()) {
|
||||||
$price = $this->parseEdgeCollection($price, $option->getId(), $opt->getEdgesCollectionContainer());
|
$price = $this->parseEdgeCollection(
|
||||||
|
$price,
|
||||||
|
$option->getId(),
|
||||||
|
$opt->getEdgesCollectionContainer(),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -74,22 +79,19 @@ class CalcValues
|
|||||||
}
|
}
|
||||||
|
|
||||||
return $price;
|
return $price;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseEdgeCollection($price, $id, EdgeCollectionContainer $container, $isSub = false)
|
private function parseEdgeCollection($price, $id, EdgeCollectionContainer $container, $isSub = false)
|
||||||
{
|
{
|
||||||
|
|
||||||
$calcValue1 = 0;
|
$calcValue1 = 0;
|
||||||
$calcValue2 = 0;
|
$calcValue2 = 0;
|
||||||
$calcValueAccount1 = 0;
|
$calcValueAccount1 = 0;
|
||||||
$calcValueAccount2 = 0;
|
$calcValueAccount2 = 0;
|
||||||
|
|
||||||
try{
|
try {
|
||||||
@eval($this->engine->getParameters());
|
eval($this->engine->getParameters());
|
||||||
@eval($this->engine->getFormulas());
|
eval($this->engine->getFormulas());
|
||||||
}catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var EdgeCollection $collection */
|
/** @var EdgeCollection $collection */
|
||||||
@ -98,10 +100,11 @@ class CalcValues
|
|||||||
$hasVar = true;
|
$hasVar = true;
|
||||||
$hasValidEdge = false;
|
$hasValidEdge = false;
|
||||||
|
|
||||||
if ($collection->getName() == "opt") continue;
|
if ($collection->getName() == 'opt')
|
||||||
if ($collection->getFormel() != "") {
|
continue;
|
||||||
|
if ($collection->getFormel() != '') {
|
||||||
$formel = $this->formelCalc->parse($collection->getFormel());
|
$formel = $this->formelCalc->parse($collection->getFormel());
|
||||||
if (preg_match("/^[a-z](.*)/", $formel)) {
|
if (preg_match('/^[a-z](.*)/', $formel)) {
|
||||||
eval('$var = "' . $formel . '";');
|
eval('$var = "' . $formel . '";');
|
||||||
} else {
|
} else {
|
||||||
eval('$var = ' . $formel . ';');
|
eval('$var = ' . $formel . ';');
|
||||||
@ -111,7 +114,7 @@ class CalcValues
|
|||||||
$var = $this->engine->getVariables()[$collection->getName()];
|
$var = $this->engine->getVariables()[$collection->getName()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if($collection->getDefault() != "" && $var === "XXXXXXXXXXXX") {
|
if ($collection->getDefault() != '' && $var === 'XXXXXXXXXXXX') {
|
||||||
$var = $collection->getDefault();
|
$var = $collection->getDefault();
|
||||||
$hasVar = false;
|
$hasVar = false;
|
||||||
}
|
}
|
||||||
@ -122,22 +125,20 @@ class CalcValues
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$hasValidEdge && $hasVar && $collection->getDefault()) {
|
if (!$hasValidEdge && $hasVar && $collection->getDefault()) {
|
||||||
$var = $collection->getDefault();
|
$var = $collection->getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var Edge $edge */
|
/** @var Edge $edge */
|
||||||
foreach ($collection as $edge) {
|
foreach ($collection as $edge) {
|
||||||
|
|
||||||
if ($var !== 'XXXXXXXX' && $edge->isValid($var)) {
|
if ($var !== 'XXXXXXXX' && $edge->isValid($var)) {
|
||||||
|
if ($edge->getCalcValue() != '') {
|
||||||
if ($edge->getCalcValue() != "") {
|
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue());
|
$cv = $this->formelCalc->parse($edge->getCalcValue());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
||||||
}catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$this->engine->addDebugCalcVariables($id, $edge->getCalcValue(), $orgCv . ' = ERROR');
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
@ -145,159 +146,299 @@ class CalcValues
|
|||||||
$this->engine->addCalcVariable($id, $cv);
|
$this->engine->addCalcVariable($id, $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName(), $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName(), $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName(),
|
||||||
|
unParsed: $edge->getCalcValue(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue1() != "") {
|
if ($edge->getCalcValue1() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue1());
|
$cv = $this->formelCalc->parse($edge->getCalcValue1());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_1', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_1',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_1', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_1',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_1', $cv);
|
$this->engine->addCalcVariable($id . '_1', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_1', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_1', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_1',
|
||||||
|
unParsed: $edge->getCalcValue1(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue2() != "") {
|
if ($edge->getCalcValue2() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue2());
|
$cv = $this->formelCalc->parse($edge->getCalcValue2());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_2', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_2',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_2', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_2',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_2', $cv);
|
$this->engine->addCalcVariable($id . '_2', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_2', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_2', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_2',
|
||||||
|
unParsed: $edge->getCalcValue2(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue3() != "") {
|
if ($edge->getCalcValue3() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue3());
|
$cv = $this->formelCalc->parse($edge->getCalcValue3());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_3', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_3',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_3', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_3',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_3', $cv);
|
$this->engine->addCalcVariable($id . '_3', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_3', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_3', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_3',
|
||||||
|
unParsed: $edge->getCalcValue3(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue4() != "") {
|
if ($edge->getCalcValue4() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue4());
|
$cv = $this->formelCalc->parse($edge->getCalcValue4());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_4', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_4',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_4', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_4',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_4', $cv);
|
$this->engine->addCalcVariable($id . '_4', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_4', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_4', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_4',
|
||||||
|
unParsed: $edge->getCalcValue4(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue5() != "") {
|
if ($edge->getCalcValue5() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue5());
|
$cv = $this->formelCalc->parse($edge->getCalcValue5());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_5', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_5',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_5', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_5',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_5', $cv);
|
$this->engine->addCalcVariable($id . '_5', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_5', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_5', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_5',
|
||||||
|
unParsed: $edge->getCalcValue5(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue6() != "") {
|
if ($edge->getCalcValue6() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue6());
|
$cv = $this->formelCalc->parse($edge->getCalcValue6());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_6', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_6',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_6', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_6',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_6', $cv);
|
$this->engine->addCalcVariable($id . '_6', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_6', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_6', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_6',
|
||||||
|
unParsed: $edge->getCalcValue6(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue7() != "") {
|
if ($edge->getCalcValue7() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue7());
|
$cv = $this->formelCalc->parse($edge->getCalcValue7());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_7', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_7',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_7', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_7',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_7', $cv);
|
$this->engine->addCalcVariable($id . '_7', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_7', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_7', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_7',
|
||||||
|
unParsed: $edge->getCalcValue7(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue8() != "") {
|
if ($edge->getCalcValue8() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue8());
|
$cv = $this->formelCalc->parse($edge->getCalcValue8());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_8', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_8',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_8', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_8',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_8', $cv);
|
$this->engine->addCalcVariable($id . '_8', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_8', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_8', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_8',
|
||||||
|
unParsed: $edge->getCalcValue8(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue9() != "") {
|
if ($edge->getCalcValue9() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue9());
|
$cv = $this->formelCalc->parse($edge->getCalcValue9());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_9', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_9',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_9', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_9',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_9', $cv);
|
$this->engine->addCalcVariable($id . '_9', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_9', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_9', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_9',
|
||||||
|
unParsed: $edge->getCalcValue9(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getCalcValue10() != "") {
|
if ($edge->getCalcValue10() != '') {
|
||||||
$cv = $this->formelCalc->parse($edge->getCalcValue10());
|
$cv = $this->formelCalc->parse($edge->getCalcValue10());
|
||||||
$orgCv = $cv;
|
$orgCv = $cv;
|
||||||
try {
|
try {
|
||||||
eval('@$cv = ' . $cv . ';');
|
eval('@$cv = ' . $cv . ';');
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_10', $edge->getCalcValue(), $orgCv . ' = ' . $cv);
|
$this->engine->addDebugCalcVariables(
|
||||||
}catch (\Throwable $e) {
|
$id . '_' . $collection->getName() . '_10',
|
||||||
$this->engine->addDebugCalcVariables($id . '_' . $collection->getName() . '_10', $edge->getCalcValue(), $orgCv . ' = ERROR');
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ' . $cv,
|
||||||
|
);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$this->engine->addDebugCalcVariables(
|
||||||
|
$id . '_' . $collection->getName() . '_10',
|
||||||
|
$edge->getCalcValue(),
|
||||||
|
$orgCv . ' = ERROR',
|
||||||
|
);
|
||||||
$cv = 0;
|
$cv = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_10', $cv);
|
$this->engine->addCalcVariable($id . '_10', $cv);
|
||||||
|
|
||||||
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_10', $cv);
|
$this->engine->addCalcVariable($id . '_' . $collection->getName() . '_10', $cv);
|
||||||
|
$this->engine->getCalcGraph()->addPart(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $id . '_' . $collection->getName() . '_10',
|
||||||
|
unParsed: $edge->getCalcValue10(),
|
||||||
|
));
|
||||||
}
|
}
|
||||||
if ($edge->getEdgesCollectionContainer()->count() > 0) {
|
if ($edge->getEdgesCollectionContainer()->count() > 0) {
|
||||||
$this->parseEdgeCollection($price, $id . '_' . $collection->getName(), $edge->getEdgesCollectionContainer(), true);
|
$this->parseEdgeCollection(
|
||||||
|
$price,
|
||||||
|
$id . '_' . $collection->getName(),
|
||||||
|
$edge->getEdgesCollectionContainer(),
|
||||||
|
true,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,6 +7,8 @@ use PSC\Library\Calc\Calc\Calc;
|
|||||||
use PSC\Library\Calc\Calc\CalcValues;
|
use PSC\Library\Calc\Calc\CalcValues;
|
||||||
use PSC\Library\Calc\Calc\Valid;
|
use PSC\Library\Calc\Calc\Valid;
|
||||||
use PSC\Library\Calc\Graph\Graph;
|
use PSC\Library\Calc\Graph\Graph;
|
||||||
|
use PSC\Library\Calc\Model\Part;
|
||||||
|
use PSC\Library\Calc\Model\PartType;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
use PSC\Library\Calc\Option\Type\Checkbox;
|
use PSC\Library\Calc\Option\Type\Checkbox;
|
||||||
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
use PSC\Library\Calc\Option\Type\PaperDbSelect;
|
||||||
@ -112,7 +114,7 @@ class Engine
|
|||||||
*/
|
*/
|
||||||
protected function parse()
|
protected function parse()
|
||||||
{
|
{
|
||||||
$this->calcGraph = new Graph();
|
$this->calcGraph = new Graph((string) $this->formulas, (string) $this->parameters);
|
||||||
$parser = new Parser();
|
$parser = new Parser();
|
||||||
$parser->setPaperContainer($this->paperContainer);
|
$parser->setPaperContainer($this->paperContainer);
|
||||||
$parser->setPaperRepository($this->paperRepository);
|
$parser->setPaperRepository($this->paperRepository);
|
||||||
@ -254,7 +256,7 @@ class Engine
|
|||||||
|
|
||||||
public function calc()
|
public function calc()
|
||||||
{
|
{
|
||||||
$this->calcGraph = new Graph();
|
$this->calcGraph = new Graph($this->formulas, $this->parameters);
|
||||||
$this->debugCalcFormel = [];
|
$this->debugCalcFormel = [];
|
||||||
$this->debugCalcVariables = [];
|
$this->debugCalcVariables = [];
|
||||||
$this->debugFlatPrice = [];
|
$this->debugFlatPrice = [];
|
||||||
@ -306,6 +308,22 @@ class Engine
|
|||||||
$this->processCalc();
|
$this->processCalc();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($this->variables as $key => $variable) {
|
||||||
|
if (is_array($variable)) {
|
||||||
|
$this->calcGraph->addPart(new Part(
|
||||||
|
type: PartType::Value,
|
||||||
|
name: $key,
|
||||||
|
unParsed: implode(',', $variable),
|
||||||
|
));
|
||||||
|
} elseif ($variable != null) {
|
||||||
|
$this->calcGraph->addPart(new Part(
|
||||||
|
type: PartType::Value,
|
||||||
|
name: $key,
|
||||||
|
unParsed: $variable,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$this->dirty = false;
|
$this->dirty = false;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -14,6 +14,7 @@ class Calc
|
|||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
$this->math = new Math();
|
$this->math = new Math();
|
||||||
|
$this->math->suppress_errors = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function calc(Part $part): void
|
public function calc(Part $part): void
|
||||||
@ -23,21 +24,28 @@ class Calc
|
|||||||
$yield = $part->accept($visitor);
|
$yield = $part->accept($visitor);
|
||||||
|
|
||||||
foreach ($yield as $y) {
|
foreach ($yield as $y) {
|
||||||
$this->parseFormulas($y);
|
$this->parsePart($y);
|
||||||
$this->parseParams($y);
|
|
||||||
$y->setResult($this->math->evaluate($y->getParsed()));
|
$y->setResult($this->math->evaluate($y->getParsed()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function parsePart(Part $part): void
|
||||||
|
{
|
||||||
|
$this->parseCalcValue($part);
|
||||||
|
$this->parseFormulas($part);
|
||||||
|
$this->parseParams($part);
|
||||||
|
$this->parseValue($part);
|
||||||
|
}
|
||||||
|
|
||||||
private function parseFormulas(Part $p): void
|
private function parseFormulas(Part $p): void
|
||||||
{
|
{
|
||||||
preg_match_all('/\$F\w*\$F/', $p->getUnparsed(), $founds);
|
preg_match_all('/\$F\w*\$F/', $p->getUnparsed(), $founds);
|
||||||
|
|
||||||
if (!empty($founds[0])) {
|
if (!empty($founds[0])) {
|
||||||
foreach ($founds[0] as $key => $found) {
|
foreach ($founds[0] as $key => $found) {
|
||||||
$foundValue = str_replace('$F', '', $found);
|
$foundPart = $p->getChildrenByName($found);
|
||||||
$foundPart = array_find($p->getChildren(), fn($c) => $c->getName() == $foundValue);
|
|
||||||
if ($foundPart) {
|
if ($foundPart) {
|
||||||
|
$this->parsePart($foundPart);
|
||||||
$p->setParsed(str_replace($found, $foundPart->getResult(), $p->getParsed()));
|
$p->setParsed(str_replace($found, $foundPart->getResult(), $p->getParsed()));
|
||||||
} else {
|
} else {
|
||||||
$p->setParsed(str_replace($found, 0, $p->getParsed()));
|
$p->setParsed(str_replace($found, 0, $p->getParsed()));
|
||||||
@ -52,9 +60,43 @@ class Calc
|
|||||||
|
|
||||||
if (!empty($founds[0])) {
|
if (!empty($founds[0])) {
|
||||||
foreach ($founds[0] as $key => $found) {
|
foreach ($founds[0] as $key => $found) {
|
||||||
$foundValue = str_replace('$P', '', $found);
|
$foundPart = $p->getChildrenByName($found);
|
||||||
$foundPart = array_find($p->getChildren(), fn($c) => $c->getName() == $foundValue);
|
|
||||||
if ($foundPart) {
|
if ($foundPart) {
|
||||||
|
$this->parsePart($foundPart);
|
||||||
|
$p->setParsed(str_replace($found, $foundPart->getResult(), $p->getParsed()));
|
||||||
|
} else {
|
||||||
|
$p->setParsed(str_replace($found, 0, $p->getParsed()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseCalcValue(Part $p): void
|
||||||
|
{
|
||||||
|
preg_match_all('/\$CV\w*\$CV/', $p->getUnparsed(), $founds);
|
||||||
|
|
||||||
|
if (!empty($founds[0])) {
|
||||||
|
foreach ($founds[0] as $key => $found) {
|
||||||
|
$foundPart = $p->getChildrenByName($found);
|
||||||
|
if ($foundPart) {
|
||||||
|
$this->parsePart($foundPart);
|
||||||
|
$p->setParsed(str_replace($found, $foundPart->getResult(), $p->getParsed()));
|
||||||
|
} else {
|
||||||
|
$p->setParsed(str_replace($found, 0, $p->getParsed()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseValue(Part $p): void
|
||||||
|
{
|
||||||
|
preg_match_all('/\$V\w*\$V/', $p->getUnparsed(), $founds);
|
||||||
|
|
||||||
|
if (!empty($founds[0])) {
|
||||||
|
foreach ($founds[0] as $key => $found) {
|
||||||
|
$foundPart = $p->getChildrenByName($found);
|
||||||
|
if ($foundPart) {
|
||||||
|
$this->parsePart($foundPart);
|
||||||
$p->setParsed(str_replace($found, $foundPart->getResult(), $p->getParsed()));
|
$p->setParsed(str_replace($found, $foundPart->getResult(), $p->getParsed()));
|
||||||
} else {
|
} else {
|
||||||
$p->setParsed(str_replace($found, 0, $p->getParsed()));
|
$p->setParsed(str_replace($found, 0, $p->getParsed()));
|
||||||
|
|||||||
@ -29,7 +29,12 @@ class Graph
|
|||||||
$this->calcFormel->append($formel);
|
$this->calcFormel->append($formel);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function build(): bool
|
public function addPart(Part $part): void
|
||||||
|
{
|
||||||
|
$this->parser->addPart($part);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function build(): bool
|
||||||
{
|
{
|
||||||
foreach ($this->calcFormel as $formel) {
|
foreach ($this->calcFormel as $formel) {
|
||||||
$this->parser->parse($formel);
|
$this->parser->parse($formel);
|
||||||
@ -47,29 +52,45 @@ class Graph
|
|||||||
return array_reduce((array) $this->calcFormel, fn($sum, $item) => $sum + $item->getResult(), 0);
|
return array_reduce((array) $this->calcFormel, fn($sum, $item) => $sum + $item->getResult(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function generateJsonGraph(): string
|
||||||
|
{
|
||||||
|
$this->build();
|
||||||
|
$json = [];
|
||||||
|
foreach ($this->calcFormel as $part) {
|
||||||
|
$json[] = $part->toArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
return json_encode($json);
|
||||||
|
}
|
||||||
|
|
||||||
public function generateSVGGraph(): string
|
public function generateSVGGraph(): string
|
||||||
{
|
{
|
||||||
$image = new SVG(1000, 1000);
|
$image = new SVG(1000, 1000);
|
||||||
$doc = $image->getDocument();
|
$doc = $image->getDocument();
|
||||||
|
$doc->setStyle('background-color', '#ffffff');
|
||||||
$x = 0;
|
$bg = new SVGRect(0, 0, 1000, 1000);
|
||||||
|
$bg->setAttribute('fill', '#ffffff');
|
||||||
|
$doc->addChild($bg);
|
||||||
|
$x = 20;
|
||||||
$y = 0;
|
$y = 0;
|
||||||
|
|
||||||
foreach ($this->calcFormel as $formel) {
|
foreach ($this->calcFormel as $formel) {
|
||||||
$this->renderSubPart($x, $y, $doc, $formel);
|
$y = $this->renderSubPart($x, $y, $doc, $formel);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $image->toXMLString();
|
return $image->toXMLString();
|
||||||
}
|
}
|
||||||
|
|
||||||
private function renderSubPart(int $x, int $y, SVGDocumentFragment $doc, Part $part): array
|
private function renderSubPart(int $x, int $y, SVGDocumentFragment $doc, Part $part): int
|
||||||
{
|
{
|
||||||
$x = $x + 20;
|
|
||||||
$y = $y + 20;
|
$y = $y + 20;
|
||||||
if (count($part->getChildren()) > 0) {
|
if (count($part->getChildren()) > 0) {
|
||||||
$textC = new SVGText('', $x, $y);
|
$textC = new SVGText('', $x, $y);
|
||||||
|
$span1 = new SVGTSpan();
|
||||||
|
$span1->setValue(sprintf('%s', $part->getName()));
|
||||||
|
$textC->addChild($span1);
|
||||||
|
|
||||||
$pattern = '/(\$[FP][a-zA-Z0-9]+\$[FP])/';
|
$pattern = '/(\$[FPV][a-zA-Z0-9]+\$[FPV])/';
|
||||||
|
|
||||||
$parts = preg_split($pattern, $part->getUnparsed(), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
$parts = preg_split($pattern, $part->getUnparsed(), -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
|
||||||
|
|
||||||
@ -78,12 +99,15 @@ class Graph
|
|||||||
if ($child) {
|
if ($child) {
|
||||||
$span1 = new SVGTSpan();
|
$span1 = new SVGTSpan();
|
||||||
$span1->setValue(sprintf('%s (%s)', $subPart, $child->getResult()));
|
$span1->setValue(sprintf('%s (%s)', $subPart, $child->getResult()));
|
||||||
|
$span1->setAttribute('dx', 10);
|
||||||
$span1->setAttribute('fill', $child->getColor());
|
$span1->setAttribute('fill', $child->getColor());
|
||||||
$textC->addChild($span1);
|
$textC->addChild($span1);
|
||||||
list($x, $y) = $this->renderSubPart($x, $y, $doc, $child);
|
$x = $x + 20;
|
||||||
|
$y = $this->renderSubPart($x, $y, $doc, $child);
|
||||||
} else {
|
} else {
|
||||||
$span1 = new SVGTSpan();
|
$span1 = new SVGTSpan();
|
||||||
$span1->setValue($subPart);
|
$span1->setValue($subPart);
|
||||||
|
$span1->setAttribute('dx', 10);
|
||||||
$textC->addChild($span1);
|
$textC->addChild($span1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -91,9 +115,10 @@ class Graph
|
|||||||
$textC = new SVGText('', $x, $y);
|
$textC = new SVGText('', $x, $y);
|
||||||
$span1 = new SVGTSpan();
|
$span1 = new SVGTSpan();
|
||||||
$span1->setValue($part->getUnparsed());
|
$span1->setValue($part->getUnparsed());
|
||||||
|
$span1->setAttribute('dx', 10);
|
||||||
$textC->addChild($span1);
|
$textC->addChild($span1);
|
||||||
}
|
}
|
||||||
$doc->addChild($textC);
|
$doc->addChild($textC);
|
||||||
return [$x, $y];
|
return $y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,34 +21,49 @@ class Parser
|
|||||||
private string $params = '',
|
private string $params = '',
|
||||||
) {
|
) {
|
||||||
$this->internalParts = new PartCollection();
|
$this->internalParts = new PartCollection();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function parseInternals(): void
|
||||||
|
{
|
||||||
$mode = 1;
|
$mode = 1;
|
||||||
|
|
||||||
$traverser = new NodeTraverser();
|
$traverser = new NodeTraverser();
|
||||||
$traverser->addVisitor(new class($mode, $this->internalParts) extends NodeVisitorAbstract {
|
|
||||||
|
$visitor = new class($mode, $this->internalParts) extends NodeVisitorAbstract {
|
||||||
public function __construct(
|
public function __construct(
|
||||||
private int $mode,
|
private int $mode,
|
||||||
private PartCollection $internalParts,
|
private PartCollection $internalParts,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
public function setMode(int $mode): void
|
||||||
|
{
|
||||||
|
$this->mode = $mode;
|
||||||
|
}
|
||||||
|
|
||||||
public function enterNode(Node $node): void
|
public function enterNode(Node $node): void
|
||||||
{
|
{
|
||||||
if ($node instanceof Assign && $this->mode === 1) {
|
if ($node instanceof Assign && $this->mode === 1) {
|
||||||
$this->internalParts->append(new Part(
|
if ($node->expr->value != null && $node->var->name != null) {
|
||||||
type: PartType::Formel,
|
$this->internalParts->append(new Part(
|
||||||
name: $node->var->name,
|
type: PartType::Formel,
|
||||||
unParsed: $node->expr->value,
|
name: $node->var->name,
|
||||||
));
|
unParsed: (string) $node->expr->value,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if ($node instanceof Assign && $this->mode === 2) {
|
if ($node instanceof Assign && $this->mode === 2) {
|
||||||
$this->internalParts->append(new Part(
|
if ($node->expr->value != null && $node->var->name != null) {
|
||||||
type: PartType::Parameter,
|
$this->internalParts->append(new Part(
|
||||||
name: $node->var->name,
|
type: PartType::Parameter,
|
||||||
unParsed: $node->expr->value,
|
name: $node->var->name,
|
||||||
));
|
unParsed: (string) $node->expr->value,
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
};
|
||||||
|
|
||||||
|
$traverser->addVisitor($visitor);
|
||||||
|
|
||||||
$parser = new ParserFactory()->createForNewestSupportedVersion();
|
$parser = new ParserFactory()->createForNewestSupportedVersion();
|
||||||
try {
|
try {
|
||||||
@ -59,6 +74,8 @@ class Parser
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$visitor->setMode(2);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$ast = $parser->parse('<?php' . PHP_EOL . $params);
|
$ast = $parser->parse('<?php' . PHP_EOL . $params);
|
||||||
$traverser->traverse($ast);
|
$traverser->traverse($ast);
|
||||||
@ -70,26 +87,25 @@ class Parser
|
|||||||
|
|
||||||
public function parse(Part $formel): void
|
public function parse(Part $formel): void
|
||||||
{
|
{
|
||||||
// $formel = $this->parseCalcVariables($formel, $breakValid);
|
$this->parseCalcValue($formel);
|
||||||
$this->parseFormulas($formel);
|
$this->parseFormulas($formel);
|
||||||
$this->parseParams($formel);
|
$this->parseParams($formel);
|
||||||
|
$this->parseValue($formel);
|
||||||
// $formel = $this->parseVariables($formel, $breakValid);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseFormulas(Part $formel): void
|
private function parseFormulas(Part $part): void
|
||||||
{
|
{
|
||||||
preg_match_all('/\$F\w*\$F/', $formel->getUnparsed(), $founds);
|
preg_match_all('/\$F\w*\$F/', $part->getUnparsed(), $founds);
|
||||||
|
|
||||||
if (!empty($founds[0])) {
|
if (!empty($founds[0])) {
|
||||||
foreach ($founds[0] as $key => $found) {
|
foreach ($founds[0] as $key => $found) {
|
||||||
$foundValue = str_replace('$F', '', $found);
|
$foundValue = str_replace('$F', '', $found);
|
||||||
if ($this->internalParts->getPartByName($foundValue)) {
|
if ($this->internalParts->getPartByName($found)) {
|
||||||
$part = $this->internalParts->getPartByName($foundValue);
|
$p = $this->internalParts->getPartByName($found);
|
||||||
$this->parse($part);
|
$this->parse($p);
|
||||||
$formel->addChild($part);
|
$part->addChild($p);
|
||||||
} else {
|
} else {
|
||||||
$formel->addChild(new Part(
|
$part->addChild(new Part(
|
||||||
type: PartType::Formel,
|
type: PartType::Formel,
|
||||||
name: $foundValue,
|
name: $foundValue,
|
||||||
unParsed: $found,
|
unParsed: $found,
|
||||||
@ -101,18 +117,68 @@ class Parser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function parseParams(Part $formel): void
|
private function parseCalcValue(Part $part): void
|
||||||
{
|
{
|
||||||
preg_match_all('/\$P\w*\$P/', $formel->getUnparsed(), $founds);
|
preg_match_all('/\$CV\w*\$CV/', $part->getUnparsed(), $founds);
|
||||||
|
|
||||||
|
if (!empty($founds[0])) {
|
||||||
|
foreach ($founds[0] as $key => $found) {
|
||||||
|
$foundValue = str_replace('$CV', '', $found);
|
||||||
|
if ($this->internalParts->getPartByName($found)) {
|
||||||
|
$p = $this->internalParts->getPartByName($found);
|
||||||
|
$this->parse($p);
|
||||||
|
$part->addChild($p);
|
||||||
|
} else {
|
||||||
|
$part->addChild(new Part(
|
||||||
|
type: PartType::CalcValue,
|
||||||
|
name: $foundValue,
|
||||||
|
unParsed: $found,
|
||||||
|
parsed: 0,
|
||||||
|
result: 0,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseValue(Part $part): void
|
||||||
|
{
|
||||||
|
preg_match_all('/\$V\w*\$V/', $part->getUnparsed(), $founds);
|
||||||
|
|
||||||
|
if (!empty($founds[0])) {
|
||||||
|
foreach ($founds[0] as $key => $found) {
|
||||||
|
$foundValue = str_replace('$V', '', $found);
|
||||||
|
if ($this->internalParts->getPartByName($found)) {
|
||||||
|
$p = $this->internalParts->getPartByName($found);
|
||||||
|
$this->parse($p);
|
||||||
|
$part->addChild($p);
|
||||||
|
} else {
|
||||||
|
$part->addChild(new Part(
|
||||||
|
type: PartType::Value,
|
||||||
|
name: $foundValue,
|
||||||
|
unParsed: $found,
|
||||||
|
parsed: 0,
|
||||||
|
result: 0,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private function parseParams(Part $part): void
|
||||||
|
{
|
||||||
|
preg_match_all('/\$P\w*\$P/', $part->getUnparsed(), $founds);
|
||||||
|
|
||||||
if (!empty($founds[0])) {
|
if (!empty($founds[0])) {
|
||||||
foreach ($founds[0] as $key => $found) {
|
foreach ($founds[0] as $key => $found) {
|
||||||
$foundValue = str_replace('$P', '', $found);
|
$foundValue = str_replace('$P', '', $found);
|
||||||
if ($this->internalParts->getPartByName($foundValue)) {
|
if ($this->internalParts->getPartByName($found)) {
|
||||||
$formel->addChild($this->internalParts->getPartByName($foundValue));
|
$p = $this->internalParts->getPartByName($found);
|
||||||
|
$this->parse($p);
|
||||||
|
$part->addChild($p);
|
||||||
} else {
|
} else {
|
||||||
$formel->addChild(new Part(
|
$part->addChild(new Part(
|
||||||
type: PartType::Formel,
|
type: PartType::Parameter,
|
||||||
name: $foundValue,
|
name: $foundValue,
|
||||||
unParsed: $found,
|
unParsed: $found,
|
||||||
parsed: 0,
|
parsed: 0,
|
||||||
@ -122,4 +188,9 @@ class Parser
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addPart(Part $part): void
|
||||||
|
{
|
||||||
|
$this->internalParts->addPart($part);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -48,6 +48,10 @@ trait NodeTrait
|
|||||||
|
|
||||||
public function addChild(NodeInterface $child): static
|
public function addChild(NodeInterface $child): static
|
||||||
{
|
{
|
||||||
|
if ($item = array_find($this->children, fn($item) => $child->getName() == $item->getName())) {
|
||||||
|
$this->removeChild($item);
|
||||||
|
}
|
||||||
|
|
||||||
$child->setParent($this);
|
$child->setParent($this);
|
||||||
$this->children[] = $child;
|
$this->children[] = $child;
|
||||||
|
|
||||||
|
|||||||
@ -14,7 +14,7 @@ class Part extends Node
|
|||||||
private string $name,
|
private string $name,
|
||||||
private string $unParsed,
|
private string $unParsed,
|
||||||
private string $parsed = '',
|
private string $parsed = '',
|
||||||
private int $result = 0,
|
private float $result = 0,
|
||||||
) {
|
) {
|
||||||
if ($parsed == '') {
|
if ($parsed == '') {
|
||||||
$this->parsed = $unParsed;
|
$this->parsed = $unParsed;
|
||||||
@ -23,6 +23,11 @@ class Part extends Node
|
|||||||
$this->color = RandomColor::one();
|
$this->color = RandomColor::one();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getType(): PartType
|
||||||
|
{
|
||||||
|
return $this->type;
|
||||||
|
}
|
||||||
|
|
||||||
public function getColor(): string
|
public function getColor(): string
|
||||||
{
|
{
|
||||||
return $this->color;
|
return $this->color;
|
||||||
@ -33,6 +38,12 @@ class Part extends Node
|
|||||||
switch ($this->type) {
|
switch ($this->type) {
|
||||||
case PartType::Formel:
|
case PartType::Formel:
|
||||||
return sprintf('$F%s$F', $this->name);
|
return sprintf('$F%s$F', $this->name);
|
||||||
|
case PartType::Parameter:
|
||||||
|
return sprintf('$P%s$P', $this->name);
|
||||||
|
case PartType::Value:
|
||||||
|
return sprintf('$V%s$V', $this->name);
|
||||||
|
case PartType::CalcValue:
|
||||||
|
return sprintf('$CV%s$CV', $this->name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,13 +62,31 @@ class Part extends Node
|
|||||||
$this->parsed = $parsed;
|
$this->parsed = $parsed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function setResult(int $result): void
|
public function setResult(float $result): void
|
||||||
{
|
{
|
||||||
$this->result = $result;
|
$this->result = $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getResult(): string
|
public function getResult(): float
|
||||||
{
|
{
|
||||||
return $this->result;
|
return $this->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function toArray(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
'name' => $this->name,
|
||||||
|
'unParsed' => $this->unParsed,
|
||||||
|
'parsed' => $this->parsed,
|
||||||
|
'result' => $this->result,
|
||||||
|
'parts' => array_reduce(
|
||||||
|
$this->getChildren(),
|
||||||
|
function ($result, $item) {
|
||||||
|
$result[] = $item->toArray();
|
||||||
|
return $result;
|
||||||
|
},
|
||||||
|
[],
|
||||||
|
),
|
||||||
|
];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,8 +8,9 @@ class PartCollection extends \ArrayIterator
|
|||||||
{
|
{
|
||||||
public function getPartByName($string): Part|null
|
public function getPartByName($string): Part|null
|
||||||
{
|
{
|
||||||
|
$this->rewind();
|
||||||
while ($this->valid()) {
|
while ($this->valid()) {
|
||||||
if ($string == $this->current()->getName()) {
|
if ($string == $this->current()->getFullName()) {
|
||||||
return $this->current();
|
return $this->current();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,4 +19,23 @@ class PartCollection extends \ArrayIterator
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function addPart(Part $part): void
|
||||||
|
{
|
||||||
|
$foundKey = null;
|
||||||
|
while ($this->valid()) {
|
||||||
|
if ($part->getName() == $this->current()->getName() && $part->getType() == $this->current()->getType()) {
|
||||||
|
$foundKey = $this->key();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->next();
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($foundKey) {
|
||||||
|
$this->offsetSet($foundKey, $part);
|
||||||
|
} else {
|
||||||
|
$this->append($part);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,6 +5,7 @@ namespace PSC\Library\Calc\Model;
|
|||||||
enum PartType
|
enum PartType
|
||||||
{
|
{
|
||||||
case CalcValue;
|
case CalcValue;
|
||||||
|
case Value;
|
||||||
case CalcFormel;
|
case CalcFormel;
|
||||||
case Formel;
|
case Formel;
|
||||||
case Parameter;
|
case Parameter;
|
||||||
|
|||||||
49
tests/Customer/Z/GraphTest.php
Normal file
49
tests/Customer/Z/GraphTest.php
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace PSC\Library\Calc\Tests\Customer\Z;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use PSC\Library\Calc\Article;
|
||||||
|
use PSC\Library\Calc\Engine;
|
||||||
|
use PSC\Library\Calc\PaperContainer;
|
||||||
|
use PSC\Library\Calc\Tests\Mock\PaperRepostory;
|
||||||
|
|
||||||
|
class GraphTest extends TestCase
|
||||||
|
{
|
||||||
|
/** @var Engine */
|
||||||
|
protected $engine = null;
|
||||||
|
|
||||||
|
public function setUp(): void
|
||||||
|
{
|
||||||
|
$repository = new PaperRepostory();
|
||||||
|
|
||||||
|
$paperContainer = new PaperContainer();
|
||||||
|
$paperContainer->parse(simplexml_load_string(file_get_contents(__DIR__ . '/papierContainer.xml')));
|
||||||
|
|
||||||
|
$this->engine = new Engine();
|
||||||
|
$this->engine->setPaperContainer($paperContainer);
|
||||||
|
$this->engine->setPaperRepository($repository);
|
||||||
|
$this->engine->setFormulas(file_get_contents(__DIR__ . '/formels.txt'));
|
||||||
|
$this->engine->setParameters(file_get_contents(__DIR__ . '/parameters.txt'));
|
||||||
|
$this->engine->setTemplates(file_get_contents(__DIR__ . '/calcTemplates.xml'));
|
||||||
|
|
||||||
|
$this->engine->loadString(file_get_contents(__DIR__ . '/calc.xml'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tearDown(): void
|
||||||
|
{
|
||||||
|
$this->engine = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function tesPriceAndGraph(): void
|
||||||
|
{
|
||||||
|
$this->engine->calc();
|
||||||
|
$priceFromOldEngine = $this->engine->getPrice();
|
||||||
|
self::assertSame(131.86, $priceFromOldEngine);
|
||||||
|
file_put_contents(
|
||||||
|
filename: __DIR__ . '/test.json',
|
||||||
|
data: $this->engine->getCalcGraph()->generateJsonGraph(),
|
||||||
|
);
|
||||||
|
self::assertSame($priceFromOldEngine, $this->engine->getCalcGraph()->getSum());
|
||||||
|
}
|
||||||
|
}
|
||||||
1
tests/Customer/Z/test.json
Normal file
1
tests/Customer/Z/test.json
Normal file
File diff suppressed because one or more lines are too long
@ -1,10 +1,13 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
namespace PSC\Library\Calc\Tests\Graph\Simple;
|
||||||
|
|
||||||
use PHPUnit\Framework\TestCase;
|
use PHPUnit\Framework\TestCase;
|
||||||
use PSC\Library\Calc\Graph\Graph;
|
use PSC\Library\Calc\Graph\Graph;
|
||||||
use PSC\Library\Calc\Model\Part;
|
use PSC\Library\Calc\Model\Part;
|
||||||
use PSC\Library\Calc\Model\PartType;
|
use PSC\Library\Calc\Model\PartType;
|
||||||
|
|
||||||
|
use function PHPUnit\Framework\assertJsonStringEqualsJsonFile;
|
||||||
use function PHPUnit\Framework\assertSame;
|
use function PHPUnit\Framework\assertSame;
|
||||||
use function PHPUnit\Framework\assertTrue;
|
use function PHPUnit\Framework\assertTrue;
|
||||||
|
|
||||||
@ -24,14 +27,17 @@ class SimpleTest extends TestCase
|
|||||||
{
|
{
|
||||||
$this->graph->addCalcFormel(new Part(
|
$this->graph->addCalcFormel(new Part(
|
||||||
type: PartType::CalcFormel,
|
type: PartType::CalcFormel,
|
||||||
name: 'test1',
|
name: 'calcFormat',
|
||||||
unParsed: '$Ftest1$F+$Ftest2$F+10',
|
unParsed: '$Ftest1$F+$Ftest2$F+10',
|
||||||
));
|
));
|
||||||
|
|
||||||
assertTrue($this->graph->build());
|
$this->graph->addCalcFormel(new Part(
|
||||||
assertSame(5610, $this->graph->getSum());
|
type: PartType::CalcFormel,
|
||||||
|
name: 'calcAnzahlNutzen',
|
||||||
|
unParsed: '$Ftest5$F+$Ftest8$F',
|
||||||
|
));
|
||||||
|
|
||||||
// $xmlString = $this->graph->generateSVGGraph();
|
assertSame(6186, $this->graph->getSum());
|
||||||
// file_put_contents('my-image.svg', $xmlString);
|
assertJsonStringEqualsJsonFile(__DIR__ . '/test.json', $this->graph->generateJsonGraph());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
160
tests/Graph/Simple/calcTemplates.xml
Normal file
160
tests/Graph/Simple/calcTemplates.xml
Normal file
@ -0,0 +1,160 @@
|
|||||||
|
<root>
|
||||||
|
<option id="calc_farbigkeit_farbwechsel_inhalt_brosch_kba" name="calc_farbigkeit_farbwechsel_inhalt_brosch_kba" type="Hidden" default="1">
|
||||||
|
<druckfarben_inhalt>
|
||||||
|
<grenze calc_value="0">1,5</grenze>
|
||||||
|
<grenze calc_value="1">2,6</grenze>
|
||||||
|
<grenze calc_value="2">3,7</grenze>
|
||||||
|
<grenze calc_value="3">4,8</grenze>
|
||||||
|
</druckfarben_inhalt>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="calc_anzahl_druckplatten_inhalt_brosch_kba" name="calc_anzahl_druckplatten_inhalt_brosch_kba" type="Hidden" default="1">
|
||||||
|
<druckfarben_inhalt>
|
||||||
|
<grenze calc_value="1">1,2</grenze>
|
||||||
|
<grenze calc_value="2">3</grenze>
|
||||||
|
<grenze calc_value="3">4</grenze>
|
||||||
|
<grenze calc_value="4">5</grenze>
|
||||||
|
<grenze calc_value="5">6</grenze>
|
||||||
|
<grenze calc_value="6">7</grenze>
|
||||||
|
<grenze calc_value="7">8</grenze>
|
||||||
|
</druckfarben_inhalt>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
|
||||||
|
<option id="calc_farbigkeit_farbwechsel_umschlag_brosch_kba" name="calc_farbigkeit_farbwechsel_umschlag_brosch_kba" type="Hidden" default="1">
|
||||||
|
<druckfarben_umschlag>
|
||||||
|
<grenze calc_value="(0+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">1,5,6</grenze>
|
||||||
|
<grenze calc_value="(1+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">2,7</grenze>
|
||||||
|
<grenze calc_value="(2+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">3,8</grenze>
|
||||||
|
<grenze calc_value="(3+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">4,9</grenze>
|
||||||
|
</druckfarben_umschlag>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="calc_anzahl_druckplatten_umschlag_brosch_kba" name="calc_anzahl_druckplatten_umschlag_brosch_kba" type="Hidden" default="1">
|
||||||
|
<druckfarben_umschlag>
|
||||||
|
<grenze calc_value="(1+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">1,2</grenze>
|
||||||
|
<grenze calc_value="(2+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">3</grenze>
|
||||||
|
<grenze calc_value="(3+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">4</grenze>
|
||||||
|
<grenze calc_value="(4+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">5,6</grenze>
|
||||||
|
<grenze calc_value="(5+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">7</grenze>
|
||||||
|
<grenze calc_value="(6+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">8</grenze>
|
||||||
|
<grenze calc_value="(7+(($Vdruckplatte_option_umschlag$V == 3 || $Vdruckplatte_option_umschlag$V == 2 || $Vdruckplatte_option_umschlag$V == 5 || $Vdruckplatte_option_umschlag$V == 4)? 1:0))">9</grenze>
|
||||||
|
</druckfarben_umschlag>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="calc_anzahl_farben_plano_fa" name="calc_anzahl_farben_plano_fa" type="Hidden" default="1">
|
||||||
|
<druckfarben_inhalt>
|
||||||
|
<grenze calc_value="4">1</grenze>
|
||||||
|
<grenze calc_value="4">2</grenze>
|
||||||
|
<grenze calc_value="4">3</grenze>
|
||||||
|
<grenze calc_value="5">4</grenze>
|
||||||
|
<grenze calc_value="5">5</grenze>
|
||||||
|
<grenze calc_value="6">6</grenze>
|
||||||
|
<grenze calc_value="1">7</grenze>
|
||||||
|
<grenze calc_value="1">8</grenze>
|
||||||
|
<grenze calc_value="2">9</grenze>
|
||||||
|
<grenze calc_value="2">10</grenze>
|
||||||
|
<grenze calc_value="2">11</grenze>
|
||||||
|
<grenze calc_value="2">12</grenze>
|
||||||
|
<grenze calc_value="3">13</grenze>
|
||||||
|
<grenze calc_value="3">14</grenze>
|
||||||
|
<grenze calc_value="3">15</grenze>
|
||||||
|
<grenze calc_value="1">16</grenze>
|
||||||
|
<grenze calc_value="1">17</grenze>
|
||||||
|
<grenze calc_value="4">18</grenze>
|
||||||
|
<grenze calc_value="4">19</grenze>
|
||||||
|
<grenze calc_value="6">20</grenze>
|
||||||
|
<grenze calc_value="7">21</grenze>
|
||||||
|
<grenze calc_value="8">22</grenze>
|
||||||
|
<grenze calc_value="4">23</grenze>
|
||||||
|
</druckfarben_inhalt>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="calc_bedruckte_seiten_plano_fa" name="calc_bedruckte_seiten_plano_fa" type="Hidden" default="1">
|
||||||
|
<druckfarben_inhalt>
|
||||||
|
<grenze calc_value="1">1</grenze>
|
||||||
|
<grenze calc_value="2">2</grenze>
|
||||||
|
<grenze calc_value="2">3</grenze>
|
||||||
|
<grenze calc_value="1">4</grenze>
|
||||||
|
<grenze calc_value="2">5</grenze>
|
||||||
|
<grenze calc_value="2">6</grenze>
|
||||||
|
<grenze calc_value="1">7</grenze>
|
||||||
|
<grenze calc_value="2">8</grenze>
|
||||||
|
<grenze calc_value="1">9</grenze>
|
||||||
|
<grenze calc_value="1">10</grenze>
|
||||||
|
<grenze calc_value="2">11</grenze>
|
||||||
|
<grenze calc_value="2">12</grenze>
|
||||||
|
<grenze calc_value="1">13</grenze>
|
||||||
|
<grenze calc_value="2">14</grenze>
|
||||||
|
<grenze calc_value="2">15</grenze>
|
||||||
|
<grenze calc_value="1">16</grenze>
|
||||||
|
<grenze calc_value="2">17</grenze>
|
||||||
|
<grenze calc_value="1">18</grenze>
|
||||||
|
<grenze calc_value="2">19</grenze>
|
||||||
|
<grenze calc_value="1">20</grenze>
|
||||||
|
<grenze calc_value="1">21</grenze>
|
||||||
|
<grenze calc_value="1">22</grenze>
|
||||||
|
<grenze calc_value="1">23</grenze>
|
||||||
|
</druckfarben_inhalt>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
<option id="calc_anzahl_farbwechsel_plano_fa" name="calc_anzahl_farbwechsel_plano_fa" type="Hidden" default="1">
|
||||||
|
<auflage formel="$CVhilfsvalue_maschine_auflage$CV">
|
||||||
|
<grenze value="kba">
|
||||||
|
<druckfarben_inhalt>
|
||||||
|
<grenze calc_value="0">1</grenze>
|
||||||
|
<grenze calc_value="0">2</grenze>
|
||||||
|
<grenze calc_value="0">3</grenze>
|
||||||
|
<grenze calc_value="1">4</grenze>
|
||||||
|
<grenze calc_value="1">5</grenze>
|
||||||
|
<grenze calc_value="2">6</grenze>
|
||||||
|
<grenze calc_value="0">7</grenze>
|
||||||
|
<grenze calc_value="0">8</grenze>
|
||||||
|
<grenze calc_value="1">9</grenze>
|
||||||
|
<grenze calc_value="2">10</grenze>
|
||||||
|
<grenze calc_value="1">11</grenze>
|
||||||
|
<grenze calc_value="2">12</grenze>
|
||||||
|
<grenze calc_value="3">13</grenze>
|
||||||
|
<grenze calc_value="2">14</grenze>
|
||||||
|
<grenze calc_value="3">15</grenze>
|
||||||
|
<grenze calc_value="1">16</grenze>
|
||||||
|
<grenze calc_value="1">17</grenze>
|
||||||
|
<grenze calc_value="1">18</grenze>
|
||||||
|
<grenze calc_value="4">19</grenze>
|
||||||
|
<grenze calc_value="2">20</grenze>
|
||||||
|
<grenze calc_value="3">21</grenze>
|
||||||
|
<grenze calc_value="4">22</grenze>
|
||||||
|
<grenze calc_value="4">23</grenze>
|
||||||
|
</druckfarben_inhalt>
|
||||||
|
</grenze>
|
||||||
|
<grenze value="gto">
|
||||||
|
<druckfarben_inhalt>
|
||||||
|
<grenze calc_value="3">1</grenze>
|
||||||
|
<grenze calc_value="3">2</grenze>
|
||||||
|
<grenze calc_value="3">3</grenze>
|
||||||
|
<grenze calc_value="4">4</grenze>
|
||||||
|
<grenze calc_value="4">5</grenze>
|
||||||
|
<grenze calc_value="5">6</grenze>
|
||||||
|
<grenze calc_value="0">7</grenze>
|
||||||
|
<grenze calc_value="0">8</grenze>
|
||||||
|
<grenze calc_value="1">9</grenze>
|
||||||
|
<grenze calc_value="2">10</grenze>
|
||||||
|
<grenze calc_value="1">11</grenze>
|
||||||
|
<grenze calc_value="2">12</grenze>
|
||||||
|
<grenze calc_value="3">13</grenze>
|
||||||
|
<grenze calc_value="2">14</grenze>
|
||||||
|
<grenze calc_value="3">15</grenze>
|
||||||
|
<grenze calc_value="1">16</grenze>
|
||||||
|
<grenze calc_value="1">17</grenze>
|
||||||
|
<grenze calc_value="4">18</grenze>
|
||||||
|
<grenze calc_value="6">19</grenze>
|
||||||
|
<grenze calc_value="6">20</grenze>
|
||||||
|
<grenze calc_value="7">21</grenze>
|
||||||
|
<grenze calc_value="8">22</grenze>
|
||||||
|
<grenze calc_value="4">23</grenze>
|
||||||
|
</druckfarben_inhalt>
|
||||||
|
</grenze>
|
||||||
|
</auflage>
|
||||||
|
</option>
|
||||||
|
|
||||||
|
</root>
|
||||||
4
tests/Graph/Simple/formel.txt
Normal file
4
tests/Graph/Simple/formel.txt
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
$test1 = '100*50';
|
||||||
|
$test2 = '$Ptest3$P*50';
|
||||||
|
$test5 = '$Ftest2$F/2+$Ftest8$F';
|
||||||
|
$test8 = '$Ftest2$F*$Ptest5$P';
|
||||||
@ -1,2 +1,3 @@
|
|||||||
$test3 = 12;
|
$test3 = 12;
|
||||||
$test4 = 13;
|
$test4 = 13;
|
||||||
|
$test5 = 0.23;
|
||||||
1
tests/Graph/Simple/test.json
Normal file
1
tests/Graph/Simple/test.json
Normal file
@ -0,0 +1 @@
|
|||||||
|
[{"name":"calcFormat","unParsed":"$Ftest1$F+$Ftest2$F+10","parsed":"5000+600+10","result":5610,"parts":[{"name":"test1","unParsed":"100*50","parsed":"100*50","result":5000,"parts":[]},{"name":"test2","unParsed":"$Ptest3$P*50","parsed":"12*50","result":600,"parts":[{"name":"test3","unParsed":"12","parsed":"12","result":12,"parts":[]}]}]},{"name":"calcAnzahlNutzen","unParsed":"$Ftest5$F+$Ftest8$F","parsed":"438+138","result":576,"parts":[{"name":"test5","unParsed":"$Ftest2$F\/2+$Ftest8$F","parsed":"600\/2+138","result":438,"parts":[{"name":"test2","unParsed":"$Ptest3$P*50","parsed":"12*50","result":600,"parts":[{"name":"test3","unParsed":"12","parsed":"12","result":12,"parts":[]}]},{"name":"test8","unParsed":"$Ftest2$F*$Ptest5$P","parsed":"600*0.23","result":138,"parts":[{"name":"test2","unParsed":"$Ptest3$P*50","parsed":"12*50","result":600,"parts":[{"name":"test3","unParsed":"12","parsed":"12","result":12,"parts":[]}]},{"name":"test5","unParsed":"0.23","parsed":"0.23","result":0.23,"parts":[]}]}]},{"name":"test8","unParsed":"$Ftest2$F*$Ptest5$P","parsed":"600*0.23","result":138,"parts":[{"name":"test2","unParsed":"$Ptest3$P*50","parsed":"12*50","result":600,"parts":[{"name":"test3","unParsed":"12","parsed":"12","result":12,"parts":[]}]},{"name":"test5","unParsed":"0.23","parsed":"0.23","result":0.23,"parts":[]}]}]}]
|
||||||
@ -1,2 +0,0 @@
|
|||||||
$test1 = '100*50';
|
|
||||||
$test2 = '$Ptest3$P*50';
|
|
||||||
Loading…
Reference in New Issue
Block a user