97 lines
2.7 KiB
C#
97 lines
2.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using IniFiles;
|
|
|
|
namespace SCMCncLib
|
|
{
|
|
public enum NC_DEVICE_TYPE { VIRTUAL = 1, NUM_10x0, OSAI_510, ESAGV_KVARA, FILE_DEVICE };
|
|
|
|
/// <summary>
|
|
/// Base class for devices
|
|
/// </summary>
|
|
public class thdNcBase
|
|
{
|
|
|
|
// !!! 2016.05.25 commentato e riscritto perchè NON C'E' la parte form, è DLL comunicazione...
|
|
#if false
|
|
protected XSimMainWindow m_form; // link to main window
|
|
protected MWEngine mwEngine; // link to graphic engine
|
|
#endif // false
|
|
public bool Connected = false;
|
|
protected bool requestStop = false;
|
|
protected int PlcDelay;
|
|
|
|
public bool Finished = false; // this flag will be true when execution is stopped (after a RequestStop)
|
|
|
|
public string DeviceName = ""; // name of the device (just for display purpose)
|
|
public NC_DEVICE_TYPE DeviceType = 0; // store type of device if needed
|
|
|
|
|
|
// !!! 2016.05.25 commentato e riscritto perchè NON C'E' la parte form, è DLL comunicazione...
|
|
#if false
|
|
/// <summary>
|
|
/// Initialization: common operations for all devices.
|
|
/// </summary>
|
|
/// <param name="e">The e.</param>
|
|
/// <param name="fIni">The f ini.</param>
|
|
/// <param name="form">The form.</param>
|
|
public thdNcBase(MWEngine e, IniFile fIni, XSimMainWindow form)
|
|
{
|
|
// store main form
|
|
m_form = form;
|
|
// store link to graphic manager
|
|
mwEngine = e;
|
|
// set delay for execution cycle
|
|
PlcDelay = fIni.ReadInteger("NC", "PlcDelay", 10);
|
|
}
|
|
#endif // false
|
|
|
|
/// <summary>
|
|
/// Initialization: common operations for all devices.
|
|
/// </summary>
|
|
/// <param name="fIni">The f ini.</param>
|
|
public thdNcBase(IniFile fIni)
|
|
{
|
|
// set delay for execution cycle
|
|
PlcDelay = fIni.ReadInteger("NC", "PlcDelay", 10);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Initialize read and write buffers of memory manager
|
|
/// </summary>
|
|
public void CreateBuffers()
|
|
{
|
|
#if false
|
|
mwEngine.MemoryManager.InitializeMemories();
|
|
#endif
|
|
}
|
|
|
|
/// <summary>
|
|
/// Request to stop the thread
|
|
/// </summary>
|
|
public void RequestStop()
|
|
{
|
|
requestStop = true;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Virtual method for thread main execution
|
|
/// </summary>
|
|
public virtual void Execute() {}
|
|
|
|
/// <summary>
|
|
/// Call main form function to display actual connection status
|
|
/// </summary>
|
|
protected void WriteConnectionStatus()
|
|
{
|
|
// !!! 2016.05.25 commentato e riscritto perchè NON C'E' la parte form, è DLL comunicazione...
|
|
#if false
|
|
XSimMainWindow.Instance.Dispatcher.BeginInvoke(new Action(() => m_form.SetConnectionState(Connected)));
|
|
#endif // false
|
|
}
|
|
|
|
}
|
|
}
|