Exemple #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;
        }
Exemple #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;
        }
Exemple #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;
 }
        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;
 }
        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;
        }
Exemple #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);
            }
        }
Exemple #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;
        }
        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;
        }
        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;
        }
Exemple #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;
 }
Exemple #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;
        }
        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;
        }
Exemple #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;
        }
        /// <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);
            }
        }
 public HexaLiteral(ILineContext context, string value) : base(context, value)
 {
 }
Exemple #18
0
 /// <summary>
 /// Creates a new device.
 /// </summary>
 public virtual DeviceLogic CreateDevice(ILineContext lineContext, DeviceConfig deviceConfig)
 {
     return(null);
 }
 public TupleElement(ILineContext context, ASTType type, string name) : base(context)
 {
     Type = type;
     Name = name;
 }
 public BitwiseNotExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
 public StringElement(ILineContext context, string quotedTextItem) : base(context)
 {
     ElementType = Global.ElementTypes.quotedTextItem;
     QuotedTextItem = quotedTextItem;
 }
 public OctalLiteral(ILineContext context, string value) : base(context, value)
 {
 }
Exemple #23
0
 public OrExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
Exemple #24
0
 public Literal(ILineContext context, string value) : base(context)
 {
     Value = value;
 }
 public FunctionCallExp(ILineContext context) : base(context)
 {
     Args = new List<ParameterCall>();
 }
 public BinaryLiteral(ILineContext context, string value) : base(context, value)
 {
 }
Exemple #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) { }
Exemple #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) { }
 public StringLiteral(ILineContext context) : base(context)
 {
     Elements = new List<IStringElement>();
 }
Exemple #32
0
 /// <summary>
 /// Creates a new device.
 /// </summary>
 public override DeviceLogic CreateDevice(ILineContext lineContext, DeviceConfig deviceConfig)
 {
     return(new DevOpcUaLogic(CommContext, lineContext, deviceConfig));
 }
 public TupleElement(ILineContext context, ASTType type) : base(context)
 {
     Type = type;
     Name = null;
 }
 public ExclamationExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
Exemple #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)
 {
 }
 public UInt16Literal(ILineContext context, string value) : base(context, value)
 {
 }
 public FloatLiteral(ILineContext context, string value) : base(context, value)
 {
 }
 public Int32Literal(ILineContext context, string value) : base(context, value)
 {
 }
 public DivisionExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
 public VarDeclaration(ILineContext context) : base(context)
 {
 }
 public StringElement(ILineContext context, Exp expression) : base(context)
 {
     ElementType = Global.ElementTypes.interpolation;
     Expression = expression;
 }
Exemple #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) { }
 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)
 {
 }
 public ModuloExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
 public BitwiseRightShiftExp(ILineContext context, Exp e1, Exp e2) : base(context, e1, e2)
 {
 }
Exemple #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;
 }