First softkey implementation

Added config and API
Added Thread and signal
This commit is contained in:
Lucio Maranta
2018-03-06 17:58:02 +01:00
parent 6db3b6d328
commit 6332ed9732
22 changed files with 528 additions and 53 deletions
+38 -1
View File
@@ -70,10 +70,37 @@ namespace Step.Config
Intervall = TimeSpan.FromMinutes(Convert.ToDouble(x.Element("interval").Value)),
Deadline = DateTime.Parse(x.Element("deadline").Value),
Type = x.Element("type").Value,
CouterId = Convert.ToInt32(x.Element("counterId").Value)
CouterId = Convert.ToInt32(x.Element("counterId").Value)
}
)
.ToList();
// Get SoftKeys
xmlConfigFile = GetXmlHandlerWithValidator(SOFT_KEY_CONFIG_SCHEMA_PATH, SOFT_KEY_CONFIG_PATH);
int id = 1;
SoftKeysConfig = xmlConfigFile
.Root
.Elements()
.Where(x => Convert.ToBoolean(x.Element("active").Value) == true)
.Select(x => new SoftKeyConfigModel()
{
Id = id++,
PlcId = Convert.ToInt32(x.Element("plcId")?.Value),
IsActive = Convert.ToBoolean(x.Element("active").Value),
Category = Convert.ToInt32(x.Element("category").Value),
LocalizedNames = x.Element("localizedNames").Elements().ToDictionary( // Read localized names and convert into a dictionary
y => y.Attribute("langKey").Value, y => y.Value
),
SubKeys = x.Element("plcKeys")?.Elements().Select(y => new SubKeysModel()
{
Id = id++,
PlcId = Convert.ToInt32(y.Attribute("plcId").Value),
Text = y.Value
}).ToList(),
Type = GetSoftKeyType(x.Name.ToString())
})
.ToList();
}
catch (Exception ex)
{
@@ -96,6 +123,16 @@ namespace Step.Config
return xmlConfigFile;
}
private static SOFTKEY_TYPE GetSoftKeyType(string type)
{
switch (type)
{
case "procedure": return SOFTKEY_TYPE.PROCEDURE;
case "group": return SOFTKEY_TYPE.MULTIPLE;
default: return SOFTKEY_TYPE.SOFTKEY;
}
}
private static void SetAreaValueByName(XElement element)
{
// Choose which area to be set