示例#1
0
        protected ModbusPoll modbusPoll;   // implements device polling


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DevModbusLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
            : base(commContext, lineContext, deviceConfig)
        {
            transMode   = TransMode.RTU;
            deviceModel = null;
            modbusPoll  = null;
        }
示例#2
0
        private Connection connection;    // the device connection


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DeviceLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
        {
            CommContext    = commContext ?? throw new ArgumentNullException(nameof(commContext));
            LineContext    = lineContext ?? throw new ArgumentNullException(nameof(lineContext));
            DeviceConfig   = deviceConfig ?? throw new ArgumentNullException(nameof(deviceConfig));
            AppDirs        = commContext.AppDirs;
            Log            = lineContext.LineConfig.LineOptions.DetailedLog ? lineContext.Log : new LogStub();
            LastRequestOK  = false;
            IsBound        = lineContext.LineConfig.IsBound && deviceConfig.IsBound;
            DeviceNum      = deviceConfig.DeviceNum;
            Title          = CommUtils.GetDeviceTitle(DeviceNum, deviceConfig.Name);
            NumAddress     = deviceConfig.NumAddress;
            StrAddress     = deviceConfig.StrAddress;
            PollingOptions = deviceConfig.PollingOptions;
            ReqRetries     = lineContext.LineConfig.LineOptions.ReqRetries;

            CanSendCommands    = false;
            ConnectionRequired = false;
            LastSessionTime    = DateTime.MinValue;
            LastCommandTime    = DateTime.MinValue;
            DeviceTags         = new DeviceTags();
            DeviceData         = new DeviceData();

            terminated = false;
            connection = null;
        }
示例#3
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public ChannelLogic(ILineContext lineContext, ChannelConfig channelConfig)
 {
     LineContext   = lineContext ?? throw new ArgumentNullException(nameof(lineContext));
     ChannelConfig = channelConfig ?? throw new ArgumentNullException(nameof(channelConfig));
     Log           = lineContext.Log;
     Title         = channelConfig.TypeName;
 }
示例#4
0
        private int lastInfoLength;       // the last info text length


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DeviceLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
        {
            CommContext  = commContext ?? throw new ArgumentNullException(nameof(commContext));
            LineContext  = lineContext ?? throw new ArgumentNullException(nameof(lineContext));
            DeviceConfig = deviceConfig ?? throw new ArgumentNullException(nameof(deviceConfig));
            AppDirs      = commContext.AppDirs;
            Log          = lineContext.LineConfig.LineOptions.DetailedLog ? lineContext.Log : LogStub.Instance;
            AssemblyName asmName = GetType().Assembly.GetName();

            DriverName         = ScadaUtils.RemoveFileNameSuffixes(asmName.Name) + " " + asmName.Version;
            LastRequestOK      = false;
            ReqRetries         = lineContext.LineConfig.LineOptions.ReqRetries;
            IsBound            = lineContext.LineConfig.IsBound && deviceConfig.IsBound;
            DeviceNum          = deviceConfig.DeviceNum;
            Title              = CommUtils.GetDeviceTitle(DeviceNum, deviceConfig.Name);
            NumAddress         = deviceConfig.NumAddress;
            StrAddress         = deviceConfig.StrAddress;
            PollingOptions     = deviceConfig.PollingOptions;
            CanSendCommands    = false;
            ConnectionRequired = false;
            DeviceStatus       = DeviceStatus.Undefined;
            LastSessionTime    = DateTime.MinValue;
            LastCommandTime    = DateTime.MinValue;
            DeviceTags         = new DeviceTags();
            DeviceData         = new DeviceData(deviceConfig.DeviceNum);
            DeviceStats        = new DeviceStats();

            terminated     = false;
            connection     = null;
            lastInfoLength = 0;
        }
 public ParameterDeclaration(ILineContext context, ASTType type, string internalName, string externalName) : base(context)
 {
     Type = type;
     InternalName = internalName;
     ExternalName = externalName;
     DefaultValue = null;
     InOut = false;
     NoConstant = false;
 }
示例#6
0
        protected volatile bool terminated;                 // necessary to stop the thread


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public SerialChannelLogic(ILineContext lineContext, ChannelConfig channelConfig)
            : base(lineContext, channelConfig)
        {
            options     = new SerialChannelOptions(channelConfig.CustomOptions);
            requestArgs = new IncomingRequestArgs();

            serialConn = null;
            thread     = null;
            terminated = false;
        }
示例#7
0
        /// <summary>
        /// Creates a new communication channel.
        /// </summary>
        public override ChannelLogic CreateChannel(ILineContext lineContext, ChannelConfig channelConfig)
        {
            switch (channelConfig.TypeName)
            {
            case ChannelTypeName.Serial:
                return(new SerialChannelLogic(lineContext, channelConfig));

            default:
                return(null);
            }
        }
