from ctypes import Array
from typing import Any, Callable, Dict, TypeAlias

STRING_BUFFER: int
PLC_DEFAULT_STRING_SIZE: int
MAX_ADS_SUB_COMMANDS: int


class PLCTYPE_WSTRING: ...


# PLC data types (typing-only ergonomic aliases)
PLCTYPE_BOOL: TypeAlias = bool
PLCTYPE_BYTE: TypeAlias = int
PLCTYPE_DWORD: TypeAlias = int
PLCTYPE_DINT: TypeAlias = int
PLCTYPE_INT: TypeAlias = int
PLCTYPE_LREAL: TypeAlias = float
PLCTYPE_REAL: TypeAlias = float
PLCTYPE_SINT: TypeAlias = int
PLCTYPE_STRING: TypeAlias = str
PLCTYPE_TOD: TypeAlias = int
PLCTYPE_UBYTE: TypeAlias = int
PLCTYPE_UDINT: TypeAlias = int
PLCTYPE_UINT: TypeAlias = int
PLCTYPE_USINT: TypeAlias = int
PLCTYPE_WORD: TypeAlias = int
PLCTYPE_LINT: TypeAlias = int
PLCTYPE_ULINT: TypeAlias = int

PLCTYPE_DATE: TypeAlias = int
PLCTYPE_DATE_AND_TIME: TypeAlias = int
PLCTYPE_DT: TypeAlias = int
PLCTYPE_TIME: TypeAlias = int

PLCSimpleDataType: TypeAlias = bool | int | float | str | PLCTYPE_WSTRING | Array
PLCDataType: TypeAlias = Any

DATATYPE_MAP: Dict[type[Any], str]
PLC_STRING_TYPE_NAME: str
ads_type_to_ctype: Dict[int, type[Any]]


def PLCTYPE_ARR_REAL(n: int) -> type[Array]: ...
def PLCTYPE_ARR_LREAL(n: int) -> type[Array]: ...
def PLCTYPE_ARR_BOOL(n: int) -> type[Array]: ...
def PLCTYPE_ARR_INT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_UINT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_SHORT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_USHORT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_DINT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_UDINT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_SINT(n: int) -> type[Array]: ...
def PLCTYPE_ARR_USINT(n: int) -> type[Array]: ...


PLC_ARRAY_MAP: Dict[str, Callable[[int], type[Array]]]

# ADS data types
ADST_VOID: int
ADST_INT8: int
ADST_UINT8: int
ADST_INT16: int
ADST_UINT16: int
ADST_INT32: int
ADST_UINT32: int
ADST_INT64: int
ADST_UINT64: int
ADST_REAL32: int
ADST_REAL64: int
ADST_BIGTYPE: int
ADST_STRING: int
ADST_WSTRING: int
ADST_REAL80: int
ADST_BIT: int
ADST_MAXTYPES: int

# Index Group
INDEXGROUP_MEMORYBYTE: int
INDEXGROUP_MEMORYBIT: int
INDEXGROUP_MEMORYSIZE: int
INDEXGROUP_RETAIN: int
INDEXGROUP_RETAINSIZE: int
INDEXGROUP_DATA: int
INDEXGROUP_DATASIZE: int

ADSIGRP_SYMTAB: int
ADSIGRP_SYMNAME: int
ADSIGRP_SYMVAL: int
ADSIGRP_SYM_HNDBYNAME: int
ADSIGRP_SYM_VALBYNAME: int
ADSIGRP_SYM_VALBYHND: int
ADSIGRP_SYM_RELEASEHND: int
ADSIGRP_SYM_INFOBYNAME: int
ADSIGRP_SYM_VERSION: int
ADSIGRP_SYM_INFOBYNAMEEX: int
ADSIGRP_SYM_DOWNLOAD: int
ADSIGRP_SYM_UPLOAD: int
ADSIGRP_SYM_UPLOADINFO: int
ADSIGRP_SYM_DOWNLOAD2: int
ADSIGRP_SYM_DT_UPLOAD: int
ADSIGRP_SYM_UPLOADINFO2: int
ADSIGRP_SYMNOTE: int
ADSIGRP_IOIMAGE_RWIB: int
ADSIGRP_IOIMAGE_RWIX: int
ADSIGRP_IOIMAGE_RWOB: int
ADSIGRP_IOIMAGE_RWOX: int
ADSIGRP_IOIMAGE_CLEARI: int
ADSIGRP_IOIMAGE_CLEARO: int
ADSIGRP_SUMUP_READ: int
ADSIGRP_SUMUP_WRITE: int
ADSIGRP_DEVICE_DATA: int
ADSIOFFS_DEVDATA_ADSSTATE: int
ADSIOFFS_DEVDATA_DEVSTATE: int

# Ports
PORT_LOGGER: int
PORT_EVENTLOGGER: int
PORT_REALTIME_CORE: int
PORT_IO: int
PORT_SPECIALTASK1: int
PORT_SPECIALTASK2: int
PORT_NC: int
PORT_SPS1: int
PORT_SPS2: int
PORT_SPS3: int
PORT_SPS4: int
PORT_TC2PLC1: int
PORT_TC2PLC2: int
PORT_TC2PLC3: int
PORT_TC2PLC4: int
PORT_TC3PLC1: int
PORT_TC3PLC2: int
PORT_TC3PLC3: int
PORT_TC3PLC4: int
PORT_NOCKE: int
PORT_CAM: int
PORT_SYSTEMSERVICE: int
PORT_SCOPE: int
PORT_REMOTE_UDP: int

# ADS state constants
ADSSTATE_INVALID: int
ADSSTATE_IDLE: int
ADSSTATE_RESET: int
ADSSTATE_INIT: int
ADSSTATE_START: int
ADSSTATE_RUN: int
ADSSTATE_STOP: int
ADSSTATE_SAVECFG: int
ADSSTATE_LOADCFG: int
ADSSTATE_POWERFAILURE: int
ADSSTATE_POWERGOOD: int
ADSSTATE_ERROR: int
ADSSTATE_SHUTDOWN: int
ADSSTATE_SUSPEND: int
ADSSTATE_RESUME: int
ADSSTATE_CONFIG: int
ADSSTATE_RECONFIG: int

# ADS notification transmode
ADSTRANS_NOTRANS: int
ADSTRANS_CLIENTCYCLE: int
ADSTRANS_CLIENT1REQ: int
ADSTRANS_SERVERCYCLE: int
ADSTRANS_SERVERONCHA: int

# Symbol flags
ADSSYMBOLFLAG_PERSISTENT: int
ADSSYMBOLFLAG_BITVALUE: int
ADSSYMBOLFLAG_REFERENCETO: int
ADSSYMBOLFLAG_TYPEGUID: int
ADSSYMBOLFLAG_TCCOMIFACEPTR: int
ADSSYMBOLFLAG_READONLY: int
ADSSYMBOLFLAG_CONTEXTMASK: int

# ADS command IDs
ADSCOMMAND_INVALID: int
ADSCOMMAND_READDEVICEINFO: int
ADSCOMMAND_READ: int
ADSCOMMAND_WRITE: int
ADSCOMMAND_READSTATE: int
ADSCOMMAND_WRITECTRL: int
ADSCOMMAND_ADDDEVICENOTE: int
ADSCOMMAND_DELDEVICENOTE: int
ADSCOMMAND_DEVICENOTE: int
ADSCOMMAND_READWRITE: int

# ADS state flags
ADSSTATEFLAG_REQRESP: int
ADSSTATEFLAG_COMMAND: int


def __getattr__(name: str) -> Any: ...
