Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BYTE_TO_XX.fct files under splitting directory in utils-1.0.0 #243

Merged
merged 13 commits into from
Aug 16, 2024
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<Function Name="SPLIT_BYTE_INTO_BOOLS" Comment="">
<Identification Standard="61499-1" Description="Copyright (c) 2024 HR Agrartechnik GmbH &#10; &#10;This program and the accompanying materials are made &#10;available under the terms of the Eclipse Public License 2.0 &#10;which is available at https://www.eclipse.org/legal/epl-2.0/ &#10; &#10;SPDX-License-Identifier: EPL-2.0" >
</Identification>
<VersionInfo Version="1.0" Author="franz" Date="2024-02-22">
</VersionInfo>
<CompilerInfo>
</CompilerInfo>
<InterfaceList>
<EventInputs>
<Event Name="REQ" Type="Event" Comment="Normal Execution Request">
<With Var="IN"/>
</Event>
</EventInputs>
<EventOutputs>
<Event Name="CNF" Type="Event" Comment="Execution Confirmation">
<With Var="OUT_00"/>
<With Var="OUT_01"/>
<With Var="OUT_02"/>
<With Var="OUT_03"/>
<With Var="OUT_04"/>
<With Var="OUT_05"/>
<With Var="OUT_06"/>
<With Var="OUT_07"/>
</Event>
</EventOutputs>
<InputVars>
<VarDeclaration Name="IN" Type="BYTE" Comment="BYTE Input"/>
</InputVars>
<OutputVars>
<VarDeclaration Name="OUT_00" Type="BOOL" Comment="BIT 00"/>
MoritzO02 marked this conversation as resolved.
Show resolved Hide resolved
<VarDeclaration Name="OUT_01" Type="BOOL" Comment="BIT 01"/>
<VarDeclaration Name="OUT_02" Type="BOOL" Comment="BIT 02"/>
<VarDeclaration Name="OUT_03" Type="BOOL" Comment="BIT 03"/>
<VarDeclaration Name="OUT_04" Type="BOOL" Comment="BIT 04"/>
<VarDeclaration Name="OUT_05" Type="BOOL" Comment="BIT 05"/>
<VarDeclaration Name="OUT_06" Type="BOOL" Comment="BIT 06"/>
<VarDeclaration Name="OUT_07" Type="BOOL" Comment="BIT 07"/>
</OutputVars>
</InterfaceList>
<FunctionBody>
<ST><![CDATA[FUNCTION SPLIT_BYTE_INTO_BOOLS
(* this Function extracts the 8 BOOLS from a byte *)

VAR_INPUT
IN : BYTE; // BYTE Input
MoritzO02 marked this conversation as resolved.
Show resolved Hide resolved
END_VAR

VAR_OUTPUT
OUT_00 : BOOL; // BIT 00
OUT_01 : BOOL; // BIT 01
OUT_02 : BOOL; // BIT 02
OUT_03 : BOOL; // BIT 03
OUT_04 : BOOL; // BIT 04
OUT_05 : BOOL; // BIT 05
OUT_06 : BOOL; // BIT 06
OUT_07 : BOOL; // BIT 07
END_VAR

OUT_00 := IN.%X0;
OUT_01 := IN.%X1;
OUT_02 := IN.%X2;
OUT_03 := IN.%X3;
OUT_04 := IN.%X4;
OUT_05 := IN.%X5;
OUT_06 := IN.%X6;
OUT_07 := IN.%X7;

END_FUNCTION
]]></ST>
</FunctionBody>
</Function>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?xml version="1.0" encoding="UTF-8"?>
<Function Name="SPLIT_BYTE_INTO_QUARTERS" Comment="">
<Identification Standard="61499-1" Description="Copyright (c) 2024 HR Agrartechnik GmbH &#10; &#10;This program and the accompanying materials are made &#10;available under the terms of the Eclipse Public License 2.0 &#10;which is available at https://www.eclipse.org/legal/epl-2.0/ &#10; &#10;SPDX-License-Identifier: EPL-2.0" >
</Identification>
<VersionInfo Version="1.0" Author="franz" Date="2024-02-22">
</VersionInfo>
<CompilerInfo>
</CompilerInfo>
<InterfaceList>
<EventInputs>
<Event Name="REQ" Type="Event" Comment="Normal Execution Request">
<With Var="IN"/>
</Event>
</EventInputs>
<EventOutputs>
<Event Name="CNF" Type="Event" Comment="Execution Confirmation">
<With Var="OUT_00"/>
<With Var="OUT_01"/>
<With Var="OUT_02"/>
<With Var="OUT_03"/>
</Event>
</EventOutputs>
<InputVars>
<VarDeclaration Name="IN" Type="BYTE" Comment="BYTE Input"/>
</InputVars>
<OutputVars>
<VarDeclaration Name="OUT_00" Type="BYTE" Comment="QUARTER BYTE 00"/>
<VarDeclaration Name="OUT_01" Type="BYTE" Comment="QUARTER BYTE 01"/>
<VarDeclaration Name="OUT_02" Type="BYTE" Comment="QUARTER BYTE 02"/>
<VarDeclaration Name="OUT_03" Type="BYTE" Comment="QUARTER BYTE 03"/>
</OutputVars>
</InterfaceList>
<FunctionBody>
<ST><![CDATA[FUNCTION SPLIT_BYTE_INTO_QUARTERS
(* this Function extracts the 4 QUARTER BYTE from a byte *)

VAR_INPUT
IN : BYTE; // BYTE Input
MoritzO02 marked this conversation as resolved.
Show resolved Hide resolved
END_VAR

VAR_OUTPUT
OUT_00 : BYTE; // QUARTER BYTE 00
OUT_01 : BYTE; // QUARTER BYTE 01
OUT_02 : BYTE; // QUARTER BYTE 02
OUT_03 : BYTE; // QUARTER BYTE 03
END_VAR

OUT_00 := SHR(IN AND BYTE_QUARTER_00, SHFT_QUARTER_00);
MoritzO02 marked this conversation as resolved.
Show resolved Hide resolved
OUT_01 := SHR(IN AND BYTE_QUARTER_01, SHFT_QUARTER_01);
OUT_02 := SHR(IN AND BYTE_QUARTER_02, SHFT_QUARTER_02);
OUT_03 := SHR(IN AND BYTE_QUARTER_03, SHFT_QUARTER_03);

END_FUNCTION
]]></ST>
</FunctionBody>
</Function>
Loading