init: 导入项目到 meswork Gitea
This commit is contained in:
@@ -0,0 +1,175 @@
|
||||
using ConLink.Enthernet;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace DTTest
|
||||
{
|
||||
public partial class ActControl
|
||||
{
|
||||
/// <summary>
|
||||
/// 是处于活跃状态
|
||||
/// 2021.3.31
|
||||
/// </summary>
|
||||
public bool isActive
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
/// <summary>
|
||||
/// 播放的指针
|
||||
/// </summary>
|
||||
private int indexPlay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = 0;
|
||||
/// <summary>
|
||||
/// 播放的状态
|
||||
/// </summary>
|
||||
private bool isPlay
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = false;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
private List<C_Frames> sendList
|
||||
{
|
||||
get;
|
||||
set;
|
||||
} = null;
|
||||
/// <summary>
|
||||
/// 2020-8-6
|
||||
/// </summary>
|
||||
public event Action<Int32, Int32, C_Frames> CurrRunInfoEvent;
|
||||
/// <summary>
|
||||
/// 2021.1.4
|
||||
/// 上午11.15
|
||||
/// </summary>
|
||||
public event Action PlayTaskEnd;
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
public Thread t_Play = null;
|
||||
|
||||
/// <summary>
|
||||
/// 构造函数
|
||||
/// </summary>
|
||||
/// <param name="clientLocal"></param>
|
||||
/// <param name="sendInterval"></param>
|
||||
public ActControl()
|
||||
{
|
||||
|
||||
}
|
||||
/// <summary>
|
||||
/// 播放序列
|
||||
/// </summary>
|
||||
/// <param name="sendList"></param>
|
||||
public ActControl PlayData(List<C_Frames> sendList)
|
||||
{
|
||||
this.sendList = sendList;
|
||||
|
||||
t_Play = new Thread(new ParameterizedThreadStart(PlayData));
|
||||
t_Play.IsBackground = true;
|
||||
t_Play.Name = "123";
|
||||
t_Play.Start(sendList);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
private void PlayData(object obj)
|
||||
{
|
||||
var frams = (List<C_Frames>)obj;
|
||||
|
||||
while (indexPlay <= sendList.Count - 1)
|
||||
{
|
||||
if (isPlay)
|
||||
{
|
||||
var frame = frams[indexPlay];
|
||||
indexPlay++;
|
||||
CurrRunInfoEvent?.Invoke(indexPlay, sendList.Count, frame);
|
||||
}
|
||||
Thread.Sleep(PP.PCP.SendInterval);
|
||||
}
|
||||
|
||||
isPlay = false;
|
||||
isActive = false;
|
||||
indexPlay = 0;
|
||||
PlayTaskEnd?.Invoke();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 返回播放状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool PlayState()
|
||||
{
|
||||
return isPlay;
|
||||
}
|
||||
/// <summary>
|
||||
/// 返回活跃状态
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public bool ActiveState()
|
||||
{
|
||||
return isActive;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 播放
|
||||
/// </summary>
|
||||
public ActControl Play()
|
||||
{
|
||||
isActive = true;
|
||||
isPlay = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 暂停
|
||||
/// </summary>
|
||||
public ActControl Suspend()
|
||||
{
|
||||
isPlay = false;
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 终了
|
||||
/// </summary>
|
||||
public ActControl End()
|
||||
{
|
||||
if (t_Play != null)
|
||||
{
|
||||
t_Play.Abort();
|
||||
}
|
||||
isPlay = false;
|
||||
isActive = false;
|
||||
indexPlay = 0;
|
||||
PlayTaskEnd?.Invoke();
|
||||
return this;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
public ActControl SetIndex(int index)
|
||||
{
|
||||
indexPlay = index;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user