示例#8
0
        protected volatile bool terminated;                 // necessary to stop the thread


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public TcpClientChannel(ILineContext lineContext, ChannelConfig channelConfig)
            : base(lineContext, channelConfig)
        {
            options = new TcpClientChannelOptions(channelConfig.CustomOptions);

            indivConnList = null;
            sharedConn    = null;
            currentConn   = null;
            thread        = null;
            terminated    = false;
        }
示例#9
0
        private readonly TextStopCondition textStopCond; // the stop condition for reading text


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DevTesterLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
            : base(commContext, lineContext, deviceConfig)
        {
            options      = new TesterOptions(deviceConfig.PollingOptions.CustomOptions);
            inBuf        = new byte[options.BufferLength];
            binStopCond  = options.BinStopCode > 0 ? new BinStopCondition(options.BinStopCode) : null;
            textStopCond = string.IsNullOrEmpty(options.StopEnding) ?
                           TextStopCondition.OneLine : new TextStopCondition(options.StopEnding);

            CanSendCommands = true;
        }
示例#10
0
        protected volatile bool terminated;                 // necessary to stop receiving data


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public UdpChannelLogic(ILineContext lineContext, ChannelConfig channelConfig)
            : base(lineContext, channelConfig)
        {
            options     = new UdpChannelOptions(channelConfig.CustomOptions);
            requestArgs = new IncomingRequestArgs();
            deviceLock  = new object();

            masterConn = null;
            slaveConn  = null;
            deviceDict = null;
            terminated = false;
        }
示例#11
0
        private bool loggingFlag;                  // indicates that a ready message should be logged


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DevEmailLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
            : base(commContext, lineContext, deviceConfig)
        {
            CanSendCommands    = true;
            ConnectionRequired = false;

            config      = new EmailDeviceConfig();
            smtpClient  = new SmtpClient();
            addressBook = null;
            isReady     = false;
            loggingFlag = false;
        }
 public ParameterDeclaration(ILineContext context, ASTType type, string name, bool sameInternalExternalName) : base(context)
 {
     Type = type;
     InternalName = name;
     if (sameInternalExternalName)
         ExternalName = name;
     else
         ExternalName = null;
     DefaultValue = null;
     InOut = false;
     NoConstant = false;
 }
示例#13
0
        protected volatile bool terminated;                 // necessary to stop the thread


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public TcpServerChannel(ILineContext lineContext, ChannelConfig channelConfig)
            : base(lineContext, channelConfig)
        {
            options     = new TcpServerChannelOptions(channelConfig.CustomOptions);
            requestArgs = new IncomingRequestArgs();
            inBuf       = new byte[InBufferLenght];
            connList    = new List <TcpConnection>();

            tcpListener = null;
            currentConn = null;
            deviceDict  = null;
            thread      = null;
            terminated  = false;
        }
示例#14
0
        private bool loggingFlag;                  // indicates that a ready message should be logged


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DevHttpNotifLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
            : base(commContext, lineContext, deviceConfig)
        {
            CanSendCommands    = true;
            ConnectionRequired = false;

            stopwatch    = new Stopwatch();
            config       = new NotifDeviceConfig();
            addressBook  = null;
            paramUri     = null;
            paramContent = null;
            httpClient   = null;
            isReady      = false;
            loggingFlag  = false;
        }
示例#15
0
        private Dictionary <string, CommandConfig> cmdByCode;  // the commands accessed by code


        /// <summary>
        /// Initializes a new instance of the class.
        /// </summary>
        public DevOpcUaLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
            : base(commContext, lineContext, deviceConfig)
        {
            opcLock          = new object();
            opcDeviceConfig  = null;
            connected        = false;
            connAttemptDT    = DateTime.MinValue;
            opcSession       = null;
            reconnectHandler = null;
            subscrByID       = null;
            cmdByNum         = null;
            cmdByCode        = null;

            CanSendCommands    = true;
            ConnectionRequired = false;
        }
示例#16
0
        /// <summary>
        /// Creates a new communication channel.
        /// </summary>
        public override ChannelLogic CreateChannel(ILineContext lineContext, ChannelConfig channelConfig)
        {
            switch (channelConfig.TypeCode)
            {
            case ChannelTypeCode.SerialPort:
                return(new SerialPortChannelLogic(lineContext, channelConfig));

            case ChannelTypeCode.TcpClient:
                return(new TcpClientChannelLogic(lineContext, channelConfig));

            case ChannelTypeCode.TcpServer:
                return(new TcpServerChannelLogic(lineContext, channelConfig));

            case ChannelTypeCode.Udp:
                return(new UdpChannelLogic(lineContext, channelConfig));

            default:
                return(null);
            }
        }
