#!D:\IDE\Anaconda3\envs\Microscope_Scan python
# -*- coding: UTF-8 -*-
"""
 @Author: Administrator
 @FileName: SocketContext.py
 @DateTime: 2025/4/8 19:50
 @SoftWare: PyCharm
 @Author  ：xsh
"""
import sys
from PyQt5                              import Qt
from AppInterfaces.ModelInterface       import ContextModelInterface
from AppCore.Levels                     import *
from AppUtils.utils                     import *
from AppCore.Requests                   import *

class SocketContext(ContextModelInterface):
    __slots__ = ('Addr'  , 'Port'  , 'IsOpen')
    __types__ = (str, int, bool)
    Addr    : str
    Port    : int
    IsOpen  : bool
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.initialization("网络连接上下文")


    def initValue(self):
        super(SocketContext, self).initValue()
        self.Addr        = "192.168.10.251"
        self.Port        = 9991
        self.IsOpen      = False

    def initParameter(self, **args):
        super(SocketContext, self).initParameter(**args)
        if not isinstance(args, dict) or len(args) <= 0:
            return
        for index, _property in enumerate(self.__slots__):
            setattr(self, _property, AppConvert.ObjectConvert(args.get(_property, getattr(self, _property, None)), self.__types__[index]))
