当前位置: 首页 > 工具软件 > 4DIAC > 使用案例 >

十一. IEC 61499开源项目4diac运行时(forte)参数调优

艾子石
2023-12-01

4diac的IDE与运行时通信的协议采用的是TCP,且运行时的服务指令端口同时只能被一个IDE连接,如果指令端口已经有IDE连接上了,其它连接到指令端口的客户端会被立即断开。Forte这样设计的目的是为了保证运行时处理应用的数据安全性。IDE向forte发送指令的长度是2个字节,每次最多只能传输两个字节长度的数据。在forte默认配置的长度可能不能满足用户传输数据要求时就要修改指令端口接收数据的最大长度,这些参数可以在cmake配置编译forte源码时设置,如果想在后面工程文件中修改应该怎么办了?下面就会详细讲解怎么在代码里面修改forte配置参数。Forte全局配置参数的文件是forte_config.h文件,内容如下:

/*******************************************************************************

 * Copyright (c) 2005 - 2014 ACIN, Profactor GmbH, fortiss GmbH

 * This program and the accompanying materials are made available under the

 * terms of the Eclipse Public License 2.0 which is available at

 * http://www.eclipse.org/legal/epl-2.0.

 *

 * SPDX-License-Identifier: EPL-2.0

 *

 * Contributors:

 *   Alois Zoitl, Martin Melik Merkumians, Ingo Hegny, Michael Hofmann

 *     - initial API and implementation and/or initial documentation

 *******************************************************************************/

#ifndef _CONFIG_H_

#define _CONFIG_H_

#include <datatype.h>

/*!Define the number of times the CTimerHandler will be called per second.

 *

 * FORTE will use this information to calculate time values.

 */

const TForteUInt32 cg_nForteTicksPerSecond = 1000;

/*! \brief Defines the time base in units per second that will be used in the TIME data type

 *

 *  The default value will be 1 000 000 000, which means that the time bas is 1 ns.

 *  For Smaller devices which do not use 64 bit datatypes a time base of 1000 (i.e., 1ms)

 *  or 1000000 (i.e., 1micro s) may be suitable.

 */

const uint_fast64_t cgForteTimeBaseUnitsPerSecond = 1000000000;

/*! Define the initial size of the event chain list used in the event chain execution thread.

 *

 */

const unsigned int cg_nEventChainEventListSize = 256;

/*! Define the initial size of the event chain's external event list.

 */

const unsigned int cg_nEventChainExternalEventListSize = 10;

/*! Defines the number of pending communication messages can be handled by a communication function block

 *

 */

const unsigned int cg_unCommunicationInterruptQueueSize = 10;

/*! Buffer size in bytes to be used by the ip layer as receive buffer.

 *

 */

const unsigned int cg_unIPLayerRecvBufferSize = 60000;

/*! \brief Define the management encapsulation protocol

 *

 * Currently two protocols are supported:

 *   # DEV_MGR for FBDK compliant XML encoded commands

 *   # WBXML_DEV_MGR for WAP Binary XML encoded commands

 */

#define FORTE_MGM_COMMAND_PROTOCOL  

//! Max supported hierarchy that can be provided in a management commands

#define FORTE_MGM_MAX_SUPPORTED_NAME_HIERARCHY   30

/*! \brief FORTE string dict's initial string buffer size

 *

 * Depending on the FORTE_STRING_DICT_FIXED_MEMORY flag the string dict will reallocate if necessary.

 */

const TForteUInt32 cg_unStringDictInitialStringBufSize = 8000;

/*! \brief FORTE string dict's initial max nr of strings

 *

 * Depending on the FORTE_STRING_DICT_FIXED_MEMORY flag the string dict will reallocate if necessary.

 */

const TForteUInt32 cg_unStringDictInitialMaxNrOfStrings = 300;

const TForteUInt32 cg_unNumberOfHandlers = 6;

#define FORTE_BOOT_FILE_LOCATION "forte.fboot"

extern char* gCommandLineBootFile;

#define FORTE_LOGGER_BUFFER_SIZE 300

#define FORTE_COM_HTTP_LISTENING_PORT 80

extern TForteUInt16 gHTTPServerPort;

#define FORTE_COM_HTTP

#define FORTE_COM_OPC_UA_PORT 4840

extern TForteUInt16 gOpcuaServerPort;

#include <string>

extern std::string gOpcuaClientConfigFile;

#define FORTE_COM_OPC_UA_SERVER_PUB_INTERVAL 100.0

#define FORTE_COM_OPC_UA_CLIENT_PUB_INTERVAL 100.0

#define FORTE_COM_OPC_UA

/* #undef FORTE_COM_OPC_UA_MULTICAST */

/* #undef FORTE_COM_OPC_UA_CUSTOM_HOSTNAME */

#endif

可以修改上面列出的参数优化网络接收数据的大小、事件队列的大小,尤其是事件队列,如果太小可能导致队列很快就慢,后面来的事件就只有丢弃,可以调整大小找到适合特定硬件处理速度的最优值,但是还是不能避免事件丢失的情况。只能在做实际应用时多加优化,避免事件丢失。后面的章节会讲解怎么优化设计应用。

 类似资料: