This commit is contained in:
@@ -881,6 +881,12 @@
|
||||
<Content Include="fwlibe64.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OsaiTool.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<Content Include="OSAI_ErrorMgr.dll">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
@@ -28,12 +28,12 @@ namespace CMS_CORE.Osai
|
||||
private String Cnc_SftVersion;
|
||||
private String Cnc_SeriesNum;
|
||||
private String Cnc_name;
|
||||
private String[] PlcMessages;
|
||||
private DateTime Last_Static_Read;
|
||||
private String OsaiLanguages;
|
||||
private ushort timeOutConn;
|
||||
private EndpointAddress endPointAddress;
|
||||
private BasicHttpBinding HttpBinding;
|
||||
private static String[] PlcMessages;
|
||||
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -61,8 +61,12 @@ namespace CMS_CORE.Osai
|
||||
//ReadLanguageConfig
|
||||
LanguageConfig();
|
||||
|
||||
//ReadPlcMessages
|
||||
ReadPlcMessages();
|
||||
//Read Plc Messages
|
||||
if(PlcMessages == null)
|
||||
{
|
||||
PlcMessages = new string[] { };
|
||||
ReadPlcMessages();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -372,6 +376,7 @@ namespace CMS_CORE.Osai
|
||||
uint errorClass, errorNum;
|
||||
ushort nReturn;
|
||||
MSGERROR err;
|
||||
MSGEMERGENCY errEmgy;
|
||||
|
||||
//Check if the NC is Connected
|
||||
CheckConnection();
|
||||
@@ -380,12 +385,45 @@ namespace CMS_CORE.Osai
|
||||
try
|
||||
{
|
||||
//Execute the method
|
||||
nReturn = OpenNC.ReadCurrentErrorMsg(Number, out err, out errorClass, out errorNum);
|
||||
nReturn = OpenNC.ReadCurrentEmergMsg(0, out errEmgy, out errorClass, out errorNum);
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
throw new Nc_Exception(getError(NC_PROD_ERROR, errorClass, errorNum));
|
||||
|
||||
//If there's an error
|
||||
if (errEmgy.CodeErr != 0)
|
||||
{
|
||||
MESSAGE_TEXT MessageEmgy = new MESSAGE_TEXT();
|
||||
Cndex.MSG_EMERGENCY CndexErrorEmgy = ConverToCndexMessage(errEmgy);
|
||||
|
||||
//Translate using OSAI .DLL (a new one!)
|
||||
OSAIErrorManagerLibrary.TranslateEmergMsg(ref CndexErrorEmgy, ref MessageEmgy);
|
||||
|
||||
//Build the new String Message
|
||||
ActMSG = MessageEmgy.Line1.Trim();
|
||||
if (!String.IsNullOrWhiteSpace(MessageEmgy.Line2))
|
||||
ActMSG += "\n" + MessageEmgy.Line2.Trim();
|
||||
if (!String.IsNullOrWhiteSpace(MessageEmgy.Line3))
|
||||
ActMSG += "\n" + MessageEmgy.Line3.Trim();
|
||||
if (!String.IsNullOrWhiteSpace(MessageEmgy.Line4))
|
||||
ActMSG += "\n" + MessageEmgy.Line4.Trim();
|
||||
|
||||
Alarms.Clear();
|
||||
Alarms.Add(ActMSG);
|
||||
return;
|
||||
}
|
||||
|
||||
//------------------------------------------
|
||||
//Second Part: Read the Global Alarms
|
||||
|
||||
//Execute the method
|
||||
nReturn = OpenNC.ReadCurrentErrorMsg(Number, out err, out errorClass, out errorNum);
|
||||
|
||||
//If there's an error launch exception
|
||||
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
|
||||
throw new Nc_Exception(getError(NC_PROD_ERROR, errorClass, errorNum));
|
||||
|
||||
//If there's an error
|
||||
if (err.CodeErr != 0)
|
||||
{
|
||||
@@ -1493,6 +1531,7 @@ namespace CMS_CORE.Osai
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Convert error from Open To Cndex
|
||||
private Cndex.MSG_ERROR ConverToCndexMessage(MSGERROR OpenError)
|
||||
{
|
||||
@@ -1511,6 +1550,21 @@ namespace CMS_CORE.Osai
|
||||
|
||||
|
||||
|
||||
//Convert error from Open To Cndex
|
||||
private Cndex.MSG_EMERGENCY ConverToCndexMessage(MSGEMERGENCY OpenError)
|
||||
{
|
||||
Cndex.MSG_EMERGENCY OsaiSerie10Err = new Cndex.MSG_EMERGENCY();
|
||||
|
||||
OsaiSerie10Err.BootID = (int)OpenError.BootID;
|
||||
OsaiSerie10Err.UnIdSeq = (int)OpenError.UnIdSeq;
|
||||
OsaiSerie10Err.Code_Err = (int)OpenError.CodeErr;
|
||||
OsaiSerie10Err.FormatTxt = OpenError.FormatTxt;
|
||||
OsaiSerie10Err.Process = OpenError.Process;
|
||||
|
||||
return OsaiSerie10Err;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// Convert the internal error in a readable-String error
|
||||
private String getError(uint CMSError, uint Class, uint Num)
|
||||
@@ -1701,7 +1755,7 @@ namespace CMS_CORE.Osai
|
||||
}
|
||||
return ErrororOwner + szErrorClassDesc + ": " + szErrorDesc + " (" + Class + "-" + Num + ")";
|
||||
|
||||
default: return ErrororOwner + " Generic Osai Error - Class:" + Class + " Num:" + Num + ")";
|
||||
default: return ErrororOwner + " Generic Osai Error - Class: " + Class + " Num: " + Num;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ namespace CMS_CORE.Osai
|
||||
/// pText: MESSAGE_TEXT*
|
||||
/// </summary>
|
||||
[DllImport("OSAI_ErrorMgr.dll", EntryPoint = "TranslateEmergMsg", CallingConvention = CallingConvention.Cdecl)]
|
||||
public static extern void TranslateEmergMsg(ref MSGEMERGENCY pMsgLog, ref MESSAGE_TEXT pText);
|
||||
public static extern void TranslateEmergMsg(ref Cndex.MSG_EMERGENCY pMsgLog, ref MESSAGE_TEXT pText);
|
||||
|
||||
/// <summary>
|
||||
/// Return Type: void
|
||||
|
||||
Binary file not shown.
@@ -20,6 +20,10 @@ namespace CMS_CORE.Siemens
|
||||
const string NcNotFound2 = "networking error";
|
||||
const string NcNotFound3 = "Nc not Connected";
|
||||
const string SinumerikEnvPath = @"MotionControl\siemens\sinumerik";
|
||||
const int IDMinPLCMessage = 700000;
|
||||
const int IDMaxPLCMessage = 799999;
|
||||
const int IDMinChannel = 10000;
|
||||
const int IDMaxChannel = 19999;
|
||||
|
||||
// Siemens Path Constants
|
||||
const string PathMaxChannelNo = "/Nck/Configuration/maxnumChannels";
|
||||
@@ -48,6 +52,10 @@ namespace CMS_CORE.Siemens
|
||||
private uint SiemensLanguage;
|
||||
private List<ushort> AxisInPath;
|
||||
|
||||
// STatic variables
|
||||
private static AlarmSvc SiemensAlmSvc;
|
||||
private static Alarm[] SiemensAlarms;
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region Contructor & global methods
|
||||
|
||||
@@ -86,6 +94,14 @@ namespace CMS_CORE.Siemens
|
||||
//Read static Data
|
||||
ReadStaticNCData();
|
||||
|
||||
//Setup the alarms (Only managed in this way (Siemens Thread)
|
||||
if(SiemensAlmSvc == null)
|
||||
{
|
||||
SiemensAlarms = new Alarm[]{ };
|
||||
SiemensAlmSvc = new AlarmSvc(ConvertToSTEPLanguage(SiemensLanguage).ThreeLetterISOLanguageName);
|
||||
SiemensAlmSvc.Subscribe(AlarmsChanged);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -200,7 +216,7 @@ namespace CMS_CORE.Siemens
|
||||
//Setup variables
|
||||
DataSvc Data = new DataSvc();
|
||||
Data.Timeout = TimeoutConn;
|
||||
Data.PriorityFlag = SlPriority.highPriority;
|
||||
Data.PriorityFlag = SlPriority.highPriority;
|
||||
Item ReadItem = new Item(PathGenericNcMode + "[u"+ ProcNumber + "]");
|
||||
Item ReadItemIncr = new Item(PathIncrJog + "[u" + ProcNumber + "]");
|
||||
Item ReadItemAdv = new Item(PathAdvancedJog + "[u" + ProcNumber + "]");
|
||||
@@ -258,7 +274,9 @@ namespace CMS_CORE.Siemens
|
||||
//Get the PLC Active Alarms
|
||||
public override void PLC_RActiveAlarms(ref List<string> Alarms)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
AlarmSource s = new AlarmSource(10,"");
|
||||
|
||||
Alarms = SiemensAlarms.Where(x => x.Id >= IDMinPLCMessage && x.Id <= IDMaxPLCMessage).Select(x => x.Message).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -266,7 +284,7 @@ namespace CMS_CORE.Siemens
|
||||
//Get the process Messages
|
||||
public override void PROC_RActiveAlarms(ushort ProcNumber, ref List<string> Alarms)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
Alarms = SiemensAlarms.Where(x => x.Id < IDMinPLCMessage || x.Id > IDMaxPLCMessage).Select(x => x.Message).ToList();
|
||||
}
|
||||
|
||||
|
||||
@@ -274,29 +292,7 @@ namespace CMS_CORE.Siemens
|
||||
//Get a dictionary with the Actual position of the axes in Process
|
||||
public override void AXES_RInterpPosition(ushort ProcNumber, ref Dictionary<string, double> Axes)
|
||||
{
|
||||
//Check if the NC is Connected
|
||||
CheckConnection();
|
||||
|
||||
//Setup variables
|
||||
DataSvc Data = new DataSvc();
|
||||
Data.Timeout = TimeoutConn;
|
||||
Data.PriorityFlag = SlPriority.highPriority;
|
||||
Item ReadItem = new Item(PathRelatPosition + "[u" + ProcNumber + ",1,16]");
|
||||
|
||||
//Try to get information
|
||||
try
|
||||
{
|
||||
//Read Data
|
||||
Data.Read(ReadItem);
|
||||
|
||||
//Save Data
|
||||
//Status = ConvertToSTEPStatus((uint)ReadItem.Value);
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ThrowNCException(ex);
|
||||
}
|
||||
throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC");
|
||||
}
|
||||
|
||||
|
||||
@@ -304,7 +300,7 @@ namespace CMS_CORE.Siemens
|
||||
//Get a dictionary with the Machine position of the axes in Process
|
||||
public override void AXES_RMachinePosition(ushort ProcNumber, ref Dictionary<string, double> Axes)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC");
|
||||
}
|
||||
|
||||
|
||||
@@ -312,7 +308,7 @@ namespace CMS_CORE.Siemens
|
||||
//Get a dictionary with the Programmed position of the axes in Process
|
||||
public override void AXES_RProgrPosition(ushort ProcNumber, ref Dictionary<string, double> Axes)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC");
|
||||
}
|
||||
|
||||
|
||||
@@ -320,7 +316,7 @@ namespace CMS_CORE.Siemens
|
||||
//Get a dictionary with the Following Error of the axes in Process
|
||||
public override void AXES_RFollowingError(ushort ProcNumber, ref Dictionary<string, double> Axes)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC");
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +324,7 @@ namespace CMS_CORE.Siemens
|
||||
//Get a dictionary with the Distance To Go of the axes in Process
|
||||
public override void AXES_RDistanceToGo(ushort ProcNumber, ref Dictionary<string, double> Axes)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
throw new Nc_Exception("CMS-Core-Error: Function not allowed for this type of NC");
|
||||
}
|
||||
|
||||
#endregion
|
||||
@@ -790,6 +786,16 @@ namespace CMS_CORE.Siemens
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
#region Subordinate Private Functions
|
||||
|
||||
|
||||
|
||||
//Manage the Alarms - Called automatically on changes
|
||||
private void AlarmsChanged(Guid guid, Alarm[] alarms)
|
||||
{
|
||||
SiemensAlarms = alarms;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//Manage the Mode
|
||||
private PROC_Mode ConvertToSTEPMode(uint mode, uint JogMode, uint AdvMode)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user