Added real length real radius

This commit is contained in:
Lucio Maranta
2019-06-04 15:20:21 +00:00
parent cdc4ef2058
commit 2cf7a32987
8 changed files with 129 additions and 106 deletions
+99 -95
View File
@@ -7,8 +7,6 @@ using CMS_CORE_Library.Siemens;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Threading;
using System.Windows.Forms;
@@ -54,108 +52,114 @@ namespace CMS_CORE_Application
private void ReadBasicData()
{
PROC_MODE mode = PROC_MODE.AUTO;
PROC_STATUS status = PROC_STATUS.ERROR;
ushort procnum = 0;
string MachNumber = "";
string ModelName = "";
string SFTVersion = "";
string PPName = "";
DateTime NcTime = new DateTime();
Dictionary<string, double> Axes = new Dictionary<string, double>();
Dictionary<int, string> messages = new Dictionary<int, string>();
Stopwatch sw = new Stopwatch();
List<AlarmModel> procAlarms = new List<AlarmModel>();
List<PlcAlarmModel> plcMsg = new List<PlcAlarmModel>();
PreAndPostPowerOnModel powerOn = new PreAndPostPowerOnModel();
List<AlarmModel> ncAlarms = new List<AlarmModel>();
List<string> Lines = new List<string>();
List < HeadDataModel> Heads = new List<HeadDataModel>();
N = SetNcByType();
CmsError cmsError = N.NC_Connect();
MessageBox.Show(cmsError.localizationKey);
cmsError = N.NC_RModelName(ref ModelName);
List<uint> val = new List<uint>();
bool error = false;
string serial = "";
while (true)
try
{
/////////////////////////////////// Load basic data
cmsError = N.PROC_RMode(1, ref mode);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
PROC_MODE mode = PROC_MODE.AUTO;
PROC_STATUS status = PROC_STATUS.ERROR;
ushort procnum = 0;
string MachNumber = "";
string ModelName = "";
string SFTVersion = "";
string PPName = "";
DateTime NcTime = new DateTime();
Dictionary<string, double> Axes = new Dictionary<string, double>();
Dictionary<int, string> messages = new Dictionary<int, string>();
Stopwatch sw = new Stopwatch();
List<AlarmModel> procAlarms = new List<AlarmModel>();
List<PlcAlarmModel> plcMsg = new List<PlcAlarmModel>();
PreAndPostPowerOnModel powerOn = new PreAndPostPowerOnModel();
List<AlarmModel> ncAlarms = new List<AlarmModel>();
List<string> Lines = new List<string>();
List<HeadDataModel> Heads = new List<HeadDataModel>();
cmsError = N.PROC_RStatus(1, ref status);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
N = SetNcByType();
cmsError = N.PROC_RActiveAlarms(1, ref procAlarms);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
CmsError cmsError = N.NC_Connect();
MessageBox.Show(cmsError.localizationKey);
cmsError = N.NC_RModelName(ref ModelName);
List<uint> val = new List<uint>();
cmsError = N.NC_RActiveAlarms(ref ncAlarms);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
bool error = false;
string serial = "";
cmsError = N.PLC_RActiveMessages(ref plcMsg);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.NC_RDateTime(ref NcTime);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.PLC_RHeadsData(Heads,3);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.NC_RSerialNumber(ref serial);
if (cmsError.IsError()){ error = true; SetError(Lines, cmsError); }
Dictionary<int, string> dictionary = new Dictionary<int, string>();
cmsError = N.NC_GetTranslatedPlcMessages("it", ref dictionary);
List<M155InputIsNeededModel> b = new List<M155InputIsNeededModel>();
N.PLC_ROperatorInputIsNeeded(ref b);
////////////////////////////////////////////////////////////// TEST
Stopwatch st = new Stopwatch();
sw.Restart();
cmsError = N.NC_WMDICommand(1, "X0");
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
////////////////////////////////////////////////////////////// END TEST
if (!this.IsDisposed && this.InvokeRequired)
while (true)
{
this.Invoke((ThreadStart)delegate ()
/////////////////////////////////// Load basic data
cmsError = N.PROC_RMode(1, ref mode);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.PROC_RStatus(1, ref status);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.PROC_RActiveAlarms(1, ref procAlarms);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.NC_RActiveAlarms(ref ncAlarms);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.PLC_RActiveMessages(ref plcMsg);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.NC_RDateTime(ref NcTime);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.PLC_RHeadsData(Heads, 3);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
cmsError = N.NC_RSerialNumber(ref serial);
if (cmsError.IsError()) { error = true; SetError(Lines, cmsError); }
Dictionary<int, string> dictionary = new Dictionary<int, string>();
cmsError = N.NC_GetTranslatedPlcMessages("it", ref dictionary);
List<M155InputIsNeededModel> b = new List<M155InputIsNeededModel>();
N.PLC_ROperatorInputIsNeeded(ref b);
////////////////////////////////////////////////////////////// TEST
Stopwatch st = new Stopwatch();
sw.Restart();
cmsError = N.NC_WMDICommand(1, "X0");
sw.Stop();
Console.WriteLine(sw.ElapsedMilliseconds);
////////////////////////////////////////////////////////////// END TEST
if (!this.IsDisposed && this.InvokeRequired)
{
TXTPath1.Text = mode.ToString();
TXTStat1.Text = status.ToString();
TXTNProcess.Text = procnum.ToString();
TXTName.Text = ModelName;
TXTMachNum.Text = MachNumber;
TXTSft.Text = SFTVersion;
TXTTime.Text = sw.ElapsedMilliseconds.ToString() + " mS";
TXTAlm.Text = string.Join(Environment.NewLine, procAlarms.Select(x => x.Message));
TXTAlmNc.Text = string.Join(Environment.NewLine, ncAlarms.Select(x => x.Message));
TXTMsg.Text = string.Join(Environment.NewLine, plcMsg.Select(x => x.Id));
TXTPPName.Text = PPName;
TXTNow.Text = NcTime.ToString();
this.Invoke((ThreadStart)delegate ()
{
TXTPath1.Text = mode.ToString();
TXTStat1.Text = status.ToString();
TXTNProcess.Text = procnum.ToString();
TXTName.Text = ModelName;
TXTMachNum.Text = MachNumber;
TXTSft.Text = SFTVersion;
TXTTime.Text = sw.ElapsedMilliseconds.ToString() + " mS";
TXTAlm.Text = string.Join(Environment.NewLine, procAlarms.Select(x => x.Message));
TXTAlmNc.Text = string.Join(Environment.NewLine, ncAlarms.Select(x => x.Message));
TXTMsg.Text = string.Join(Environment.NewLine, plcMsg.Select(x => x.Id));
TXTPPName.Text = PPName;
TXTNow.Text = NcTime.ToString();
if (error == false)
Error.Text = "";
if (error == false)
Error.Text = "";
TXTPPLines.Text = string.Join(Environment.NewLine, Lines);
Connect.Enabled = false;
Disconnect.Enabled = true;
});
TXTPPLines.Text = string.Join(Environment.NewLine, Lines);
Connect.Enabled = false;
Disconnect.Enabled = true;
});
}
error = false;
if ((200 - (int)sw.ElapsedMilliseconds) < 0)
Debug.WriteLine("Ritardo " + sw.ElapsedMilliseconds);
Thread.Sleep(50);
}
error = false;
if ((200 - (int)sw.ElapsedMilliseconds) < 0)
Debug.WriteLine("Ritardo " + sw.ElapsedMilliseconds);
Thread.Sleep(50);
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
@@ -226,7 +230,7 @@ namespace CMS_CORE_Application
if (t != null)
t.Abort();
if(N != null)
if (N != null)
N.NC_Disconnect();
}
+4 -1
View File
@@ -3324,7 +3324,7 @@ namespace CMS_CORE_Library.Demo
return NO_ERROR;
}
public override CmsError TOOLS_WOffset(short offsetId, OffsetModel offset)
public override CmsError TOOLS_WOffset(short offsetId, ref OffsetModel offset)
{
offset.Id = offsetId;
@@ -3342,6 +3342,9 @@ namespace CMS_CORE_Library.Demo
return ManageException(ex);
}
offset.RealLength = offset.Length + offset.WearLength;
offset.RealRadius = offset.RealRadius + offset.WearRadius;
return NO_ERROR;
}
+7 -1
View File
@@ -3509,10 +3509,13 @@ namespace CMS_CORE_Library.Fanuc
}
}
offset.RealLength = Math.Round(offset.Length + offset.WearLength, 5);
offset.RealRadius = Math.Round(offset.Radius + offset.WearRadius, 5);
return NO_ERROR;
}
public override CmsError TOOLS_WOffset(short offsetId, OffsetModel offset)
public override CmsError TOOLS_WOffset(short offsetId, ref OffsetModel offset)
{
// Check if the NC is Connected
CmsError cmsError = CheckConnection();
@@ -3555,6 +3558,9 @@ namespace CMS_CORE_Library.Fanuc
short nReturn = Focas1.cnc_wrtofs(nLibHandle[0], offsetId, i, 8, valueToWrite);
if (nReturn != 0)
return GetNcError(nReturn);
offset.RealLength = Math.Round(offset.Length + offset.WearLength, 5);
offset.RealRadius = Math.Round(offset.Radius + offset.WearRadius, 5);
}
return NO_ERROR;
+3
View File
@@ -28,6 +28,9 @@ namespace CMS_CORE_Library.Models
public double WearRadius { get; set; }
public string UnitOfMeasure { get; set; }
public double RealLength { get; set; }
public double RealRadius { get; set; }
}
public class NcShankModel
+1 -1
View File
@@ -1674,7 +1674,7 @@ namespace CMS_CORE_Library
public abstract CmsError TOOLS_ROffset(short offsetId, ref OffsetModel offset);
public abstract CmsError TOOLS_WOffset(short offsetId, OffsetModel offset);
public abstract CmsError TOOLS_WOffset(short offsetId, ref OffsetModel offset);
public abstract CmsError TOOLS_WStartEditData();
+7 -3
View File
@@ -3600,6 +3600,9 @@ namespace CMS_CORE_Library.Osai
offset.Length = Math.Round(offsetData.LenVal[0].ValOrig / divider, 5);
offset.WearLength = Math.Round(offsetData.LenVal[0].ActChangeVal / divider, 5);
offset.UnitOfMeasure = unitOfMeasure;
offset.RealLength = Math.Round(offset.Length + offset.WearLength, 5);
offset.RealRadius = Math.Round(offset.Radius + offset.WearRadius, 5);
}
catch (Exception ex)
{
@@ -3609,7 +3612,7 @@ namespace CMS_CORE_Library.Osai
return NO_ERROR;
}
public override CmsError TOOLS_WOffset(short offsetId, OffsetModel offset)
public override CmsError TOOLS_WOffset(short offsetId, ref OffsetModel offset)
{
//Check if the NC is Connected
CmsError cmsError = CheckConnection();
@@ -3634,11 +3637,12 @@ namespace CMS_CORE_Library.Osai
offsetData.DiaVal[0].ActChangeVal = offset.WearRadius * divider;
offsetData.LenVal[0].ValOrig = offset.Length * divider;
offsetData.LenVal[0].ActChangeVal = offset.WearLength * divider;
nReturn = OpenNC.SetOffsetTabRecordII((uint)offsetId, offsetData, out errorClass, out errorNum);
if (errorClass != 0 || errorNum != 0 || nReturn == 0)
return GetNCError(errorClass, errorNum);
offset.RealLength = Math.Round(offset.Length + offset.WearLength, 5);
offset.RealRadius = Math.Round(offset.Radius + offset.WearRadius, 5);
}
catch (Exception ex)
{
+2 -1
View File
@@ -664,6 +664,7 @@ namespace CMS_CORE_Library.Siemens
try
{
FileSvc fileSvc = new FileSvc();
var a = fileSvc.ReadMdaBuffer(1);
fileSvc.WriteMdaBuffer(processId, mdiString);
}
catch(Exception ex)
@@ -4262,7 +4263,7 @@ namespace CMS_CORE_Library.Siemens
return FUNCTION_NOT_ALLOWED_ERROR;
}
public override CmsError TOOLS_WOffset(short offsetId, OffsetModel offset)
public override CmsError TOOLS_WOffset(short offsetId, ref OffsetModel offset)
{
return FUNCTION_NOT_ALLOWED_ERROR;
}
+6 -4
View File
@@ -250,8 +250,8 @@ namespace CMS_CORE_Library
new FieldsConfiguration{ Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "name", Type = "string", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = 0},
new FieldsConfiguration{ Name = "toolType", Type = "select", SelectValues = toolTypeCodeList, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "leftSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "rightSize", Type = "int", SelectValues = null, Category = "magazine", ReadOnly = false, MinValue = 1, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "leftSize", Type = "int", SelectValues = null, Category = "shankOpt", ReadOnly = false, MinValue = 1, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "rightSize", Type = "int", SelectValues = null, Category = "shankOpt", ReadOnly = false, MinValue = 1, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "tcpTable", Type = "int", SelectValues = null, Category = "tcp", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "gamma", Type = "int", SelectValues = null, Category = "gamma", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue},
new FieldsConfiguration{ Name = "rotationType", Type = "select", SelectValues = cmsRotationTypeList, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = byte.MaxValue},
@@ -345,11 +345,13 @@ namespace CMS_CORE_Library
EdgeConfiguration = new List<FieldsConfiguration>()
{
new FieldsConfiguration{Name = "id", Type = "int", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "unitOfMeasure", Type = "string", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "unitOfMeasure", Type = "string", SelectValues = null, Category = "general", ReadOnly = true, MinValue = 0, MaxValue = 0 },
new FieldsConfiguration{Name = "length", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue },
new FieldsConfiguration{Name = "radius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = 0, MaxValue = int.MaxValue },
new FieldsConfiguration{Name = "wearLength", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = int.MinValue, MaxValue = int.MaxValue },
new FieldsConfiguration{Name = "wearRadius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = int.MinValue, MaxValue = int.MaxValue }
new FieldsConfiguration{Name = "wearRadius", Type = "double", SelectValues = null, Category = "general", ReadOnly = false, MinValue = int.MinValue, MaxValue = int.MaxValue },
new FieldsConfiguration{Name = "realLength", Type = "double", SelectValues = null, Category = "general", ReadOnly = true, MinValue = int.MinValue, MaxValue = int.MaxValue }
new FieldsConfiguration{Name = "realRadius", Type = "double", SelectValues = null, Category = "general", ReadOnly = true, MinValue = int.MinValue, MaxValue = int.MaxValue },
},
EdgesAdditionalParamsConfiguration = new Dictionary<int, List<string>>() // Set value runtime, based on NC vendor
};