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.
104 lines
2.3 KiB
C#
104 lines
2.3 KiB
C#
using Rs.Framework;
|
|
using Rs.MotionPlat.Commom;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace Rs.MotionPlat.Flow
|
|
{
|
|
public class BaseFlow
|
|
{
|
|
public string FlowName { get; set; }
|
|
protected bool b_IsRun = false;
|
|
protected bool b_IsStop = true;
|
|
private Task mainTask;
|
|
protected string logInfo = "";
|
|
protected string alarmInfo = "";
|
|
protected int stopWaitTime = 10;
|
|
protected int sleepTime = 1;
|
|
protected SchedulingMessageBox msgBox;
|
|
public BaseFlow() {
|
|
mainTask = new Task(task);
|
|
}
|
|
|
|
|
|
public virtual void Run()
|
|
{
|
|
|
|
}
|
|
private void task() {
|
|
while (b_IsRun)
|
|
{
|
|
if(b_IsStop)
|
|
{
|
|
Thread.Sleep(stopWaitTime);
|
|
continue;
|
|
}
|
|
Run();
|
|
Thread.Sleep(sleepTime);
|
|
}
|
|
}
|
|
|
|
public virtual void Stop()
|
|
{
|
|
b_IsStop = true;
|
|
}
|
|
|
|
public virtual void Quit()
|
|
{
|
|
if(mainTask!=null)
|
|
{
|
|
b_IsRun = false;
|
|
mainTask.Wait();
|
|
}
|
|
}
|
|
|
|
public virtual void Start()
|
|
{
|
|
if(b_IsRun)
|
|
{
|
|
b_IsStop = false;
|
|
}
|
|
else
|
|
{
|
|
b_IsRun = true;
|
|
b_IsStop = false;
|
|
mainTask.Start();
|
|
}
|
|
//if(mainTask!=null && (mainTask.Status== TaskStatus.Created || mainTask.Status== TaskStatus.WaitingToRun))
|
|
//{
|
|
|
|
//}
|
|
//else if(mainTask.Status== TaskStatus.Running)
|
|
//{
|
|
|
|
//}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 如果是虚拟轴,则模拟等待一下
|
|
/// </summary>
|
|
public void VirtualAxisSleep()
|
|
{
|
|
if (GlobalVar.VirtualAxis)
|
|
{
|
|
Thread.Sleep(GlobalVar.VirtualAxisMoveTime);
|
|
}
|
|
}
|
|
|
|
public string GetClassName()
|
|
{
|
|
return this.GetType().Name + "-";
|
|
}
|
|
|
|
public bool IsRunning()
|
|
{
|
|
return b_IsRun;
|
|
}
|
|
}
|
|
}
|