using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Net.NetworkInformation;
using System.Threading;
using TwinCAT;
using TwinCAT.Ads;
using TwinCAT.Ads.TypeSystem;
using System.IO;
using System.Text;
using System.Linq;
using System.Threading.Tasks;
using TwinCAT.TypeSystem;
namespace Test_Beckhoff
{
//var handle = adsClient.AddDeviceNotification("MAIN.boolVal", dataStream, 0, 1,
// AdsTransMode.OnChange, 100, 0, new object() );
// Structure declaration for handles
public enum EnuStates //Stato Macchina
{
Errore = -1,
Ferma = 0,
Automatica = 1,
Manuale = 2,
Emergenza = 3,
AzzeraTavola = 4,
ManualeStazione = 5,
Avviamento = 7,
}
public class ADS
{
public class ComandiADS
{
public TcAdsSymbolInfo Symbol;
public string SymbolName;
public bool ComandoScrittua;
public object Value;
public ManualResetEventSlim Updating;
public bool Error;
public ComandiADS()
{
Updating = new ManualResetEventSlim(false);
}
public ComandiADS(string name)
{
SymbolName = name;
Updating = new ManualResetEventSlim(false);
}
public ComandiADS(TcAdsSymbolInfo info)
{
Symbol = info;
Updating = new ManualResetEventSlim(false);
}
}
///
/// Dizionario di conversione da indice a index group e index offset
///
private Dictionary> addressList;
public delegate void StatusChangedEventHandler(ADS sender, EnuStates newStatus);
public TcAdsSymbolInfoCollection Symbols;
private TcAdsClient adsClient;
public TcAdsClient Client
{
get { return adsClient; }
}
public TwinCAT.Ads.TcAdsSymbolInfoLoader InfoLoader;
public TwinCAT.TypeSystem.ISymbolLoader SymbolLoaderInstance;
private List addedSignalationList = new List();
private int notifyposition;
private int eventHandle;
private int SegnalazioniADSEventHandle, StatusChangedEventHandle, MessageQueuedEventHandle;
private AdsStream notifyStream;
private AdsStream newNotificationStream;
public bool EnableEvents { get; set; }
private EnuStates _status;
private object lockobj = new object();
//private Action