Added axes position (first implementatio only for demo)

This commit is contained in:
Lucio Maranta
2018-07-17 15:56:08 +02:00
parent 62d3744e42
commit ab1701b00b
7 changed files with 94 additions and 2 deletions
Binary file not shown.
+45
View File
@@ -395,6 +395,51 @@ public static class ThreadsFunctions
}
}
public static void ReadAxesPositionsData()
{
NcHandler ncHandler = new NcHandler();
Stopwatch sw = new Stopwatch();
try
{
// Try connection
CmsError libraryError = ncHandler.Connect();
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
while (true)
{
sw.Restart();
if (ncHandler.numericalControl.NC_IsConnected())
{
// Get Data from NC
libraryError = ncHandler.GetAxesPositionsBySelectedProcess(out DTOAxesModel axesPositions);
if (libraryError.errorCode != 0)
ManageLibraryError(libraryError);
else
// Send through signalR
MessageServices.Current.Publish(SEND_AXES, null, axesPositions);
}
else
TryNcConnection();
sw.Stop();
//Update thread timer
ReadAxesTimer += sw.ElapsedMilliseconds;
ReadAxesTimes++;
// Wait
Thread.Sleep(CalcSleepTime(200, (int)sw.ElapsedMilliseconds));
}
}
catch (ThreadAbortException)
{
ncHandler.Dispose();
}
}
public static void ReadMagazinesStatus()
{
NcHandler ncHandler = new NcHandler();
+3 -1
View File
@@ -16,11 +16,13 @@ namespace Step.Core
ThreadsFunctions.ReadProcessesPPStatus,
ThreadsFunctions.ReadEnabledFunctionality,
ThreadsFunctions.ReadExpiredMaintenances,
// ThreadsFunctions.ReadNcSoftKeysData,
ThreadsFunctions.ReadAxesPositionsData,
ThreadsFunctions.ReadMagazinesStatus,
ThreadsFunctions.ReadUserSoftKeysData,
ThreadsFunctions.ReadHeadsData,
ThreadsFunctions.ReadAxesNamesData
// ThreadsFunctions.ReadNcSoftKeysData,
};
private volatile static List<Thread> RunningThreadsList = new List<Thread>();
+13 -1
View File
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Linq;
namespace Step.Model.DTOModels
{
@@ -31,7 +32,18 @@ namespace Step.Model.DTOModels
if (item == null)
return false;
return base.Equals(obj);
if (!interpolated.SequenceEqual(item.interpolated))
return false;
if (!machine.SequenceEqual(item.machine))
return false;
if (!programmePos.SequenceEqual(item.programmePos))
return false;
if (!toGo.SequenceEqual(item.toGo))
return false;
if (!followingErr.SequenceEqual(item.followingErr))
return false;
return true;
}
public override int GetHashCode()
+16
View File
@@ -233,6 +233,22 @@ namespace Step.NC
return cmsError;
}
public CmsError GetAxesPositionsBySelectedProcess(out DTOAxesModel axes)
{
axes = new DTOAxesModel();
// Get selectedProcess process number
ushort selectedProcess = 0;
CmsError cmsError = numericalControl.PROC_RSelectedProcess(ref selectedProcess);
if (cmsError.IsError())
return cmsError;
if(selectedProcess > 0)
cmsError = GetAxesPositionsByProcess(selectedProcess, out axes);
return cmsError;
}
public CmsError GetAxesPositionsByProcess(ushort processNum, out DTOAxesModel axes)
{
axes = new DTOAxesModel();
+5
View File
@@ -63,6 +63,11 @@ namespace Step.Listeners
{
SignalRListener.SendAxesNamesData(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_AXES, async (a, b) =>
{
SignalRListener.SendAxesToClient(a);
}));
infos.Add(MessageServices.Current.Subscribe(SEND_MAGAZINES_STATUS, async (a, b) =>
{
SignalRListener.SendMagazinesStatus(a);
+12
View File
@@ -21,6 +21,7 @@ namespace Step.Listeners.SignalR
private static List<DTOUserSoftKeyModel> LastUserSoftKeysData = new List<DTOUserSoftKeyModel>();
private static List<DTONcSoftKeyModel> LastNcSoftKeysData = new List<DTONcSoftKeyModel>();
private static List<DTOHeadModel> LastHeadsData = new List<DTOHeadModel>();
private static DTOAxesModel LastAxesPositions = new DTOAxesModel();
private static List<DTOAxisNameModel> LastAxesNamesData = new List<DTOAxisNameModel>();
private static DTOMagazineActionModel LastMagazineStatus = new DTOMagazineActionModel();
@@ -39,6 +40,17 @@ namespace Step.Listeners.SignalR
}
}
public static void SendAxesToClient(object newAxesData)
{
if (!LastAxesPositions.Equals(newAxesData))
{
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();
LastAxesPositions = newAxesData as DTOAxesModel;
context.Clients.Group("ncData").axesPositions(newAxesData);
}
}
public static void SendPowerOnDataToClient(object powerOnData)
{
var context = GlobalHost.ConnectionManager.GetHubContext<NcHub>();