This commit is contained in:
Lucio Maranta
2019-01-16 16:21:30 +00:00
parent 4fbfab4c82
commit 84c3f74d7f
5 changed files with 230 additions and 12 deletions
+52
View File
@@ -909,6 +909,58 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value)
{
string[] index = memIndex.Split('.');
if (index.Count() == 0)
{
return INCORRECT_PARAMETERS_ERROR;
}
else if (index.Count() == 1)
{
if (memType == SCADA_MEM_TYPE.INT)
{
// READ INT
int val = 0;
CmsError cmsError = MEM_RWInteger(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else if (memType == SCADA_MEM_TYPE.WORD)
{ // READ WORD
ushort val = 0;
CmsError cmsError = MEM_RWWord(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else
{ // READ byte
byte val = 0;
CmsError cmsError = MEM_RWByte(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), 0, ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
}
else if (index.Count() == 2 && memType == SCADA_MEM_TYPE.BOOL)
{ // READ BOOL
bool val = false;
CmsError cmsError = MEM_RWBoolean(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
return NO_ERROR;
}
#endregion PLC High-level data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+52
View File
@@ -871,6 +871,58 @@ namespace CMS_CORE_Library.Fanuc
return NO_ERROR;
}
public override CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value)
{
string[] index = memIndex.Split('.');
if (index.Count() == 0)
{
return INCORRECT_PARAMETERS_ERROR;
}
else if (index.Count() == 1)
{
if (memType == SCADA_MEM_TYPE.INT)
{
// READ INT
int val = 0;
CmsError cmsError = MEM_RWInteger(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else if (memType == SCADA_MEM_TYPE.WORD)
{ // READ WORD
ushort val = 0;
CmsError cmsError = MEM_RWWord(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else
{ // READ byte
byte val = 0;
CmsError cmsError = MEM_RWByte(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), 0, ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
}
else if (index.Count() == 2 && memType == SCADA_MEM_TYPE.BOOL)
{ // READ BOOL
bool val = false;
CmsError cmsError = MEM_RWBoolean(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
return NO_ERROR;
}
#endregion PLC High-level data
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1
View File
@@ -562,6 +562,7 @@ namespace CMS_CORE_Library
public abstract CmsError PLC_RScadaValue(string memIndex, SCADA_MEM_TYPE memType, ref object value);
public abstract CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value);
#endregion PLC High-level data (to override)
+54 -2
View File
@@ -667,7 +667,7 @@ namespace CMS_CORE_Library.Osai
softKeyStatusMemory.MemType,
softKeyStatusMemory.Address,
memorySizeToRead / 4,
ref readValue);
ref readValue);
if (cmsError.IsError())
return cmsError;
@@ -676,7 +676,7 @@ namespace CMS_CORE_Library.Osai
// Convert array into structured data
for (ushort i = 0; i < bits.Count() / 2; i++)
{
{
softKeys.Add(new SoftKeysModel()
{
Id = (uint)i + 1,
@@ -808,6 +808,58 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
public override CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value)
{
string[] index = memIndex.Split('.');
if (index.Count() == 0)
{
return INCORRECT_PARAMETERS_ERROR;
}
else if (index.Count() == 1)
{
if (memType == SCADA_MEM_TYPE.INT)
{
// READ INT
int val = 0;
CmsError cmsError = MEM_RWInteger(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else if (memType == SCADA_MEM_TYPE.WORD)
{ // READ WORD
ushort val = 0;
CmsError cmsError = MEM_RWWord(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else
{ // READ byte
byte val = 0;
CmsError cmsError = MEM_RWByte(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), 0, ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
}
else if (index.Count() == 2 && memType == SCADA_MEM_TYPE.BOOL)
{ // READ BOOL
bool val = false;
CmsError cmsError = MEM_RWBoolean(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
return NO_ERROR;
}
private CmsError PLC_WStrobe(MEMORY_CELL ackCell, MEMORY_CELL strobeCell, uint id)
{
CmsError cmsError;
+71 -10
View File
@@ -25,6 +25,7 @@ namespace CMS_CORE_Library.Siemens
{
// Global Constants
private const string OptionHMINotRunning = "P66";
private const string HMIDllName = "Wrapper.dll";
private const string NcNotFound = "Missing response";
private const string NcNotFound2 = "networking error";
@@ -165,8 +166,20 @@ namespace CMS_CORE_Library.Siemens
AxesSvc = new DataSvc();
if (SelectedProcessSvc == null)
{
SelectedProcessSvc = new DataSvc();
SelectedProcessSvc.Subscribe(ManageSelectedProcess, new Item[]
{
new Item() { Path = "DB258.DBX2582.2" },
new Item() { Path = "DB258.DBX2586.2" },
new Item() { Path = "DB258.DBX2590.2" },
new Item() { Path = "DB258.DBX2594.2" },
new Item() { Path = "DB258.DBX2598.2" },
new Item() { Path = "DB258.DBX2602.2" },
});
}
//Check if Siemens Environment is started
CmsError cmsError = CheckSiemensEnv();
if (cmsError.IsError())
@@ -191,16 +204,6 @@ namespace CMS_CORE_Library.Siemens
MagazineActionsSvc = new DataSvc();
SetupToolTableData();
}
SelectedProcessSvc.Subscribe(ManageSelectedProcess, new Item[]
{
new Item() { Path = "DB258.DBX2582.2" },
new Item() { Path = "DB258.DBX2586.2" },
new Item() { Path = "DB258.DBX2590.2" },
new Item() { Path = "DB258.DBX2594.2" },
new Item() { Path = "DB258.DBX2598.2" },
new Item() { Path = "DB258.DBX2602.2" },
});
}
catch (Exception ex)
{
@@ -1142,6 +1145,58 @@ namespace CMS_CORE_Library.Siemens
return NO_ERROR;
}
public override CmsError PLC_WScadaValue(string memIndex, SCADA_MEM_TYPE memType, object value)
{
string[] index = memIndex.Split('.');
if (index.Count() == 0)
{
return INCORRECT_PARAMETERS_ERROR;
}
else if (index.Count() == 1)
{
if (memType == SCADA_MEM_TYPE.INT)
{
// READ INT
int val = 0;
CmsError cmsError = MEM_RWInteger(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else if (memType == SCADA_MEM_TYPE.WORD)
{ // READ WORD
ushort val = 0;
CmsError cmsError = MEM_RWWord(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
else
{ // READ byte
byte val = 0;
CmsError cmsError = MEM_RWByte(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), 0, ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
}
else if (index.Count() == 2 && memType == SCADA_MEM_TYPE.BOOL)
{ // READ BOOL
bool val = false;
CmsError cmsError = MEM_RWBoolean(W, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), ref val);
if (cmsError.IsError())
return cmsError;
value = val;
}
return NO_ERROR;
}
private CmsError ReadActiveLine(uint path, ref string line)
{
try
@@ -3296,6 +3351,7 @@ namespace CMS_CORE_Library.Siemens
// If the magazine is a circular magazine move position before ( for left case ) or after ( right case ) the location you want to mount the tool
if (magConfig.Type != SIEMENS_MAGAZINE_TYPE.BOX_MAGAZINE)
{
// If magazine is circular, move position before ( for left case ) or after ( right case ) the location you want to mount the tool
decPosition = decPosition < newMagazineTool.PositionId ? decPosition + magConfig.MaxPositions : decPosition;
incPosition = incPosition > newMagazineTool.PositionId ? incPosition - magConfig.MaxPositions : incPosition;
@@ -3819,12 +3875,17 @@ namespace CMS_CORE_Library.Siemens
//Manage the Exception Launch
private CmsError ManageException(Exception ex)
{
var a = ex.GetType();
//Catch the Siemens exceptions
if (ex is OperateMissingOptionException && ex.Message.Contains(OptionHMINotRunning))
{
Connected = false;
return SIEMENS_HMI_NOT_RUNNING_ERROR;
}
else if(ex is FileNotFoundException && ex.Message.Contains(HMIDllName))
{
return SIEMENS_ENVIRONMENT_NOT_FOUND_ERROR;
}
else if (ex.Message.Contains(NcNotFound) || ex.Message.Contains(NcNotFound2) || ex.Message.Contains(NcNotFound3))
{
Connected = false;