예제 #1
0
        private IPlcMonitorWork AddPlcMonitorWork <TValue>()
        {
            IPlcMonitorWork plcMonitorWork = GetPlcMonitorWork <TValue>();

            if (plcMonitorWork == null)
            {
                plcMonitorWork = new PlcMonitorWork <TValue>(Plc, loggerFactory);

                plcMonitorWorks.Add(plcMonitorWork);
            }

            return(plcMonitorWork);
        }
예제 #2
0
        public void Register <TEvent>(TEvent @event, Action <TEvent> callback)
            where TEvent : EventBase, IEvent, new()
        {
            IPlcMonitorWork plcMonitorWork = null;

            if (@event.ValueType == typeof(bool))
            {
                plcMonitorWork = AddPlcMonitorWork <bool>();
            }
            else if (@event.ValueType == typeof(short))
            {
                plcMonitorWork = AddPlcMonitorWork <short>();
            }
            else if (@event.ValueType == typeof(ushort))
            {
                plcMonitorWork = AddPlcMonitorWork <ushort>();
            }
            else if (@event.ValueType == typeof(int))
            {
                plcMonitorWork = AddPlcMonitorWork <int>();
            }
            else if (@event.ValueType == typeof(float))
            {
                plcMonitorWork = AddPlcMonitorWork <float>();
            }
            else if (@event.ValueType == typeof(string))
            {
                plcMonitorWork = AddPlcMonitorWork <string>();
            }
            else
            {
                throw new NotImplementedException();
            }

            plcMonitorWork.Register(@event, callback);
        }