Client Bug Fixes. Added GPU-CPU Rendering in XML Config

This commit is contained in:
CMS3762\carminatini
2017-12-21 08:30:49 +01:00
parent eda55bd7e5
commit cc88c89c83
35 changed files with 1226 additions and 792 deletions
+1
View File
@@ -67,6 +67,7 @@
<ItemGroup>
<EmbeddedResource Include="Config.xml">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<SubType>Designer</SubType>
</EmbeddedResource>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+2 -1
View File
@@ -7,6 +7,8 @@
<xs:complexType>
<xs:all>
<xs:element name="TranspColor" minOccurs='1' maxOccurs='1'/>
<xs:element name="RenderingMethod" minOccurs='1' maxOccurs='1'/>
<xs:element name="RunningOnSecondaryScreen" minOccurs='1' maxOccurs='1'/>
</xs:all>
</xs:complexType>
</xs:element>
@@ -22,7 +24,6 @@
<xs:element name="VendorHmi">
<xs:complexType>
<xs:all>
<xs:element name="Enabled" minOccurs='1' maxOccurs='1'/>
<xs:element name="Type" minOccurs='1' maxOccurs='1'/>
</xs:all>
</xs:complexType>
+4 -3
View File
@@ -1,7 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<Config>
<Client>
<TranspColor>#00FF00</TranspColor>
<TranspColor>#FF00FF</TranspColor>
<RenderingMethod>GPU</RenderingMethod> <!-- GPU/CPU -->
<RunningOnSecondaryScreen>false</RunningOnSecondaryScreen>
</Client>
<Connection>
<Url>http://localhost:9000/index.html</Url>
@@ -9,8 +11,7 @@
<DeleteCahceFolderOnStartup>false</DeleteCahceFolderOnStartup>
</Connection>
<VendorHmi>
<Enabled>false</Enabled>
<Type>1</Type>
<Type>OSAI</Type><!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
</VendorHmi>
<ExtSoftwares>
<Software>
+50 -20
View File
@@ -15,6 +15,8 @@ namespace Client.Config
{
public class ConfigController
{
const String ChromeScheme = "chrome";
public static void ReadStartupConfig()
{
int SoftwareId = 0;
@@ -35,7 +37,9 @@ namespace Client.Config
.Descendants(Constants.CLIENT_CONFIG_KEY)
.Select(x => new SubModels.Client()
{
TranspColor = ValidateTranspColor(x.Element("TranspColor").Value)
TranspColor = ValidateTranspColor(x.Element("TranspColor").Value),
RenderingMethod = ValidateRendering(x.Element("RenderingMethod").Value),
RunningOnSecondaryScreen = ValidateSecScreen(x.Element("RunningOnSecondaryScreen").Value)
}).FirstOrDefault();
Config.ConnectionConfig = xmlConfigFile
@@ -51,7 +55,7 @@ namespace Client.Config
.Descendants(Constants.VENDORHMI_CONFIG_KEY)
.Select(x => new SubModels.VendorHmi()
{
Enabled = ValidateOpenHmi(x.Element("Enabled").Value),
Enabled = ValidateOpenHmi(x.Element("Type").Value),
Type = ValidateNcType(x.Element("Type").Value)
}).FirstOrDefault();
@@ -75,9 +79,7 @@ namespace Client.Config
if (!String.IsNullOrWhiteSpace(Arguments.Url))
Config.ConnectionConfig.Url = ValidateArgumentUrl(Arguments.Url);
}
}
private static void ValidationHandler(object sender, ValidationEventArgs e)
{
@@ -91,7 +93,7 @@ namespace Client.Config
private static String ValidateUrl(String value)
{
Uri NewUrl;
if (Uri.TryCreate(value, UriKind.Absolute, out NewUrl) && (NewUrl.Scheme == Uri.UriSchemeHttp || NewUrl.Scheme == Uri.UriSchemeHttps || NewUrl.Scheme == Uri.UriSchemeFile))
if (Uri.TryCreate(value, UriKind.Absolute, out NewUrl) && (NewUrl.Scheme == Uri.UriSchemeHttp || NewUrl.Scheme == Uri.UriSchemeHttps || NewUrl.Scheme == Uri.UriSchemeFile || NewUrl.Scheme == ChromeScheme))
return value;
else
throw new Exception(@"Configuration Error: ""Connection - Url"" is not a valid URL");
@@ -101,7 +103,7 @@ namespace Client.Config
private static String ValidateArgumentUrl(String value)
{
Uri NewUrl;
if (Uri.TryCreate(value, UriKind.Absolute, out NewUrl) && (NewUrl.Scheme == Uri.UriSchemeHttp || NewUrl.Scheme == Uri.UriSchemeHttps || NewUrl.Scheme == Uri.UriSchemeFile))
if (Uri.TryCreate(value, UriKind.Absolute, out NewUrl) && (NewUrl.Scheme == Uri.UriSchemeHttp || NewUrl.Scheme == Uri.UriSchemeHttps || NewUrl.Scheme == Uri.UriSchemeFile || NewUrl.Scheme == ChromeScheme))
return value;
else
throw new Exception(@"Argument Url Error: is not a valid URL");
@@ -120,35 +122,65 @@ namespace Client.Config
catch (Exception)
{
throw new Exception(@"Configuration Error: ""Client - TranspColor"" is not a valid Hex Color");
}
}
}
private static Constants.Rendering ValidateRendering(string value)
{
if (value.ToUpper().Equals("CPU"))
return Constants.Rendering.CPU;
else if (value.ToUpper().Equals("GPU"))
return Constants.Rendering.GPU;
else
throw new Exception(@"Configuration Error: ""Client - RenderingMethod"" is not a valid Rendering Method");
}
private static bool ValidateSecScreen(string value)
{
Boolean secScreen;
if (Boolean.TryParse(value, out secScreen))
return secScreen;
else
throw new Exception(@"Configuration Error: ""Client - RunningOnSecondaryScreen"" is not a valid Boolean Type");
}
private static Boolean ValidateOpenHmi(String value)
{
Boolean OpenHmi;
if (Boolean.TryParse(value, out OpenHmi))
return OpenHmi;
String Nc = value.ToUpper();
if (Nc.Equals("NO_NC"))
return false;
else
throw new Exception(@"Configuration Error: ""VendorHmi - Enabled"" is not a valid Boolean Type");
return true;
}
private static ushort ValidateNcType(String value)
{
ushort Nc;
String Nc = value.ToUpper();
if (ushort.TryParse(value, out Nc) && Nc <= 3)
return Nc;
if (Nc.Equals("NO_NC") || Nc.Equals("DEMO"))
return 0;
else if(Nc.Equals("FANUC"))
return 1;
else if (Nc.Equals("SIEMENS"))
return 2;
else if (Nc.Equals("OSAI"))
return 3;
else
throw new Exception(@"Configuration Error: ""VendorHmi - Type"" is not a valid NC Type");
}
private static ushort ValidateClientID(String value)
{
ushort Client;
@@ -211,9 +243,7 @@ namespace Client.Config
Image im = Icon.ExtractAssociatedIcon(value).ToBitmap();
MemoryStream m = new MemoryStream();
im.Save(m, ImageFormat.Png);
return "data:image/png;base64," + Convert.ToBase64String(m.ToArray());
return "data:image/png;base64," + Convert.ToBase64String(m.ToArray());
}
+3
View File
@@ -4,11 +4,14 @@ using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static Client.Utils.Constants;
namespace Client.Config.SubModels
{
public class Client
{
public Color TranspColor { get; set; }
public Rendering RenderingMethod { get; set; }
public Boolean RunningOnSecondaryScreen { get; set; }
}
}