5bd278fa69
* Added NC handler class * Fixed threads * Added threads: AXES, ALARMS, GENERIC INFO + API * Refactoring
58 lines
1.5 KiB
C#
58 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using CMS_CORE;
|
|
using CMS_CORE.Demo;
|
|
using CMS_CORE.Fanuc;
|
|
using CMS_CORE.Osai;
|
|
using CMS_CORE.Siemens;
|
|
using Step.NC;
|
|
using static Step.Config.StartupConfig;
|
|
using static Step.Utils.Constants;
|
|
|
|
namespace Step.Core
|
|
{
|
|
public static class ThreadsHandler
|
|
{
|
|
private static List<Action> ThreadFunctionsList = new List<Action>
|
|
{
|
|
ThreadsFunctions.ReadAlarmsAsync,
|
|
ThreadsFunctions.ReadNcGenericInfo,
|
|
ThreadsFunctions.ReadAxes
|
|
};
|
|
private static List<Thread> RunningThreadsList = new List<Thread>();
|
|
|
|
|
|
public static void Start()
|
|
{
|
|
// For each function run in the list a thread
|
|
ThreadFunctionsList.ForEach(threadFunction =>
|
|
{
|
|
// Run new Thread in the list
|
|
Thread t = new Thread(() =>
|
|
threadFunction()
|
|
);
|
|
|
|
t.Start();
|
|
// Add thread to running threads list
|
|
RunningThreadsList.Add(t);
|
|
});
|
|
}
|
|
|
|
public static void Stop()
|
|
{
|
|
// Stop each thread
|
|
RunningThreadsList.ForEach(thread =>
|
|
{
|
|
thread.Abort();
|
|
});
|
|
// No running status
|
|
RunningThreadsList.Clear();
|
|
}
|
|
}
|
|
}
|
|
|