Beispiel #1
0
        public CCTimer(ITagOp tagOp, string tagName,
                       string outTagName, int onLast = 1000,
                       string offOutTagName          = "", int offLast = 1000)
            : base(tagName)
        {
            TagOp     = tagOp;
            OnLastMs  = onLast;
            OffLastMs = offLast;
            Func <bool?> check = () => {
                if (tagOp != null)
                {
                    return(tagOp.ReadBit(tagName));
                }
                else
                {
                    return(null);
                }
            };

            Name      = $"{tagName}-{outTagName}:{onLast}-{offOutTagName}:{offLast}";
            CheckFunc = check;
            OnLastMs  = onLast;
            OffLastMs = offLast;

            ThreadStart = new ControlledThreadStart(RunCheck);

            ThreadController = new ThreadController(ThreadStart, null, Name);

            StartThread();

            OutTag         = outTagName;
            OffOutTag      = offOutTagName;
            OutChanged    += Task_OutChanged;
            OffOutChanged += Task_OffOutChanged;
        }
Beispiel #2
0
 /// <summary>
 /// Creates a new controller.
 /// </summary>
 /// <param name="starter">The delegate to invoke when the thread is started.
 /// Must not be null.</param>
 /// <param name="state">The state to pass to the delegate. May be null.</param>
 public ThreadController(ControlledThreadStart starter, object state)
 {
     if (starter == null)
     {
         throw new ArgumentNullException("starter");
     }
     this.starter = starter;
     this.state   = state;
 }
 /// <summary>
 /// Creates a new controller.
 /// </summary>
 /// <param name="starter">The delegate to invoke when the thread is started.
 /// Must not be null.</param>
 /// <param name="state">The state to pass to the delegate. May be null.</param>
 public ThreadController(ControlledThreadStart starter, object state)
 {
     if (starter==null)
     {
         throw new ArgumentNullException("starter");
     }
     this.starter = starter;
     this.state = state;
 }
        public void InitR()
        {
            Engine = Python.CreateEngine();
            Scope  = Engine.CreateScope();
            ICollection <string> sps = Engine.GetSearchPaths();

            sps.Add(@"D:\Program Files (x86)\Siemens\Automation\WinCC RT Advanced\IRONPYTHON");
            Engine.SetSearchPaths(sps);

            ThreadStart = new ControlledThreadStart(RunPY);

            ThreadController = new ThreadController(ThreadStart, null, Name);
        }
Beispiel #5
0
        /// <summary>
        /// 计时器
        /// </summary>
        /// <param name="name">名称</param>
        /// <param name="check">检查方法</param>
        /// <param name="lastMs">持续时间</param>
        /// <param name="offLast">反扶持时间</param>
        public YZXTimerTask(string name, Func <bool?> check, int lastMs = 1000, int offLast = 1000)
        {
            Name      = name;
            CheckFunc = check;
            OnLastMs  = lastMs;
            OffLastMs = offLast;

            ThreadStart = new ControlledThreadStart(RunCheck);

            ThreadController = new ThreadController(ThreadStart, null, Name);

            StartThread();
        }
Beispiel #6
0
 /// <summary>
 /// Creates a new controller without specifying a state object to
 /// pass when the delegate is invoked.
 /// </summary>
 /// <param name="starter">The delegate to invoke when the thread is started.</param>
 public ThreadController(ControlledThreadStart starter) : this(starter, null)
 {
 }
		/// <summary>
		/// Creates a new controller without specifying a state object to
		/// pass when the delegate is invoked.
		/// </summary>
		/// <param name="starter">The delegate to invoke when the thread is started.</param>
		public ThreadController(ControlledThreadStart starter) : this (starter, null)
		{
		}
 /// <summary>
 /// Creates a new controller.
 /// </summary>
 /// <param name="starter">
 /// The delegate to invoke when the thread is started.
 /// Must not be null.
 /// </param>
 /// <param name="state">The state to pass to the delegate. May be null.</param>
 public ThreadController([NotNull] ControlledThreadStart starter, object state)
 {
     _starter = starter ?? throw new ArgumentNullException(nameof(starter));
     _state   = state;
 }