You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/Actions/ChemicalWeighing/Mesnac.Action.ChemicalWeighing/Test/TestAction.cs

65 lines
1.7 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using DataBlockHelper.DBHelpers;
using DevExpress.Utils.Extensions;
using ICSharpCode.Core;
using Mesnac.Action.Base;
using Mesnac.Action.ChemicalWeighing.Report;
using Mesnac.Action.ChemicalWeighing.SetValueInfo;
using Mesnac.Controls.ChemicalWeighing;
using Mesnac.Controls.Default;
namespace Mesnac.Action.ChemicalWeighing.Test
{
public class TestAction : DatabaseAction, IAction
{
MCButton mCButton;
// LoggingService<TestAction> _log;
HslMoveText hslMove;
public void theout(object source, EventArgs e)
{
LoggingService<TestAction>.InfoFormatted("定时器运行");
}
public void Run(RuntimeParameter runtime)
{
base.RunIni(runtime); //必须调用
var allDb = GetAllControls();
mCButton = allDb.FirstOrDefault(x => x.Name == "MCButton1") as MCButton;
hslMove = allDb.FirstOrDefault(x => x.Name == "HslMoveText1") as HslMoveText;
mCButton.Click += MCButton_Click;
System.Timers.Timer t = new System.Timers.Timer(1000*5);//实例化Timer类设置间隔时间为10000毫秒
t.Elapsed += new System.Timers.ElapsedEventHandler(theout);//到达时间的时候执行事件;
t.AutoReset = true;//设置是执行一次false还是一直执行(true)
t.Enabled = true;//是否执行System.Timers.Timer.Elapsed事件
}
private void MCButton_Click(object sender, EventArgs e)
{
}
}
}