FP_FTP_GET_DATA_FORMAT

Generate data format string for FTP protocol

This FP instruction generates a string specifying the data format (FP address and length) according to the data type at the input Var. It writes the string into the output variable sDataFormat that is suitable for the input sPLCFullFileNameOrDataFormat of the instruction FP_FTP_SET_MODE.

Parameters

Input

Var (BOOL, INT, UINT, WORD, DINT, UDINT, DWORD, REAL, DATE, TOD, DT, STRING)

Simple data type or array of simple data types, e.g. BOOL, INT, UINT, STRING, ...

Restriction: ARRAY..OF..STRING is not allowed

nSize (WORD, INT, UINT)

Size of data in word or for strings in byte units.

nColumns (WORD, INT, UINT)

Number of items after which a new line should be added in the .csv converted file

Output

sDataFormat (STRING)

String specifying the data format for the input sPLCFullFileNameOrDataFormat of FP_FTP_SET_MODE

Remarks

  • Before you execute the instruction, you need to specify the transfer settings using FP_FTP_SET_MODE or the setting dialog of the FTP client.

  • Before you execute the instruction, make sure that sys_bIsEthernetInitializing is FALSE. sys_bIsEthernetInitializing turns to TRUE when the instruction is executed. When you execute the instruction while sys_bIsEthernetInitializing is TRUE, an error occurs.

  • The instruction can only be executed when the transfer request flag for the specified transfer setting is "FALSE: No transfer request". When the transfer request flag is "TRUE: Transfer requested", an operation error occurs.

  • When this instruction has been executed successfully, the system variables sys_bIsCarry and sys_iEthernetConnectionErrorCode are reset.

  • This instruction does not overwrite the Ethernet configuration data stored in the PLC permanently. When the PLC has been switched off and on again, the Ethernet configuration data stored in the PLC are used again.

  • After the FTP client transfer settings have been completed, data is sent to files or obtained from files when FP_FTP_TRANSFER_REQUEST is executed.

  • When an error occurs, check the system variable sys_iEthernetConnectionErrorCode for the error code number.

Error flags

sys_bIsOperationErrorHold (turns to TRUE and remains TRUE)
  • if a timeout of the connection is exceeded

  • if an IP address is invalid

sys_bIsOperationErrorNonHold (turns to TRUE for one scan)
  • if a timeout of the connection is exceeded

  • if an IP address is invalid

sys_bIsCarry (turns to TRUE for one scan)
  • if the instruction is executed during the initialization of Ethernet, sys_iEthernetConnectionErrorCode is set to "11: Ethernet is being initialized".

Example

POU header

All input and output variables used for programming this function have been declared in the POU header. The same POU header is used for all programming languages.

	VAR
		bSetModePlcData: BOOL:=FALSE;
		bSetModePlcDataError: BOOL:=FALSE;
		arrayValues: ARRAY[0..15] OF REAL:=[16(0.0)];
		iID10: INT:=10;
	END_VAR

POU body

If bSetModePlcData changes from FALSE to TRUE and sys_bIsEthernetInitializing is FALSE, the instruction is carried out.

LD body

NOTE
When a constant with the value 0 is applied to the input nColumns, the line feed position in the generated data format string is omitted. This is necessary if the instruction FP_FTP_SET_MODE is used subsequently in the operation mode GETDATA.
BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
        ACTIVE_NETWORK := 0 ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 8 ;
        NETWORK_BODY
B(B_CONTACT,,bSetModePlcData,5,1,7,3,R);
B(B_VARIN,,'SV0~GETDATA~NON',40,3,42,5,);
B(B_VAROUT,,bSetModePlcDataError,60,2,62,4,);
B(B_VARIN,,'\B:\LOG\MyData.csv~END',40,5,42,7,);
B(B_VARIN,,iID10,40,2,42,4,);
B(B_CONTACT,,sys_bIsEthernetInitializing,16,1,18,3,N);
B(B_VARIN,,arrayValues,6,4,8,6,);
B(B_VARIN,,0,13,6,15,8,);
B(B_F,Size_Of_Var!,,8,5,15,7,,?D?C);
B(B_F,FP_FTP_SET_MODE!,,42,0,58,7,,?DEN?DnTransferID?DsOperation?DsPLCFullFileNameOrDataFormat?DsFTPServerFullFileName?AENO?CbError);
B(B_F,FP_FTP_GET_DATA_FORMAT!,,15,3,29,8,,?D@'Var'?DnSize?DnColumns?CsDataFormat);
L(1,2,5,2);
L(7,2,16,2);
L(8,5,8,6);
L(18,2,42,2);
L(58,3,60,3);
L(8,5,15,5);
L(29,5,42,5);
L(1,0,1,8);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

If DF(bSetModePlcData) And not sys_bIsEthernetInitializing then
    FP_FTP_SET_MODE(nTransferID := iID10,
                    sOperation := 'SV0,GETDATA,NON',
                    sPLCFullFileNameOrDataFormat := FP_FTP_GET_DATA_FORMAT(Var := arrayValues,
                                                                           nSize := Size_Of_Var(arrayValues),
                                                                           nColumns := 0), 
                    sFTPServerFullFileName := '\B:\LOG\MyData.csv,END',
                    bError => bSetModePlcDataError);
End_if;

Modified on: 2022-02-17Feedback on this pagePanasonic hotline