2022-07-06 17:51:51 +00:00
|
|
|
|
/*
|
|
|
|
|
* node_settings.c
|
|
|
|
|
*
|
|
|
|
|
* Created on: 6 июл. 2022 г.
|
|
|
|
|
* Author: alexander
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
2022-07-08 16:45:45 +00:00
|
|
|
|
#include <stdio.h>
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
|
|
|
|
#include "node_settings.h"
|
|
|
|
|
#include "concat.h"
|
2022-07-13 17:49:49 +00:00
|
|
|
|
#include "db.h"
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeHead settings =
|
|
|
|
|
{ NULL, 0 };
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static NodeValue* newNodeValue(Value name, char *current, bool set)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeValue *node = (NodeValue*) malloc(sizeof(NodeValue));
|
|
|
|
|
node->name = name;
|
|
|
|
|
node->set = set;
|
|
|
|
|
node->change = false;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
node->next = NULL;
|
2022-07-08 16:45:45 +00:00
|
|
|
|
|
|
|
|
|
node->current = (char*) malloc(sizeof(char) * strlen(current));
|
|
|
|
|
strcpy(node->current, current);
|
|
|
|
|
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static void freeNodeValue(NodeValue *node)
|
|
|
|
|
{
|
|
|
|
|
if (node)
|
|
|
|
|
{
|
|
|
|
|
free(node->current);
|
|
|
|
|
free(node);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void freeAllNodeValue(NodeValue *node)
|
|
|
|
|
{
|
|
|
|
|
NodeValue *next = NULL;
|
|
|
|
|
for (NodeValue *head = node; head; head = next)
|
|
|
|
|
{
|
|
|
|
|
next = head->next;
|
|
|
|
|
freeNodeValue(head);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-11 17:06:05 +00:00
|
|
|
|
static NodeParameter* newNodeParameter(Parameter name, char *key, bool set, bool singleValue, NodeParameter *dependence, NodeParameter *conflict)
|
2022-07-08 16:45:45 +00:00
|
|
|
|
{
|
|
|
|
|
NodeParameter *node = (NodeParameter*) malloc(sizeof(NodeParameter));
|
|
|
|
|
node->name = name;
|
|
|
|
|
node->set = set;
|
|
|
|
|
node->change = false;
|
|
|
|
|
node->value = NULL;
|
|
|
|
|
node->countValue = 0;
|
2022-07-11 17:06:05 +00:00
|
|
|
|
node->countValueSet = 0;
|
2022-07-08 16:45:45 +00:00
|
|
|
|
node->singleValue = singleValue;
|
2022-07-11 17:06:05 +00:00
|
|
|
|
node->dependence = dependence;
|
|
|
|
|
node->conflict = conflict;
|
2022-07-08 16:45:45 +00:00
|
|
|
|
node->next = NULL;
|
|
|
|
|
|
|
|
|
|
node->key = (char*) malloc(sizeof(char) * strlen(key));
|
|
|
|
|
strcpy(node->key, key);
|
|
|
|
|
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void freeNodeParameter(NodeParameter *node)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (node)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
freeAllNodeValue(node->value);
|
|
|
|
|
free(node->key);
|
|
|
|
|
free(node);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void freeAllNodeParameter(NodeParameter *node)
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *next = NULL;
|
|
|
|
|
for (NodeParameter *head = node; head; head = next)
|
|
|
|
|
{
|
|
|
|
|
next = head->next;
|
|
|
|
|
freeNodeParameter(head);
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
///////////////////////////////
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static NodeParameter* getLastNodeParameter()
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *head = settings.parameter;
|
|
|
|
|
|
|
|
|
|
if (head)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
|
|
|
|
while (head->next)
|
|
|
|
|
{
|
|
|
|
|
head = head->next;
|
|
|
|
|
}
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NodeParameter* getNodeParameter(Parameter name)
|
|
|
|
|
{
|
|
|
|
|
for (NodeParameter *head = settings.parameter; head; head = head->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->name == name)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-13 17:49:49 +00:00
|
|
|
|
NodeValue* getValue(Value name)
|
|
|
|
|
{
|
|
|
|
|
for (NodeParameter *pNode = settings.parameter; pNode; pNode = pNode->next)
|
|
|
|
|
{
|
|
|
|
|
for (NodeValue *vNode = pNode->value; vNode; vNode = vNode->next)
|
|
|
|
|
{
|
|
|
|
|
if (vNode->name == name)
|
|
|
|
|
{
|
|
|
|
|
return vNode;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-11 17:06:05 +00:00
|
|
|
|
NodeParameter* getParameter(Parameter name)
|
|
|
|
|
{
|
|
|
|
|
for (NodeParameter *head = settings.parameter; head; head = head->next)
|
|
|
|
|
{
|
|
|
|
|
if (head->name == name)
|
|
|
|
|
{
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void addParameterKey(Parameter name, char *key, bool set, bool singleValue, NodeParameter *dependence, NodeParameter *conflict)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (!settings.parameter)
|
|
|
|
|
{
|
2022-07-11 17:06:05 +00:00
|
|
|
|
settings.parameter = newNodeParameter(name, key, set, singleValue, dependence, conflict);
|
2022-07-08 16:45:45 +00:00
|
|
|
|
++settings.countParameter;
|
|
|
|
|
if (set)
|
|
|
|
|
{
|
|
|
|
|
++settings.countParameterSet;
|
|
|
|
|
}
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeParameter *node = getNodeParameter(name);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (node)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
fprintf(stderr, "%s \"%s\" %s", "Параметр", key, "уже существует!\n");
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
node = getLastNodeParameter();
|
2022-07-11 17:06:05 +00:00
|
|
|
|
node->next = newNodeParameter(name, key, set, singleValue, dependence, conflict);
|
2022-07-08 16:45:45 +00:00
|
|
|
|
++settings.countParameter;
|
|
|
|
|
if (set)
|
|
|
|
|
{
|
|
|
|
|
++settings.countParameterSet;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static NodeValue* getLastNodeValue(NodeParameter *node)
|
|
|
|
|
{
|
|
|
|
|
NodeValue *head = node->value;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
while (head->next)
|
|
|
|
|
{
|
|
|
|
|
head = head->next;
|
|
|
|
|
}
|
|
|
|
|
return head;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
|
|
|
|
|
return NULL;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static NodeValue* getNodeValue(NodeParameter *node, Value name)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (NodeValue *head = node->value; head; head = head->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->name == name)
|
|
|
|
|
{
|
|
|
|
|
return head;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void addParameterValue(Parameter pName, Value vName, char *current, bool set)
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *nodeParameter = getNodeParameter(pName);
|
|
|
|
|
|
|
|
|
|
if (!nodeParameter)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "%s \"%s\" %s", "Параметр для значения", current, "не существует!\n");
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (!nodeParameter->value)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
nodeParameter->value = newNodeValue(vName, current, set);
|
|
|
|
|
++nodeParameter->countValue;
|
|
|
|
|
if (set)
|
|
|
|
|
{
|
|
|
|
|
++nodeParameter->countValueSet;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
|
|
|
|
|
NodeValue *nodeValue = getNodeValue(nodeParameter, vName);
|
|
|
|
|
|
|
|
|
|
if (nodeValue)
|
|
|
|
|
{
|
|
|
|
|
fprintf(stderr, "%s \"%s\" %s", "Значение", current, "уже существует!\n");
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
else
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
nodeValue = getLastNodeValue(nodeParameter);
|
|
|
|
|
nodeValue->next = newNodeValue(vName, current, set);
|
|
|
|
|
++nodeParameter->countValue;
|
|
|
|
|
if (set)
|
|
|
|
|
{
|
|
|
|
|
++nodeParameter->countValueSet;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void freeSettings()
|
|
|
|
|
{
|
|
|
|
|
if (settings.parameter)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
freeAllNodeParameter(settings.parameter);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
NodeValue* getSetNodeValue(NodeParameter *node)
|
|
|
|
|
{
|
|
|
|
|
for (NodeValue *head = node->value; head; head = head->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (head->set)
|
|
|
|
|
{
|
|
|
|
|
return head;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return NULL;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-14 10:40:51 +00:00
|
|
|
|
char *getSetValueCurrent(Parameter name)
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *nodeParameter = getNodeParameter(name);
|
|
|
|
|
|
|
|
|
|
if (!nodeParameter)
|
|
|
|
|
{
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (NodeValue *head = nodeParameter->value; head; head = head->next)
|
|
|
|
|
{
|
|
|
|
|
if (head->set)
|
|
|
|
|
{
|
|
|
|
|
return head->current;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void setParameterValue(Parameter pName, Value vName, char *current)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeParameter *nodeParameter = getNodeParameter(pName);
|
|
|
|
|
|
|
|
|
|
if (!nodeParameter)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
fprintf(stderr, "%s \"%s\" %s", "Параметр для значения", current, "не существует!\n");
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
|
|
|
|
|
size_t length = strlen(current);
|
|
|
|
|
|
|
|
|
|
if (!length)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (nodeParameter->set)
|
|
|
|
|
{
|
|
|
|
|
nodeParameter->set = false;
|
|
|
|
|
--settings.countParameterSet;
|
|
|
|
|
}
|
|
|
|
|
return;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
else
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (!nodeParameter->set)
|
|
|
|
|
{
|
|
|
|
|
nodeParameter->set = true;
|
|
|
|
|
++settings.countParameterSet;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (!nodeParameter->value)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
nodeParameter->value = newNodeValue(vName, current, true);
|
|
|
|
|
++nodeParameter->countValue;
|
|
|
|
|
++nodeParameter->countValueSet;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
|
|
|
|
|
NodeValue *nodeValue = getNodeValue(nodeParameter, vName);
|
|
|
|
|
|
|
|
|
|
if (nodeValue)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
free(nodeValue->current);
|
|
|
|
|
nodeValue->current = (char*) malloc(sizeof(char) * length);
|
|
|
|
|
strcpy(nodeValue->current, current);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
nodeValue = getLastNodeValue(nodeParameter);
|
|
|
|
|
nodeValue->next = newNodeValue(vName, current, true);
|
|
|
|
|
++nodeParameter->countValue;
|
|
|
|
|
++nodeParameter->countValueSet;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
|
|
|
|
|
changeValue(pName, vName);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
void changeParameter(Parameter name)
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeParameter *node = getNodeParameter(name);
|
|
|
|
|
node->change = !node->change;
|
|
|
|
|
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-11 17:06:05 +00:00
|
|
|
|
void setParameter(Parameter name, bool set)
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *node = getNodeParameter(name);
|
|
|
|
|
node->set = set;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void changeValue(Parameter pName, Value vName)
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeParameter *pNode = getNodeParameter(pName);
|
|
|
|
|
for (NodeValue *head = pNode->value; head; head = head->next)
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (pNode->singleValue)
|
|
|
|
|
{
|
|
|
|
|
head->change = head->name == vName && !head->set;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
// ДОРАБОТАТЬ НА ИСПОЛЬЗОВАНИЕ МНОГИХ ПАРАМЕТРОВ
|
|
|
|
|
head->change = head->name == vName;
|
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static void saveChangeSingleValueSettings(NodeParameter *node)
|
|
|
|
|
{
|
|
|
|
|
NodeValue *nChange = NULL;
|
|
|
|
|
NodeValue *nSet = NULL;
|
|
|
|
|
|
|
|
|
|
for (NodeValue *head = node->value; head; head = head->next)
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
if (head->change)
|
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
nChange = head;
|
|
|
|
|
}
|
|
|
|
|
if (head->set)
|
|
|
|
|
{
|
|
|
|
|
nSet = head;
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (nChange)
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
nChange->change = false;
|
|
|
|
|
nChange->set = true;
|
2022-07-13 17:49:49 +00:00
|
|
|
|
|
|
|
|
|
dbWriteValue(nChange->name, nChange->set);
|
|
|
|
|
|
2022-07-11 17:06:05 +00:00
|
|
|
|
if (nSet)
|
|
|
|
|
{
|
|
|
|
|
nSet->set = false;
|
2022-07-13 17:49:49 +00:00
|
|
|
|
dbWriteValue(nSet->name, nSet->set);
|
2022-07-11 17:06:05 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
++node->countValueSet;
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
2022-07-07 16:35:48 +00:00
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
static void saveChangeValueSettings(NodeParameter *node)
|
|
|
|
|
{
|
|
|
|
|
for (NodeValue *head = node->value; head; head = head->next)
|
2022-07-07 16:35:48 +00:00
|
|
|
|
{
|
|
|
|
|
if (head->change)
|
|
|
|
|
{
|
|
|
|
|
head->change = false;
|
2022-07-08 16:45:45 +00:00
|
|
|
|
head->set = !head->set;
|
|
|
|
|
}
|
|
|
|
|
if (head->set)
|
|
|
|
|
{
|
|
|
|
|
++node->countValueSet;
|
2022-07-07 16:35:48 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void saveChangeSettings()
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
settings.countParameterSet = 0;
|
|
|
|
|
|
|
|
|
|
for (NodeParameter *pHead = settings.parameter; pHead; pHead = pHead->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (pHead->change)
|
|
|
|
|
{
|
|
|
|
|
pHead->change = false;
|
|
|
|
|
pHead->set = !pHead->set;
|
|
|
|
|
}
|
2022-07-11 17:06:05 +00:00
|
|
|
|
if (pHead->dependence && !pHead->dependence->set)
|
|
|
|
|
{
|
|
|
|
|
pHead->set = false;
|
|
|
|
|
}
|
|
|
|
|
if (pHead->conflict && pHead->conflict->set)
|
|
|
|
|
{
|
|
|
|
|
pHead->set = false;
|
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (pHead->set)
|
|
|
|
|
{
|
|
|
|
|
++settings.countParameterSet;
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-13 17:49:49 +00:00
|
|
|
|
dbWriteParameter(pHead->name, pHead->set);
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
pHead->countValueSet = 0;
|
|
|
|
|
|
|
|
|
|
if (pHead->singleValue)
|
|
|
|
|
saveChangeSingleValueSettings(pHead);
|
|
|
|
|
else
|
|
|
|
|
saveChangeValueSettings(pHead);
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
void resetChangeSettings()
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (NodeParameter *pHead = settings.parameter; pHead; pHead = pHead->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
pHead->change = false;
|
|
|
|
|
|
|
|
|
|
for (NodeValue *vHead = pHead->value; vHead; vHead = vHead->next)
|
|
|
|
|
{
|
|
|
|
|
vHead->change = false;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool getSetParameter(Parameter name)
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *node = getNodeParameter(name);
|
|
|
|
|
if (!node)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return false;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return node->set;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
bool getSetValue(Parameter pName, Value vName)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
NodeParameter *pNode = getNodeParameter(pName);
|
|
|
|
|
if (!pNode)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return false;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
for (NodeValue *vNode = pNode->value; vNode; vNode = vNode->next)
|
2022-07-06 17:51:51 +00:00
|
|
|
|
{
|
2022-07-08 16:45:45 +00:00
|
|
|
|
if (vNode->name == vName)
|
|
|
|
|
{
|
|
|
|
|
return vNode->set;
|
|
|
|
|
}
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2022-07-08 16:45:45 +00:00
|
|
|
|
return false;
|
2022-07-06 17:51:51 +00:00
|
|
|
|
}
|
2022-07-11 17:06:05 +00:00
|
|
|
|
|
|
|
|
|
int getCountValue(Parameter name)
|
|
|
|
|
{
|
|
|
|
|
NodeParameter *node = getNodeParameter(name);
|
|
|
|
|
if (!node)
|
|
|
|
|
{
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return node->countValue;
|
|
|
|
|
}
|