Skip to content

Commit

Permalink
update upax file for app, entry, certs
Browse files Browse the repository at this point in the history
  • Loading branch information
blazej.kuhajda committed Dec 11, 2024
1 parent 7623ecf commit bbd2640
Show file tree
Hide file tree
Showing 8 changed files with 100 additions and 5 deletions.
19 changes: 19 additions & 0 deletions src/data/app/SystemConstants/plc_line_HwIdentifiers.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
CONFIGURATION HardwareIDs
VAR_GLOBAL CONSTANT
plc_line_HwID : UINT := UINT#32;
plc_line_Rail_0_HwID : UINT := UINT#257;
plc_line_plc_line_HwID : UINT := UINT#48;
plc_line_plc_line_CPU_display_1_HwID : UINT := UINT#54;
plc_line_plc_line_Card_reader_writer_1_HwID : UINT := UINT#51;
plc_line_plc_line_DP_interface_1_HwID : UINT := UINT#60;
plc_line_plc_line_OPC_UA_1_HwID : UINT := UINT#117;
plc_line_plc_line_profinet_x1_HwID : UINT := UINT#64;
plc_line_plc_line_profinet_x1_Port_1_HwID : UINT := UINT#65;
plc_line_plc_line_profinet_x1_Port_2_HwID : UINT := UINT#66;
plc_line_plc_line_profinet_x2_HwID : UINT := UINT#72;
plc_line_plc_line_profinet_x2_Port_3_HwID : UINT := UINT#73;
plc_line_plc_line_virtual_communication_interface_HwID : UINT := UINT#135;
profinet_plc_line_HwID : UINT := UINT#256;

END_VAR
END_CONFIGURATION
5 changes: 5 additions & 0 deletions src/data/app/SystemConstants/plc_line_IoAddresses.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIGURATION IoAddresses
VAR_GLOBAL

END_VAR
END_CONFIGURATION
6 changes: 5 additions & 1 deletion src/data/app/apax.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@ dependencies:
"@ix-ax/axopen.data": '0.0.0-dev.0'
"@ix-ax/ax.axopen.app": '0.0.0-dev.0'
"@ix-ax/axopen.simatic1500": '0.0.0-dev.0'
installStrategy: strict
# this is just temporary to test new features
# upto the moment of releasing new catalog
# installStrategy: strict
"@ix-ax/ax.latest.packages": '0.0.0-dev.0'
installStrategy: overridable
apaxVersion: 3.3.1
scripts:
# For proper execution of these scripts, the following variables need to be defined as environment variables or local variables.
Expand Down
28 changes: 24 additions & 4 deletions src/data/app/ix/Entry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,38 @@
using System.Text;
using System.Threading.Tasks;
using AXSharp.Connector.S71500.WebApi;
using System.Net.Security;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;

namespace librarytemplate
{

public static class Entry
{
private static readonly string TargetIp = Environment.GetEnvironmentVariable("AXTARGET"); // <- replace by your IP
private const string UserName = "Everybody"; //<- replace by user name you have set up in your WebAPI settings
private const string Pass = ""; // <- Pass in the password that you have set up for the user. NOT AS PLAIN TEXT! Use user secrets instead.
public static string TargetIp { get; } = Environment.GetEnvironmentVariable("AXTARGET"); // <- replace by your IP
private static string Pass => Environment.GetEnvironmentVariable("AX_TARGET_PWD"); // <- Pass in the password that you have set up for the user. NOT AS PLAIN TEXT! Use user secrets instead.
private static string UserName = Environment.GetEnvironmentVariable("AX_USERNAME"); //<- replace by user name you have set up in your WebAPI settings
private const bool IgnoreSslErrors = true; // <- When you have your certificates in order set this to false.
private static string CertificatePath = "certs\\plc_line\\plc_line.cer";

static string GetCertPath()
{
var fp = new FileInfo(Path.Combine(Assembly.GetExecutingAssembly().Location));
return Path.Combine(fp.DirectoryName, CertificatePath);
}

static readonly X509Certificate2 Certificate = new X509Certificate2(GetCertPath());

private static bool CertificateValidation(HttpRequestMessage requestMessage, X509Certificate2 certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{
return certificate.Thumbprint == Certificate.Thumbprint;
}

public static axopen_data_appTwinController Plc { get; }
= new(ConnectorAdapterBuilder.Build()
.CreateWebApi(TargetIp, UserName, Pass, IgnoreSslErrors));
.CreateWebApi(TargetIp, UserName, Pass, CertificateValidation, IgnoreSslErrors));

}

}
6 changes: 6 additions & 0 deletions src/data/app/ix/axopen_data_app.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@
<Content Include=".meta\**" />
</ItemGroup>

<ItemGroup>
<None Include="..\certs\plc_line\plc_line.cer" Link="certs\plc_line\plc_line.cer">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\..\..\core\src\AXOpen.Core\ix_ax_axopen_core.csproj" />
<ProjectReference Include="..\..\src\AXOpen.Data\ix_ax_axopen_data.csproj" />
Expand Down
23 changes: 23 additions & 0 deletions src/data/app/src/IO/HwIdentifiers.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
NAMESPACE AXOpen.Data
TYPE
HwIdentifiers : WORD
(
plc_line_HwID := WORD#32,
plc_line_Rail_0_HwID := WORD#257,
plc_line_plc_line_HwID := WORD#48,
plc_line_plc_line_CPU_display_1_HwID := WORD#54,
plc_line_plc_line_Card_reader_writer_1_HwID := WORD#51,
plc_line_plc_line_DP_interface_1_HwID := WORD#60,
plc_line_plc_line_OPC_UA_1_HwID := WORD#117,
plc_line_plc_line_profinet_x1_HwID := WORD#64,
plc_line_plc_line_profinet_x1_Port_1_HwID := WORD#65,
plc_line_plc_line_profinet_x1_Port_2_HwID := WORD#66,
plc_line_plc_line_profinet_x2_HwID := WORD#72,
plc_line_plc_line_profinet_x2_Port_3_HwID := WORD#73,
plc_line_plc_line_virtual_communication_interface_HwID := WORD#135,
profinet_plc_line_HwID := WORD#256,

NONE := WORD#0
);
END_TYPE
END_NAMESPACE
9 changes: 9 additions & 0 deletions src/data/app/src/IO/Inputs.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NAMESPACE AXOpen.Data
TYPE
{S7.extern=ReadWrite}
{#ix-attr:[Container(Layout.Wrap)]}
Inputs : STRUCT
noInputsFoundInTheHwConfig AT %B0: BYTE;
END_STRUCT;
END_TYPE
END_NAMESPACE
9 changes: 9 additions & 0 deletions src/data/app/src/IO/Outputs.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
NAMESPACE AXOpen.Data
TYPE
{S7.extern=ReadWrite}
{#ix-attr:[Container(Layout.Wrap)]}
Outputs : STRUCT
noOutputsFoundInTheHwConfig AT %B0: BYTE;
END_STRUCT;
END_TYPE
END_NAMESPACE

0 comments on commit bbd2640

Please sign in to comment.