Merge branch 'feature/S7Net' into develop
This commit is contained in:
@@ -172,10 +172,10 @@ namespace CMS_CORE_Library.Models
|
||||
public static CmsError NO_ERROR = new CmsError(CMS_ERROR_CODES.OK, "");
|
||||
public static CmsError NOT_CONNECTED_ERROR = new CmsError(CMS_ERROR_CODES.NOT_CONNECTED, "error_not_connected");
|
||||
public static CmsError NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, "error_not_found");
|
||||
public static CmsError S7_PLC_EMPTY_READ = new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, "error_s7_empy_data");
|
||||
public static CmsError S7_PLC_WRONG_DATA = new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, "error_s7_wrong_data");
|
||||
public static CmsError S7_PLC_READ_ERROR = new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, "error_s7_read_error");
|
||||
public static CmsError S7_PLC_WRITE_ERROR = new CmsError(CMS_ERROR_CODES.INTERNAL_ERROR, "error_s7_write_error");
|
||||
public static CmsError S7_PLC_EMPTY_READ = new CmsError(CMS_ERROR_CODES.PLC_MEM_CONF_ERROR, "error_s7_empy_data");
|
||||
public static CmsError S7_PLC_WRONG_DATA = new CmsError(CMS_ERROR_CODES.PLC_MEM_CONF_ERROR, "error_s7_wrong_data");
|
||||
public static CmsError S7_PLC_READ_ERROR = new CmsError(CMS_ERROR_CODES.PLC_MEM_CONF_ERROR, "error_s7_read_error");
|
||||
public static CmsError S7_PLC_WRITE_ERROR = new CmsError(CMS_ERROR_CODES.PLC_MEM_CONF_ERROR, "error_s7_write_error");
|
||||
public static CmsError PROC_NOT_FOUND_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "error_process_not_found");
|
||||
public static CmsError FUNCTION_NOT_ALLOWED_ERROR = new CmsError(CMS_ERROR_CODES.FUNCTION_NOT_ALLOWED, "error_function_not_allowed");
|
||||
public static CmsError BIT_NOT_IN_RANGE_ERROR = new CmsError(CMS_ERROR_CODES.BIT_NOT_IN_RANGE, "error_bit_not_in_range");
|
||||
|
||||
@@ -69,6 +69,10 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// Oggetto PLC da ri-utilizzare...
|
||||
/// </summary>
|
||||
protected Plc currPLC;
|
||||
/// <summary>
|
||||
/// Lock per connessione PLC
|
||||
/// </summary>
|
||||
private readonly object connectLock = new object();
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -137,40 +141,42 @@ namespace CMS_CORE_Library.S7Net
|
||||
/// <returns></returns>
|
||||
public override CmsError NC_Connect()
|
||||
{
|
||||
// Try to get information
|
||||
try
|
||||
lock (connectLock)
|
||||
{
|
||||
// Check if Siemens Environment is started
|
||||
CmsError libraryError = CheckS7Ping();
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
// Check connection
|
||||
currPLC = new Plc(tipoCpu, this.Ip, this.rack, this.slot);
|
||||
currPLC.Open();
|
||||
if (currPLC.IsConnected)
|
||||
Connected = true;
|
||||
|
||||
// FARE TODO FIXME
|
||||
// Setup the alarms (with DB bitmap) --> PlcMessages
|
||||
|
||||
if (this.EnableAlarms)
|
||||
// Try to get information
|
||||
try
|
||||
{
|
||||
// PlcMessages
|
||||
// Check if Siemens Environment is started
|
||||
CmsError libraryError = CheckS7Ping();
|
||||
if (libraryError.IsError())
|
||||
return libraryError;
|
||||
|
||||
// Check connection
|
||||
currPLC = new Plc(tipoCpu, this.Ip, this.rack, this.slot);
|
||||
currPLC.Open();
|
||||
if (currPLC.IsConnected)
|
||||
Connected = true;
|
||||
|
||||
// FARE TODO FIXME
|
||||
// Setup the alarms (with DB bitmap) --> PlcMessages
|
||||
|
||||
if (this.EnableAlarms)
|
||||
{
|
||||
// PlcMessages
|
||||
#if false
|
||||
SiemensAlarms = new Alarm[] { };
|
||||
SiemensAlmSvc = new AlarmSvc(ConvertToSTEPLanguage(SiemensLanguage).ThreeLetterISOLanguageName);
|
||||
SiemensAlmSvc.Subscribe(AlarmsChanged);
|
||||
Infrastructure.SubscribeLanguageChanged(NcLanguageChanged);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return ManageException(ex);
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user