package io.openems.edge.controller.api.modbus.readwrite.tcp;

import static io.openems.edge.controller.api.modbus.CommonConfig.DEFAULT_API_TIMEOUT_SECONDS;
import static io.openems.edge.controller.api.modbus.CommonConfig.DEFAULT_MAX_CONCURRENT_CONNECTIONS;
import static io.openems.edge.controller.api.modbus.CommonConfig.Tcp.DEFAULT_PORT;

import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;

import io.openems.edge.controller.api.modbus.LogVerbosity;

@ObjectClassDefinition(//
		name = "Controller Api Modbus/TCP Read-Write", //
		description = "This controller provides a read-write Modbus/TCP api.")
public @interface Config {

	@AttributeDefinition(name = "Component-ID", description = "Unique ID of this Component")
	String id() default "ctrlApiModbusTcp0";

	@AttributeDefinition(name = "Alias", description = "Human-readable name of this Component; defaults to Component-ID")
	String alias() default "ModbusTcp Read-Write";

	@AttributeDefinition(name = "Is enabled?", description = "Is this Component enabled?")
	boolean enabled() default true;

	@AttributeDefinition(name = "Port", description = "Port on which the server should listen.")
	int port() default DEFAULT_PORT;

	@AttributeDefinition(name = "Component-IDs", description = "Components that should be made available via Modbus.")
	String[] component_ids() default { "_sum" };

	// TODO: Currently unused
	@AttributeDefinition(name = "Read Channel-IDs", description = "Contains the channelnames of all read channels.")
	String[] readChannels() default {};

	@AttributeDefinition(name = "Write Channel-IDs", description = "Contains the channelnames of all overridden channels.")
	String[] writeChannels();

	@AttributeDefinition(name = "Api-Timeout", description = "Sets the timeout in seconds for updates on Channels set by this Api.")
	int apiTimeout() default DEFAULT_API_TIMEOUT_SECONDS;

	@AttributeDefinition(name = "Max concurrent connections", description = "Sets the maximum number of concurrent connections via Modbus.")
	int maxConcurrentConnections() default DEFAULT_MAX_CONCURRENT_CONNECTIONS;

	@AttributeDefinition(name = "Log-Verbosity", description = "The log verbosity.")
	LogVerbosity logVerbosity() default LogVerbosity.NONE;

	String webconsole_configurationFactory_nameHint() default "Controller Api Modbus/TCP Read-Write [{id}]";
}