Merge branch 'feature/S7Net' into develop

This commit is contained in:
Samuele Locatelli
2020-06-22 09:21:28 +02:00
20 changed files with 9919 additions and 9968 deletions
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace CMS_CORE_Library.Demo.Models
{
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace CMS_CORE_Library.Demo.Models
{
+1 -6
View File
@@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;
using System.Runtime.Serialization;
namespace CMS_CORE_Library.Demo.Models
{
+1 -7
View File
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE_Library.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
class NcDataModel
{
@@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE_Library.Demo.Models
namespace CMS_CORE_Library.Demo.Models
{
class NcProcessModel
{
@@ -1,6 +1,5 @@
using CMS_CORE_Library.Models;
using System.Collections.Generic;
using static CMS_CORE_Library.Models.DataStructures;
namespace CMS_CORE_Library.Demo.Models
{
+22 -22
View File
@@ -32,7 +32,7 @@ namespace CMS_CORE_Library.Demo
private List<SiemensMagazineConfigModel> MagazineConfig = new List<SiemensMagazineConfigModel>()
{
new SiemensMagazineConfigModel{Id = 1, Type = SIEMENS_MAGAZINE_TYPE.BOX_MAGAZINE, LoadingIsActive = true, Name = "MAG1", MaxPositions = 8},
new SiemensMagazineConfigModel{Id = 2, Type = SIEMENS_MAGAZINE_TYPE.CHAIN, LoadingIsActive = true, Name = "MAG2", MaxPositions = 10},
new SiemensMagazineConfigModel{Id = 2, Type = SIEMENS_MAGAZINE_TYPE.CHAIN, LoadingIsActive = true, Name = "MAG2", MaxPositions = 10},
new SiemensMagazineConfigModel{Id = 3, Type = SIEMENS_MAGAZINE_TYPE.INVISIBLE_MAGAZINE, LoadingIsActive = true, Name = "MAG3", MaxPositions = 10},
};
@@ -75,7 +75,7 @@ namespace CMS_CORE_Library.Demo
}
return NO_ERROR;
}
}
public override CmsError NC_Disconnect()
{
@@ -338,7 +338,7 @@ namespace CMS_CORE_Library.Demo
if (libraryError.IsError())
return libraryError;
if(val == 0)
if (val == 0)
unitOfMeasure = MILLIMETERS;
else
unitOfMeasure = INCHES;
@@ -752,7 +752,7 @@ namespace CMS_CORE_Library.Demo
public override CmsError PLC_RWorkedTimeHead(int head, ref uint time)
{
int index = (head - 1) *4;
int index = (head - 1) * 4;
// Read Worked time
CmsError libraryError = MEM_RWDWord(R, 0, HEADS_WORKED_TIMES.MemType, HEADS_WORKED_TIMES.Address + index, ref time);
@@ -780,7 +780,7 @@ namespace CMS_CORE_Library.Demo
public override CmsError PLC_RWorkedTimeMachine(ref uint time)
{
// Read Worked time -> ipotizzo sia il contatore 0
CmsError libraryError = MEM_RWDWord(R, 0, COUNTERS.MemType, COUNTERS.Address, ref time);
if (libraryError.IsError())
@@ -788,7 +788,7 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError PLC_WResetWorkedTimeMachine(uint time)
{
// Write Worked time -> ipotizzo sia il contatore 0
@@ -798,7 +798,7 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError PLC_WHeadOverride(uint id, HEAD_OVERRIDE_SIGN sign)
{
if (id > MAX_HEADS_NUMBER)
@@ -835,7 +835,7 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError PLC_ROperatorInputIsNeeded(ref List<M155InputIsNeededModel> value)
{
byte val = 0;
@@ -844,8 +844,8 @@ namespace CMS_CORE_Library.Demo
return libraryError;
bool[] bits = ByteToBits(val);
for(uint i = 0; i < 6; i++)
for (uint i = 0; i < 6; i++)
{
if (bits[i])
{
@@ -964,9 +964,9 @@ namespace CMS_CORE_Library.Demo
{
return INCORRECT_PARAMETERS_ERROR;
}
else if(index.Count() == 1)
else if (index.Count() == 1)
{
if(memType == SCADA_MEM_TYPE.INT)
if (memType == SCADA_MEM_TYPE.INT)
{
// read INT
int val = 0;
@@ -976,7 +976,7 @@ namespace CMS_CORE_Library.Demo
value = val;
}
else if(memType == SCADA_MEM_TYPE.WORD)
else if (memType == SCADA_MEM_TYPE.WORD)
{ // read WORD
ushort val = 0;
CmsError libraryError = MEM_RWWord(R, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), ref val);
@@ -995,7 +995,7 @@ namespace CMS_CORE_Library.Demo
value = val;
}
}
else if(index.Count() == 2 && memType == SCADA_MEM_TYPE.BOOL)
else if (index.Count() == 2 && memType == SCADA_MEM_TYPE.BOOL)
{ // read BOOL
bool val = false;
CmsError libraryError = MEM_RWBoolean(R, 0, MEMORY_TYPE.Demo, Convert.ToInt32(index[0]), Convert.ToInt32(index[1]), ref val);
@@ -1004,7 +1004,7 @@ namespace CMS_CORE_Library.Demo
value = val;
}
return NO_ERROR;
}
@@ -1059,7 +1059,7 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError PLC_RScadaSiemens(ref List<ScadaObjectModel> objects)
{
return FUNCTION_NOT_ALLOWED_ERROR;
@@ -1069,7 +1069,7 @@ namespace CMS_CORE_Library.Demo
{
List<ushort> values = new List<ushort>()
{
toolId,
toolId,
magazineId,
positionId,
familyId,
@@ -1105,7 +1105,7 @@ namespace CMS_CORE_Library.Demo
return libraryError;
// Check if the procedure is finished
if(GetBitValue(procFinalValue, 0))
if (GetBitValue(procFinalValue, 0))
{
List<ushort> values = new List<ushort>();
@@ -1504,7 +1504,7 @@ namespace CMS_CORE_Library.Demo
libraryError = MEM_RWByte(R, 1, WORK_OVERRIDE.MemType, WORK_OVERRIDE.Address, 0, ref val);
if (libraryError.IsError())
return libraryError;
processData.WorkOverride = val;
processData.ProcessMessage = "Generic Message";
@@ -2123,7 +2123,7 @@ namespace CMS_CORE_Library.Demo
serverService.PutDWordList(MemIndex.ToString(), binaryMemoryModel);
}
}
catch (Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -2469,7 +2469,7 @@ namespace CMS_CORE_Library.Demo
{
CmsError libraryError = CheckConnection();
if (libraryError.IsError())
return libraryError;
return libraryError;
try
{
@@ -3462,7 +3462,7 @@ namespace CMS_CORE_Library.Demo
offset = offsetData.Where(x => x.Id == offsetId).FirstOrDefault();
if(offset != null)
if (offset != null)
{
offset.CustomDouble = new List<double>()
{
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE_Library.Exceptions
{
+8 -8
View File
@@ -1573,7 +1573,7 @@ namespace CMS_CORE_Library.Fanuc
public override CmsError PLC_RToolMovement(ref MovementBetweenMagazinesModel toolMovement)
{
List<ushort> values = new List<ushort>();
CmsError cmsError = MEM_RWWordList(R, 0, TOOL_MOVEMENT_AREA.MemType, TOOL_MOVEMENT_AREA.Address, TOOL_MOVEMENT_AREA.Size/2, ref values);
CmsError cmsError = MEM_RWWordList(R, 0, TOOL_MOVEMENT_AREA.MemType, TOOL_MOVEMENT_AREA.Address, TOOL_MOVEMENT_AREA.Size / 2, ref values);
if (cmsError.IsError())
return cmsError;
@@ -3125,10 +3125,10 @@ namespace CMS_CORE_Library.Fanuc
nReturn = Focas1.cnc_rdpdf_subdirn(nLibHandle[0], absolutePath, dataNum);
if (nReturn != 0)
return GetNcError(nReturn);
short maxFiles = 1;
// Check if there are directories
if(dataNum.dir_num > 0)
if (dataNum.dir_num > 0)
{
IDBPDFSDIR funcInput = new IDBPDFSDIR();
ODBPDFSDIR dirData = new ODBPDFSDIR();
@@ -3156,7 +3156,7 @@ namespace CMS_CORE_Library.Fanuc
}
// Check if there are files
if (dataNum.file_num > 0 )
if (dataNum.file_num > 0)
{
IDBPDFADIR funcInput = new IDBPDFADIR();
ODBPDFADIR fileData = new ODBPDFADIR();
@@ -3615,7 +3615,7 @@ namespace CMS_CORE_Library.Fanuc
cmsError = TOOLS_RMagazineStatus(ref magazineStatus);
if (cmsError.IsError())
return cmsError;
config.Magazines = conf.Select(x => new SiemensMagazineConfigModel()
{
Id = x.Id,
@@ -5481,7 +5481,7 @@ namespace CMS_CORE_Library.Fanuc
internal static MEMORY_CELL M154_SWITCH_ONOFF = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS, 1, 2);
internal static MEMORY_CELL M154_ACK = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 3031, 1);
internal static MEMORY_CELL M154_STROBE = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 3032, 1);
internal static MEMORY_CELL M156_INPUT_NEEDED = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 23053, 1);
internal static MEMORY_CELL M156_INPUT_ACK = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 23054, 1);
internal static MEMORY_CELL M156_INPUT_STROBE = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 23055, 1);
@@ -5524,7 +5524,7 @@ namespace CMS_CORE_Library.Fanuc
internal static MEMORY_CELL TOOL_MOVEMENT_AREA = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4019, 1, 12);
internal static MEMORY_CELL TOOL_MOVEMENT_STROBE_END= new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4020, 1, 0);
internal static MEMORY_CELL TOOL_MOVEMENT_STROBE_END = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4020, 1, 0);
internal static MEMORY_CELL TOOL_MOVEMENT_HMI_RESPONSE = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, STARTING_ADDRESS + 4030, 1, 12);
// Tool table indexes
@@ -5546,6 +5546,6 @@ namespace CMS_CORE_Library.Fanuc
// Machine number
internal static MEMORY_CELL MATR_MACCH_FANUC = new MEMORY_CELL(MEMORY_TYPE.Fanuc_D, 4018, 0, 1);
internal static MEMORY_CELL NEW_MATR_MACCH = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 23049 , 0, 1);
internal static MEMORY_CELL NEW_MATR_MACCH = new MEMORY_CELL(MEMORY_TYPE.Fanuc_R, 23049, 0, 1);
}
}
File diff suppressed because it is too large Load Diff
-3
View File
@@ -1,8 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace CMS_CORE_Library.Models
{
+1 -1
View File
@@ -2053,7 +2053,7 @@ namespace CMS_CORE_Library
internal MEMORY_CELL PARAM_LING_FANUC = new MEMORY_CELL(MEMORY_TYPE.Null, 3281, 0, 1);
internal MEMORY_CELL PARAM_LING_FANUC_W = new MEMORY_CELL(MEMORY_TYPE.Fanuc_G, 581, 0, 1);
#endregion Fixed memory area
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+1 -2
View File
@@ -7,7 +7,6 @@ using System.IO;
using System.Reflection;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.Nc;
using static CMS_CORE_Library.Nc.MEMORY_TYPE;
namespace CMS_CORE_Library
{
@@ -640,7 +639,7 @@ namespace CMS_CORE_Library
/// </summary>
/// <returns></returns>
public abstract CmsError PLC_WAckProdUpdate();
/// <summary>
/// Get current recipe parameter list
/// </summary>
+48 -50
View File
@@ -7,16 +7,13 @@ using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.ServiceModel;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.Nc;
using static CMS_CORE_Library.Osai.MEMORY_ADDRESS;
@@ -52,7 +49,7 @@ namespace CMS_CORE_Library.Osai
//private const string TOOL_MANAGER_DIRECTORY_PATH = @"active\OEM\CMS\SYS\ACTIVE\";
private static List<string> EXT_PP = new List<string>() { "", "TXT", "CNC", "INI" };
private static List<string> EXT_PP = new List<string>() { "", "TXT", "CNC", "INI" };
private static List<string> EXT_IMG = new List<string>() { "PNG", "JPG", "JPEG" };
private const uint MAX_ROWS_FILE_PREVIEW = 10; // massimo 10 righe
@@ -134,7 +131,7 @@ namespace CMS_CORE_Library.Osai
bool directoryFound = false;
CmsError cmsError = FileExist(TOOL_MANAGER_DIRECTORY_PATH, ref directoryFound);
if(cmsError.IsError())
if (cmsError.IsError())
return cmsError;
if (!directoryFound)
@@ -145,9 +142,9 @@ namespace CMS_CORE_Library.Osai
//// Check if tool manager folder exist
//nReturn = OpenNC.LogFSFindFirst(TOOL_MANAGER_DIRECTORY_PATH, out FILEFINDDATA findData, out uint finder, out errorClass, out errorNum);
////If there's an error
//if (errorClass != 0 || errorNum != 0 || nReturn == 0)
// return GetNCError(errorClass, errorNum);
////If there's an error
//if (errorClass != 0 || errorNum != 0 || nReturn == 0)
// return GetNCError(errorClass, errorNum);
}
catch (Exception ex)
{
@@ -346,7 +343,7 @@ namespace CMS_CORE_Library.Osai
MachNumber = Encoding.ASCII.GetString(lists.ToArray());
}
return NO_ERROR;
}
@@ -723,7 +720,7 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
// MACHINE COUNTERS
public override CmsError PLC_RMachineCounters(ref List<CounterModel> counters)
{
@@ -893,7 +890,7 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
public override CmsError PLC_RWorkedTimeHead(int head, ref uint time)
{
int index = (head - 1) * 2;
@@ -905,12 +902,12 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
public override CmsError PLC_WResetWorkedTimeHead(int head)
{
ushort usControlWord = 0;
if(head <= 0 || head > MAX_HEADS_NUMBER)
if (head <= 0 || head > MAX_HEADS_NUMBER)
return INCORRECT_PARAMETERS_ERROR;
// Read status
@@ -952,12 +949,12 @@ namespace CMS_CORE_Library.Osai
bool bitValue = true;
int nTry = 0;
for (int i = 0; i<=4; i++)
for (int i = 0; i <= 4; i++)
{
//Scrivo il bit
bitValue = true;
nTry = 0;
cmsError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address,0, ref bitValue);
cmsError = MEM_RWBoolean(W, 0, MACHINE_RESET_WORKED_TIME.MemType, MACHINE_RESET_WORKED_TIME.Address, 0, ref bitValue);
if (cmsError.IsError())
return cmsError;
@@ -1125,9 +1122,9 @@ namespace CMS_CORE_Library.Osai
// Parse line & get parameters
value.Add(new M156InputIsNeededModel()
{
Process = (uint)processId,
Id = vals.ElementAt(processId - 1),
Value = responseVal
Process = (uint)processId,
Id = vals.ElementAt(processId - 1),
Value = responseVal
});
}
}
@@ -1178,7 +1175,7 @@ namespace CMS_CORE_Library.Osai
TimerInputNeeded = true,
CountdownIsActive = false,
Timer = 0
});
});
}
else if (countdownActiveNeeded[processId - 1])
{
@@ -1284,7 +1281,7 @@ namespace CMS_CORE_Library.Osai
case "MD": Type = MEMORY_TYPE.Osai_MD; break;
case "GD": Type = MEMORY_TYPE.Osai_GD; break;
};
index = index[1].Split('.');
try
@@ -1330,7 +1327,7 @@ namespace CMS_CORE_Library.Osai
}
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -1470,7 +1467,7 @@ namespace CMS_CORE_Library.Osai
}
public override CmsError PLC_WTerminateAssistedToolingProcedure()
{
{
// Terminate procedure with ACK-STROBE method
CmsError cmsError = PLC_ManageActiveAck(PLC_ASSISTED_TOOLING_STROBE.Address, PLC_ASSISTED_TOOLING_STROBE.SubAddress,
HMI_ASSISTED_TOOLING_ACK.Address, HMI_ASSISTED_TOOLING_ACK.SubAddress,
@@ -1697,7 +1694,7 @@ namespace CMS_CORE_Library.Osai
return cmsError;
// Build Long value
value = ((long)word << 32) + firtInt;
value = ((long)word << 32) + firtInt;
return NO_ERROR;
}
@@ -2072,10 +2069,10 @@ namespace CMS_CORE_Library.Osai
OffsetModel offsetData = new OffsetModel();
// Read offset data
if(info.actualtooloff != 0)
if (info.actualtooloff != 0)
cmsError = TOOLS_ROffset((short)info.actualtooloff, ref offsetData);
if (cmsError.IsError())
return cmsError;
if (cmsError.IsError())
return cmsError;
processData = new SelectedProcessData()
{
@@ -2090,11 +2087,11 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
}
#endregion PROCESS (PATH) High-level data
@@ -2440,11 +2437,11 @@ namespace CMS_CORE_Library.Osai
//if (errorClass != 0 || errorNum != 0 || nReturn == 0)
// return GetNCError(errorClass, errorNum);
// Read axes info from NC
// Read axes info from NC
nReturn = OpenNC.GetAxesInfo3(ushort.MaxValue, ref axesNumber, out unsignedshortarray axesProcess, out byte[] axesName, out unsignedshortarray axesType, out unsignedshortarray axesInterface, out uint errorClass, out uint errorNum);
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
// Get from PLC which axis can be selected
List<byte> ids = new List<byte>();
List<int> ints = new List<int>();
@@ -2461,7 +2458,7 @@ namespace CMS_CORE_Library.Osai
if ((charName < 'a' || charName > 'z') && charName != 'S' && charName != '\0' && axesProcess[i] == process)
{
var isVisible = ids.Where(x => x == i + 1)?.FirstOrDefault() == 0 ? false : true;
if(isVisible)
if (isVisible)
// Add to returned value
axesData.Add(new AxisModel()
{
@@ -2511,7 +2508,7 @@ namespace CMS_CORE_Library.Osai
public override CmsError AXES_ROrigin(int numberOfAxes)
{
for(uint i = 1; i <= 100; i++)
for (uint i = 1; i <= 100; i++)
{
OpenNC.GetOriginTabRecordII(i, out ORIGINTABLEII recordBuff, out uint errClass, out uint errNum);
}
@@ -3189,7 +3186,7 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -3247,7 +3244,7 @@ namespace CMS_CORE_Library.Osai
//If there's an error launch exception
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
}
}
catch (Exception ex)
{
return ManageException(ex);
@@ -3421,7 +3418,7 @@ namespace CMS_CORE_Library.Osai
CmsError cmsError = FILES_WProgram(newFilePath, customPartProgramContent);
if (cmsError.IsError())
return cmsError;
// Activate custom file
return FILES_WSetActiveProgram(processId, newFilePath, ref activeData);
}
@@ -3478,7 +3475,7 @@ namespace CMS_CORE_Library.Osai
Id = x.Id,
Type = ConvertToSiemensMagazineType(x.Type),
Name = x.Id.ToString(),
LoadingIsActive = x.Type != NC_MAGAZINE_TYPE.MAGAZINE_TOOL_BUFFER,
LoadingIsActive = x.Type != NC_MAGAZINE_TYPE.MAGAZINE_TOOL_BUFFER,
MaxPositions = x.MaxPositions
}).ToList();
@@ -3738,7 +3735,7 @@ namespace CMS_CORE_Library.Osai
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
cmsError = CreateBackup();
if (cmsError.IsError())
return cmsError;
@@ -4006,7 +4003,7 @@ namespace CMS_CORE_Library.Osai
CmsError cmsError = CheckConnection();
if (cmsError.IsError())
return cmsError;
ushort nReturn;
try
@@ -4070,7 +4067,7 @@ namespace CMS_CORE_Library.Osai
offsetData.LenVal[0].ValOrig = offset.Length * divider;
offsetData.LenVal[0].ActChangeVal = offset.WearLength * divider;
for(int i = 0; i < offset.CustomDouble.Count(); i++)
for (int i = 0; i < offset.CustomDouble.Count(); i++)
{
offsetData.Duser[i] = offset.CustomDouble[i];
offsetData.Suser[i] = offset.CustomInt[i];
@@ -4311,7 +4308,7 @@ namespace CMS_CORE_Library.Osai
return cmsError;
bool[] values = IntToBits(val);
for(int i = 0; i < values.Length; i++ )
for (int i = 0; i < values.Length; i++)
{
if (values[i])
ids.Add(i);
@@ -4701,13 +4698,14 @@ namespace CMS_CORE_Library.Osai
//Read From Files
PlcMessages = File.ReadAllLines(Path)
.Select(line => line.Split(','))
.ToDictionary(line => Convert.ToInt32(line[0]), line => {
.ToDictionary(line => Convert.ToInt32(line[0]), line =>
{
if (line.Count() > 1)
return line[1];
return "";
});
});
return NO_ERROR;
}
catch (Exception ex)
@@ -4796,7 +4794,7 @@ namespace CMS_CORE_Library.Osai
//Manage the Exception Launch
private CmsError ManageException(Exception ex)
{
{
Connected = false;
//Catch the .Net exceptions
@@ -4813,7 +4811,7 @@ namespace CMS_CORE_Library.Osai
Connected = false;
return NOT_CONNECTED_ERROR;
}
else if(errorClass == 23)
else if (errorClass == 23)
{
return NO_ERROR;
}
@@ -5080,7 +5078,7 @@ namespace CMS_CORE_Library.Osai
{
switch (errorNum)
{
case 1: szErrorDesc = "file_not_valid";break;
case 1: szErrorDesc = "file_not_valid"; break;
case 161: szErrorDesc = "file_not_valid"; break;
}
}
@@ -5206,11 +5204,11 @@ namespace CMS_CORE_Library.Osai
internal static MEMORY_CELL SELF_ADAPTIVE_PATH = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 3472, 4);
// Assisted tooling
internal static MEMORY_CELL ASSISTED_TOOLING_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4512, 7);
internal static MEMORY_CELL HMI_ASSISTED_TOOLING_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4518, 0, 1);
internal static MEMORY_CELL HMI_ASSISTED_TOOLING_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4518, 1, 1);
internal static MEMORY_CELL ASSISTED_TOOLING_DATA = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4512, 7);
internal static MEMORY_CELL HMI_ASSISTED_TOOLING_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4518, 0, 1);
internal static MEMORY_CELL HMI_ASSISTED_TOOLING_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4518, 1, 1);
internal static MEMORY_CELL PLC_ASSISTED_TOOLING_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4519, 1, 1);
internal static MEMORY_CELL PLC_ASSISTED_TOOLING_ACK = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4519, 1, 1);
internal static MEMORY_CELL PLC_ASSISTED_TOOLING_STROBE = new MEMORY_CELL(MEMORY_TYPE.Osai_MW, 4519, 1, 1);
}
+5 -9
View File
@@ -1,18 +1,14 @@
using CndexLinkDotNet;
using CMS_CORE_Library.OPENControl;
using CndexLinkDotNet;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using CMS_CORE_Library.OPENControl;
namespace CMS_CORE_Library.Osai
{
partial class NativeConstants
{
//NUM_LINE_PER_MSG -> 4
//NUM_LINE_PER_MSG -> 4
public const int NUM_LINE_PER_MSG = 4;
//NUM_WCHAR_PER_LINE -> 512
@@ -38,7 +34,7 @@ namespace CMS_CORE_Library.Osai
return new MESSAGE_TEXT() { Line1 = value, Line2 = value, Line3 = value, Line4 = value };
}
}
class OSAIErrorManagerLibrary
{
/// <summary>
@@ -1,5 +1,4 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Le informazioni generali relative a un assembly sono controllate dal seguente
+2 -6
View File
@@ -9,15 +9,11 @@ using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Xml.Linq;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.NcThermo;
using static CMS_CORE_Library.Nc.MEMORY_TYPE;
using static CMS_CORE_Library.Nc;
using static CMS_CORE_Library.S7Net.MEMORY_ADDRESS;
using static CMS_CORE_Library.Utils.Nc_Utils;
using static CMS_CORE_Library.Nc;
namespace CMS_CORE_Library.S7Net
{
@@ -4560,7 +4556,7 @@ namespace CMS_CORE_Library.S7Net
// C) STD MEM (need check!) FIXME TODO
internal static MEMORY_CELL PRE_POST_POWER_ON_ACK = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2578, 2);
internal static MEMORY_CELL PRE_POST_POWER_ON_CLICKED = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2580, 2);
internal static MEMORY_CELL AXIS_RESET_PROCEDURE = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2608, 1);
internal static MEMORY_CELL SELECTED_PROCESS = new MEMORY_CELL(MEMORY_TYPE.Siemens_DB, TABLE, 2582, 24);
+31 -31
View File
@@ -9,7 +9,6 @@ using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Xml.Linq;
using static CMS_CORE_Library.Models.DataStructures;
using static CMS_CORE_Library.Nc;
@@ -197,7 +196,7 @@ namespace CMS_CORE_Library.Siemens
Connected = true;
// InitializeSiemens objects
if(this.EnableAxes)
if (this.EnableAxes)
{
if (AxesSvc == null)
AxesSvc = new DataSvc();
@@ -525,7 +524,7 @@ namespace CMS_CORE_Library.Siemens
var splittedFileName = fileName.Split('_');
if (splittedFileName.Count() == 2)
{
if(splittedFileName[0].ToLower() == "cmsalarm")
if (splittedFileName[0].ToLower() == "cmsalarm")
{
// Get lang from threeletter
var lang = GetCultureFromThreeLetter(splittedFileName[1]);
@@ -782,7 +781,7 @@ namespace CMS_CORE_Library.Siemens
var a = fileSvc.ReadMdaBuffer(1);
fileSvc.WriteMdaBuffer(processId, mdiString);
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -1141,10 +1140,10 @@ namespace CMS_CORE_Library.Siemens
short toolId = SwapShortEndianFormat(BitConverter.ToInt16(readValues.ToArray(), headOffset + 4));
double residualLife = 0;
// Find tool
var tool = ToolTableData.Where(x => x.Id == toolId).FirstOrDefault();
// Check if process is selected
if (readValues[headOffset] != 0)
{
@@ -1166,7 +1165,7 @@ namespace CMS_CORE_Library.Siemens
residualLife = edge.ResidualLife;
}
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -1547,7 +1546,7 @@ namespace CMS_CORE_Library.Siemens
DataSvc dataSvc = new DataSvc();
dataSvc.Read(item);
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -1646,7 +1645,7 @@ namespace CMS_CORE_Library.Siemens
value = val;
}
}
catch(Exception ex)
catch (Exception ex)
{
return ManageException(ex);
}
@@ -1801,7 +1800,7 @@ namespace CMS_CORE_Library.Siemens
{
return ManageException(ex);
}
return NO_ERROR;
}
@@ -2094,7 +2093,7 @@ namespace CMS_CORE_Library.Siemens
return cmsError;
byte readValues = 0;
cmsError = MEM_RWByte(R, 0, ACTIVE_CLIENT.MemType, ACTIVE_CLIENT.Address, ACTIVE_CLIENT.SubAddress, 0,ref readValues);
cmsError = MEM_RWByte(R, 0, ACTIVE_CLIENT.MemType, ACTIVE_CLIENT.Address, ACTIVE_CLIENT.SubAddress, 0, ref readValues);
if (cmsError.IsError())
return cmsError;
@@ -2114,7 +2113,7 @@ namespace CMS_CORE_Library.Siemens
{
return FUNCTION_NOT_ALLOWED_ERROR;
}
public override CmsError PLC_WTerminateMovementProcedure(MOVEMENT_RESPONSE resp)
{
return FUNCTION_NOT_ALLOWED_ERROR;
@@ -2430,7 +2429,7 @@ namespace CMS_CORE_Library.Siemens
new Item { Path = "/Tool/Compensation/edgeData[u1,c"+ actualToolId +","+ (offsetEdge + 15) + "]" } // $TC_DP15
};
dataSvc.Read(itemsToolEdge);
dataSvc.Read(itemsToolEdge);
offset = new OffsetModel()
{
@@ -2493,7 +2492,7 @@ namespace CMS_CORE_Library.Siemens
ProcessMessage = "",
WorkOverride = Convert.ToByte(items[3].Value),
RapidOverride = Convert.ToByte(items[4].Value),
OffsetData = offset,
OffsetData = offset,
FeedOverride = Convert.ToDouble(items[5].Value)
};
}
@@ -2734,7 +2733,7 @@ namespace CMS_CORE_Library.Siemens
int processAxes = Convert.ToInt32(ncAxes[i].Value);
// If axis is visible, add it to the output
if (processAxes == channel && axesAreVisible[i])
{
{
// Check if axes is configurated axes
var axis = configuredAxes.Where(x => x.Id == (i + 1)).FirstOrDefault();
if (axis != null)
@@ -2810,8 +2809,8 @@ namespace CMS_CORE_Library.Siemens
List<AxisModel> axes = new List<AxisModel>();
CmsError cmsError = AXES_RAxesNames(1, ref axes);
for(int i = 1; i <= 4; i++)
for (int i = 1; i <= 4; i++)
{
foreach (var axis in axes)
{
@@ -4463,14 +4462,14 @@ namespace CMS_CORE_Library.Siemens
// Check if tool can fit in the position considering disabled positions
if (magConfig.Type != SIEMENS_MAGAZINE_TYPE.BOX_MAGAZINE)
{
foreach(var pos in MagazinePositionsData)
foreach (var pos in MagazinePositionsData)
{
if (pos.Disabled && pos.MagazineId == magazineId)
{
// If magazine is circular, move position before ( for left case ) or after ( right case ) the location you want to mount the tool
var right = pos.PositionId < newMagazineTool.PositionId ? pos.PositionId + magConfig.MaxPositions : pos.PositionId;
var left = pos.PositionId > newMagazineTool.PositionId ? pos.PositionId - magConfig.MaxPositions : pos.PositionId;
// Calculate right space needed
double rightToBeMount = newMagazineTool.PositionId + ((tool as SiemensToolModel).RightSize / 2.0);
if (right < rightToBeMount)
@@ -4487,11 +4486,11 @@ namespace CMS_CORE_Library.Siemens
else
{
// Check if near positions are disabled
var posizionDisabled = MagazinePositionsData.Where(
x => x.MagazineId == magazineId && x.Disabled == true &&
((x.PositionId > newMagazineTool.PositionId && x.PositionId <= newMagazineTool.PositionId + (tool as SiemensToolModel).RightSize / 2.0)
|| (x.PositionId < newMagazineTool.PositionId && x.PositionId >= newMagazineTool.PositionId - (tool as SiemensToolModel).LeftSize / 2.0)))
.ToList();
var posizionDisabled = MagazinePositionsData.Where(
x => x.MagazineId == magazineId && x.Disabled == true &&
((x.PositionId > newMagazineTool.PositionId && x.PositionId <= newMagazineTool.PositionId + (tool as SiemensToolModel).RightSize / 2.0)
|| (x.PositionId < newMagazineTool.PositionId && x.PositionId >= newMagazineTool.PositionId - (tool as SiemensToolModel).LeftSize / 2.0)))
.ToList();
if (posizionDisabled.Count() > 0)
return MAGAZINE_POSITION_OCCUPIED_ERROR;
@@ -4733,7 +4732,7 @@ namespace CMS_CORE_Library.Siemens
public override CmsError TOOLS_WStartTDIUnloading(ushort magazineId, ushort positionId, ushort toolId)
{
var mountedTool = MagazineMountedTools.Where(x => x.ToolId == toolId).FirstOrDefault();
if(mountedTool == null || (mountedTool.ToolId != toolId && mountedTool.PositionId != positionId))
if (mountedTool == null || (mountedTool.ToolId != toolId && mountedTool.PositionId != positionId))
return INCORRECT_PARAMETERS_ERROR;
List<ushort> words = new List<ushort>()
@@ -4802,13 +4801,14 @@ namespace CMS_CORE_Library.Siemens
if (edge.EdgeAdditionalParams.ContainsKey(conf.Name) && toolEdgesConfig.TDIEdgeFields.ContainsKey(conf.Path))
{
var formattedValue = GetSiemensFormattedDouble(edge.EdgeAdditionalParams[conf.Name]);
items.Add(new Item() {
items.Add(new Item()
{
Path = string.Format(toolEdgesConfig.TDIEdgeFields[conf.Path], BALLUF_EMPTY_TABLE.Address),
Value = formattedValue
});
}
}
// Life Parameters
switch (tool.LifeType)
{
@@ -4858,7 +4858,7 @@ namespace CMS_CORE_Library.Siemens
return BitConverter.ToUInt32(byteVal, 0);
}
public override CmsError TOOLS_WAbortBallufTablet()
{
return WBallufAction(SIEMENS_TDI_ACTION.ABORT);
@@ -5090,7 +5090,7 @@ namespace CMS_CORE_Library.Siemens
{
return FUNCTION_NOT_ALLOWED_ERROR;
}
public override CmsError TOOLS_RAdatpivePathStep(ref Byte step)
{
// Check ACK
@@ -6506,7 +6506,7 @@ namespace CMS_CORE_Library.Siemens
int magazineId = Convert.ToInt32(item[0].Value);
int positionId = Convert.ToInt32(item[1].Value);
if(magazineId != 0 && positionId != 0)
if (magazineId != 0 && positionId != 0)
MoveToolInMagazineList(newTool.Id, magazineId, positionId);
}
//*SHANK FIX*else if (MULTITOOL_OPTION_ACTIVE)
@@ -6541,7 +6541,7 @@ namespace CMS_CORE_Library.Siemens
new Item(){ Path = string.Format("/Tool/Data/toolInPlace[{0}]", toolInfo.tNo) }
};
dataSvc.Read(item);
int magazineId = Convert.ToInt32(item[0].Value);
int positionId = Convert.ToInt32(item[1].Value);
+2 -2
View File
@@ -130,7 +130,7 @@ namespace CMS_CORE_Library
{6, "loading_station" },
{7, "loading_point" }
};
private static Dictionary<int, string> cmsRotationTypeList = new Dictionary<int, string>()
{
{0, "none"},
@@ -378,7 +378,7 @@ namespace CMS_CORE_Library
new FieldsConfiguration{ Name = "type", Type = "select", SelectValues = toolTypeCodeList, Category = "magPosType", ReadOnly = false, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{ Name = "disabled", Type = "boolean", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = 0 }
};
public static EdgesConfiguration NcOffsetFieldsConfiguration = new EdgesConfiguration()
{
EdgeConfiguration = new List<FieldsConfiguration>()
+4 -6
View File
@@ -1,11 +1,9 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices;
using static CMS_CORE_Library.Models.DataStructures;
@@ -167,9 +165,9 @@ namespace CMS_CORE_Library.Utils
return String.Empty;
}
// Convert one integer in array of bools
internal static bool[] IntToBits(int val)
internal static bool[] IntToBits(int val)
{
return IntToBits(new int[] { val });
}
@@ -243,7 +241,7 @@ namespace CMS_CORE_Library.Utils
{
string tmpString = codeLine;
if (endPos != -1)
tmpString = codeLine.Substring(startPos + 1 , endPos - startPos - 1);
tmpString = codeLine.Substring(startPos + 1, endPos - startPos - 1);
returnVal = tmpString.Trim(';').Split(',');
@@ -278,7 +276,7 @@ namespace CMS_CORE_Library.Utils
}
else
{
returnVal = new string[0];
returnVal = new string[0];
}
return returnVal;