示例#17
0
 public HexaLiteral(ILineContext context, string value) : base(context, value)
 {
 }
示例#18
0
 /// <summary>
 /// Creates a new device.
 /// </summary>
 public virtual DeviceLogic CreateDevice(ILineContext lineContext, DeviceConfig deviceConfig)
 {
     return(null);
 }
示例#19
0
 public TupleElement(ILineContext context, ASTType type, string name) : base(context)
 {
     Type = type;
     Name = name;
 }
示例#20
0
 public BitwiseNotExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
示例#21
0
 public StringElement(ILineContext context, string quotedTextItem) : base(context)
 {
     ElementType = Global.ElementTypes.quotedTextItem;
     QuotedTextItem = quotedTextItem;
 }
示例#22
0
 public OctalLiteral(ILineContext context, string value) : base(context, value)
 {
 }
示例#23
0
 public OrExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
示例#24
0
 public Literal(ILineContext context, string value) : base(context)
 {
     Value = value;
 }
 public FunctionCallExp(ILineContext context) : base(context)
 {
     Args = new List<ParameterCall>();
 }
示例#26
0
 public BinaryLiteral(ILineContext context, string value) : base(context, value)
 {
 }
示例#27
0
 public Literal(ILineContext context) : base(context)
 {
 }
 public IncompatibleTypesException(ILineContext context, string message = "the types of the left-hand and right-hand side of the assignment don't match") : base(context, message) { }
示例#29
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public DevSimulatorLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
     : base(commContext, lineContext, deviceConfig)
 {
     CanSendCommands = true;
 }
 public ConstantReassignmentException(ILineContext context, string message = "the value of constants cannot be changed") : base(context, message) { }
示例#31
0
 public StringLiteral(ILineContext context) : base(context)
 {
     Elements = new List<IStringElement>();
 }
示例#32
0
 /// <summary>
 /// Creates a new device.
 /// </summary>
 public override DeviceLogic CreateDevice(ILineContext lineContext, DeviceConfig deviceConfig)
 {
     return(new DevOpcUaLogic(CommContext, lineContext, deviceConfig));
 }
示例#33
0
 public TupleElement(ILineContext context, ASTType type) : base(context)
 {
     Type = type;
     Name = null;
 }
 public ExclamationExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
示例#35
0
 /// <summary>
 /// Creates a new communication channel.
 /// </summary>
 public virtual ChannelLogic CreateChannel(ILineContext lineContext, ChannelConfig channelConfig)
 {
     return(null);
 }
 public MultiplicationExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
示例#37
0
 public UInt16Literal(ILineContext context, string value) : base(context, value)
 {
 }
示例#38
0
 public FloatLiteral(ILineContext context, string value) : base(context, value)
 {
 }
示例#39
0
 public Int32Literal(ILineContext context, string value) : base(context, value)
 {
 }
示例#40
0
 public DivisionExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
 public VarDeclaration(ILineContext context) : base(context)
 {
 }
示例#42
0
 public StringElement(ILineContext context, Exp expression) : base(context)
 {
     ElementType = Global.ElementTypes.interpolation;
     Expression = expression;
 }
示例#43
0
 /// <summary>
 /// Creates a new communication channel.
 /// </summary>
 public override ChannelLogic CreateChannel(ILineContext lineContext, ChannelConfig channelConfig)
 {
     return(channelConfig.TypeCode == "MqttClient"
         ? new MqttClientChannelLogic(lineContext, channelConfig)
         : null);
 }
 public ConstDeclaration(ILineContext context, Exp RHS) : base(context)
 {
     this.RHS = RHS;
 }
 public AssignmentUnknownVariable(ILineContext context, string message = "assignment to unknown variable") : base(context, message) { }
示例#46
0
 public StringElement(ILineContext context, Global.EscapedCharacter escapedCharacter) : base(context)
 {
     ElementType = Global.ElementTypes.escapedCharacter;
     EscapedCharacter = escapedCharacter;
 }
 public OverflowSubExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
示例#48
0
 public ModuloExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
 public BitwiseRightShiftExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
示例#50
0
 /// <summary>
 /// Initializes a new instance of the class.
 /// </summary>
 public DevSimulatorLogic(ICommContext commContext, ILineContext lineContext, DeviceConfig deviceConfig)
     : base(commContext, lineContext, deviceConfig)
 {
     CanSendCommands    = true;
     ConnectionRequired = false;
 }