Merge branch 'feature/Osai_ToolTable' into develop
# Conflicts: # Libs/CMS_CORE_Library.dll # Step.Core/ThreadsFunctions.cs # Step.Core/ThreadsHandler.cs # Step.Database/DatabaseContext.cs # Step.Database/Migrations/201806220920193_InitMigration.Designer.cs # Step.Database/Migrations/201806220920193_InitMigration.cs # Step.Database/Migrations/201807120908403_InitMigration.Designer.cs # Step.Database/Migrations/201807120908403_InitMigration.cs # Step.Database/Migrations/201807120908403_InitMigration.resx # Step.Database/Migrations/201807251330036_InitMigration.Designer.cs # Step.Database/Migrations/201807251330036_InitMigration.cs # Step.Database/Step.Database.csproj # Step.Model/Constants.cs # Step.NC/NcHandler.cs # Step/Listeners/ListenersHandler.cs # Step/Step.csproj
This commit is contained in:
Binary file not shown.
@@ -3,7 +3,7 @@
|
||||
<ncConfig>
|
||||
<ncVendor>DEMO</ncVendor> <!-- NO_NC/DEMO/FANUC/SIEMENS/OSAI -->
|
||||
<showNcHMI>true</showNcHMI>
|
||||
<ncIpAddress>127.0.0.1</ncIpAddress>
|
||||
<ncIpAddress>localhost</ncIpAddress>
|
||||
<ncPort>8080</ncPort>
|
||||
<machineModel>Ares 37 OF</machineModel>
|
||||
</ncConfig>
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<toolManagerConfig>
|
||||
<familyOptIsActive>true</familyOptIsActive>
|
||||
<shankOptIsActive>false</shankOptIsActive>
|
||||
<magPositionOptIsActive>true</magPositionOptIsActive>
|
||||
<offsetOptIsActive>true</offsetOptIsActive>
|
||||
<reviveOptIsActive>true</reviveOptIsActive>
|
||||
<gammaOptIsActive>true</gammaOptIsActive>
|
||||
<lifeOptIsActive>true</lifeOptIsActive>
|
||||
<tcpOptIsActive>true</tcpOptIsActive>
|
||||
<coolingOptIsActive>true</coolingOptIsActive>
|
||||
<multidimensionalShankOptIsActive>true</multidimensionalShankOptIsActive>
|
||||
<selfAdaptivePathOptIsActive>true</selfAdaptivePathOptIsActive>
|
||||
<dynamicCompensationOptIsActive>true</dynamicCompensationOptIsActive>
|
||||
</toolManagerConfig>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
|
||||
<xs:element name="toolManagerConfig">
|
||||
<xs:complexType>
|
||||
<xs:all>
|
||||
<xs:element name="familyOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="shankOptIsActive" type="xs:boolean" minOccurs="1" maxOccurs="1"/>
|
||||
<xs:element name="magPositionOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="offsetOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="reviveOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="gammaOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="lifeOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="tcpOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="coolingOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="multidimensionalShankOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="selfAdaptivePathOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
<xs:element name="dynamicCompensationOptIsActive" type="xs:boolean" minOccurs='1' maxOccurs='1'/>
|
||||
</xs:all>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
</xs:schema>
|
||||
@@ -23,6 +23,7 @@ namespace Step.Config
|
||||
public static List<NcSoftKeysModel> NcSoftKeysConfig;
|
||||
public static List<AlarmsConfigModel> InitialAlarmsConfig;
|
||||
public static List<HeadsConfigModel> HeadsConfig;
|
||||
public static ToolManagerConfigModel ToolManagerConfig;
|
||||
|
||||
public static AreasConfigModel ProductionConfig;
|
||||
public static AreasConfigModel ToolingConfig;
|
||||
|
||||
@@ -24,6 +24,7 @@ namespace Step.Config
|
||||
ReadUserSoftKeysConfig();
|
||||
ReadAlarmsConfig();
|
||||
ReadHeadsConfig();
|
||||
ReadToolManagerConfig();
|
||||
}
|
||||
catch (System.Xml.XmlException ex)
|
||||
{
|
||||
@@ -308,6 +309,31 @@ namespace Step.Config
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private static void ReadToolManagerConfig()
|
||||
{
|
||||
XDocument xmlConfigFile = GetXmlHandlerWithValidator(TOOL_MANAGER_CONFIG_SCHEMA_PATH, TOOL_MANAGER_CONFIG_PATH);
|
||||
|
||||
// Read config from XML file
|
||||
ToolManagerConfig = xmlConfigFile
|
||||
.Elements()
|
||||
.Select(x => new ToolManagerConfigModel()
|
||||
{
|
||||
FamilyOptIsActive = Convert.ToBoolean(x.Element("familyOptIsActive").Value),
|
||||
ShankOptIsActive = Convert.ToBoolean(x.Element("shankOptIsActive").Value),
|
||||
MagPositionIsActive = Convert.ToBoolean(x.Element("magPositionOptIsActive").Value),
|
||||
OffsetOptIsActive = Convert.ToBoolean(x.Element("offsetOptIsActive").Value),
|
||||
ReviveOptIsActive = Convert.ToBoolean(x.Element("reviveOptIsActive").Value),
|
||||
GammaOptIsActive = Convert.ToBoolean(x.Element("gammaOptIsActive").Value),
|
||||
LifeOptIsActive = Convert.ToBoolean(x.Element("lifeOptIsActive").Value),
|
||||
TcpOptIsActive = Convert.ToBoolean(x.Element("tcpOptIsActive").Value),
|
||||
CoolingOptIsActive = Convert.ToBoolean(x.Element("coolingOptIsActive").Value),
|
||||
MultidimensionalShankOptIsActive = Convert.ToBoolean(x.Element("multidimensionalShankOptIsActive").Value),
|
||||
SelfAdaptivePathOptIsActive = Convert.ToBoolean(x.Element("selfAdaptivePathOptIsActive").Value),
|
||||
DynamicCompensationOptIsActive = Convert.ToBoolean(x.Element("dynamicCompensationOptIsActive").Value),
|
||||
})
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
#endregion Read config from file from configuration
|
||||
}
|
||||
}
|
||||
@@ -47,6 +47,9 @@
|
||||
<Compile Include="ServerConfigController.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="Config\toolManagerConfig.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</Content>
|
||||
<EmbeddedResource Include="Config\userSoftKeyConfig.xml">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<SubType>Designer</SubType>
|
||||
@@ -93,6 +96,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</EmbeddedResource>
|
||||
<Content Include="Config\toolManagerConfigValidator.xsd">
|
||||
<SubType>Designer</SubType>
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Step.Model\Step.Model.csproj">
|
||||
|
||||
@@ -22,6 +22,7 @@ public static class ThreadsFunctions
|
||||
private static long ReadUserSoftKeysTimer = 0, ReadUserSoftKeysTimes = 0;
|
||||
private static long ReadAxesNamesTimer = 0, ReadAxesNamesTimes = 0;
|
||||
private static long ReadHeadsTimer = 0, ReadHeadsTimes = 0;
|
||||
private static long ReadToolDataTimer = 0, ReadToolDataTimes = 0;
|
||||
|
||||
private static Thread ConnThread;
|
||||
|
||||
@@ -505,6 +506,7 @@ public static class ThreadsFunctions
|
||||
{
|
||||
// Get Data from config and PLC
|
||||
libraryError = ncHandler.GetActiveProgramInfo(out DTOActiveProgramDataModel active);
|
||||
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
else
|
||||
@@ -530,7 +532,53 @@ public static class ThreadsFunctions
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Nc threads
|
||||
public static void UpdateToolsData()
|
||||
{
|
||||
NcHandler ncHandler = new NcHandler();
|
||||
Stopwatch sw = new Stopwatch();
|
||||
|
||||
try
|
||||
{
|
||||
// Try connection
|
||||
CmsError libraryError = ncHandler.Connect();
|
||||
if (libraryError.errorCode != 0)
|
||||
ManageLibraryError(libraryError);
|
||||
|
||||
while (true)
|
||||
{
|
||||
sw.Restart();
|
||||
|
||||
// Check if client is connected
|
||||
if (ncHandler.numericalControl.NC_IsConnected())
|
||||
{
|
||||
// Get new data from PLC
|
||||
libraryError = ncHandler.GetUpdatedToolsData(out Dictionary<int, byte> updatedStatus, out Dictionary<int, uint> updatedLives);
|
||||
MessageServices.Current.Publish(UPDATE_TOOLS_DATA, null,
|
||||
new DTONewToolDataModel
|
||||
{
|
||||
UpdatedStatus = updatedStatus,
|
||||
UpdatedLives = updatedLives
|
||||
});
|
||||
}
|
||||
else
|
||||
TryNcConnection();
|
||||
sw.Stop();
|
||||
|
||||
//Update thread timer
|
||||
ReadToolDataTimer += sw.ElapsedMilliseconds;
|
||||
ReadToolDataTimes++;
|
||||
|
||||
// Wait
|
||||
Thread.Sleep(CalcSleepTime(1000, (int)sw.ElapsedMilliseconds));
|
||||
}
|
||||
}
|
||||
catch (ThreadAbortException)
|
||||
{
|
||||
ncHandler.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Nc functions threads
|
||||
|
||||
#region SupportFunctions
|
||||
|
||||
@@ -689,6 +737,12 @@ public static class ThreadsFunctions
|
||||
ReadAxesNamesTimer = 0;
|
||||
ReadAxesNamesTimes = 0;
|
||||
}
|
||||
if (ThreadsHandler.RunningThreadStatus.ContainsKey("UpdateToolsData") && ReadAxesNamesTimer != 0)
|
||||
{
|
||||
ThreadsHandler.RunningThreadStatus["UpdateToolsData"] = (ReadToolDataTimer / ReadToolDataTimes) + " mS";
|
||||
ReadToolDataTimer = 0;
|
||||
ReadToolDataTimes = 0;
|
||||
}
|
||||
|
||||
MessageServices.Current.Publish(SEND_THREADS_STATUS, null, ThreadsHandler.RunningThreadStatus);
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ namespace Step.Core
|
||||
ThreadsFunctions.ReadUserSoftKeysData,
|
||||
ThreadsFunctions.ReadHeadsData,
|
||||
ThreadsFunctions.ReadAxesNamesData,
|
||||
ThreadsFunctions.ReadActiveProgramData
|
||||
|
||||
ThreadsFunctions.ReadActiveProgramData,
|
||||
ThreadsFunctions.UpdateToolsData
|
||||
// ThreadsFunctions.ReadNcSoftKeysData,
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,445 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels.ToolModels;
|
||||
using Step.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Linq;
|
||||
|
||||
namespace Step.Database.Controllers
|
||||
{
|
||||
public class NcToolManagerController : IDisposable
|
||||
{
|
||||
public DatabaseContext dbCtx;
|
||||
|
||||
public NcToolManagerController()
|
||||
{
|
||||
// Initialize database context
|
||||
dbCtx = new DatabaseContext();
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database context
|
||||
dbCtx.Dispose();
|
||||
}
|
||||
|
||||
public List<DbNcFamilyModel> FindFamilies()
|
||||
{
|
||||
List<DbNcFamilyModel> families = dbCtx
|
||||
.Families
|
||||
.Include("Tools")
|
||||
.ToList();
|
||||
|
||||
return families;
|
||||
}
|
||||
|
||||
public List<DTONcFamilyModel> GetFamilies()
|
||||
{
|
||||
List<DbNcFamilyModel> dbFamilies = FindFamilies();
|
||||
|
||||
return dbFamilies
|
||||
.Select(x => (DTONcFamilyModel)x)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<DbNcFamilyModel> FindFamiliesByShankId(int shankId)
|
||||
{
|
||||
DbNcShankModel shank = FindShankWithTools(shankId);
|
||||
// Get only families id
|
||||
int[] ids = shank.Tools.Select(x => x.FamilyId).ToArray();
|
||||
|
||||
return FindFamilies() // Get Families
|
||||
.Where(x => ids.Contains(x.FamilyId)) // Filter by ids
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public DbNcToolModel FindTool(int toolId)
|
||||
{
|
||||
return dbCtx.Tools
|
||||
.Where(x => x.ToolId == toolId)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public DbNcShankModel FindShankWithTools(int shankId)
|
||||
{
|
||||
return dbCtx.Shanks
|
||||
.Include("Tools")
|
||||
.Where(x => x.ShankId == shankId)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public DbNcFamilyModel FindFamily(int familyId)
|
||||
{
|
||||
return dbCtx
|
||||
.Families
|
||||
.Where(x => x.FamilyId == familyId)
|
||||
.FirstOrDefault();
|
||||
}
|
||||
|
||||
public List<DbNcToolModel> FindToolsWithDependencies()
|
||||
{
|
||||
List<DbNcToolModel> tools = dbCtx
|
||||
.Tools
|
||||
.Include("Family")
|
||||
.Include("Shank")
|
||||
.ToList();
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
public List<DbNcToolModel> FindToolsByShankIdWithDependencies(int shankId)
|
||||
{
|
||||
List<DbNcToolModel> tools = FindToolsWithDependencies()
|
||||
.Where(x => x.ShankId == shankId)
|
||||
.ToList();
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
public List<DbNcToolModel> FindTools()
|
||||
{
|
||||
List<DbNcToolModel> tools = dbCtx
|
||||
.Tools
|
||||
.ToList();
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
public List<DTONcToolModel> GetTools()
|
||||
{
|
||||
List<DbNcToolModel> dbTools = FindToolsWithDependencies();
|
||||
|
||||
return dbTools
|
||||
.Select(x => (DTONcToolModel)x)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public List<DbNcShankModel> FindShanks()
|
||||
{
|
||||
List<DbNcShankModel> shanks = dbCtx
|
||||
.Shanks
|
||||
.Include("MagazinePosition")
|
||||
.ToList();
|
||||
|
||||
return shanks;
|
||||
}
|
||||
|
||||
public DbNcShankModel FindShanksByPositions(int magazineId, int positionId)
|
||||
{
|
||||
DbNcShankModel shank = FindShanks()
|
||||
.Where(x => x.MagazineId == magazineId && x.PositionId == positionId)
|
||||
.FirstOrDefault();
|
||||
|
||||
return shank;
|
||||
}
|
||||
|
||||
public List<DTONcShankModel> GetShanks()
|
||||
{
|
||||
// Get shank from database
|
||||
List<DbNcShankModel> dbShanks = dbCtx
|
||||
.Shanks
|
||||
.Include("Tools")
|
||||
.ToList();
|
||||
|
||||
// Populate db shanks
|
||||
List<DTONcShankModel> dtoShanks = dbShanks
|
||||
.Select(x => (DTONcShankModel)x)
|
||||
.ToList();
|
||||
// new List<DTONcShankModel>();
|
||||
//foreach (var shank in dbShanks)
|
||||
//{
|
||||
// //dbCtx.Shanks.Attach(shank);
|
||||
// DTONcShankModel dtoShank = (DTONcShankModel)shank;
|
||||
|
||||
// dtoShanks.Add(dtoShank);
|
||||
//}
|
||||
|
||||
return dtoShanks;
|
||||
}
|
||||
|
||||
public DTONcShankModel GetShank(int shankId)
|
||||
{
|
||||
// Get shank from database
|
||||
DbNcShankModel dbShank = dbCtx
|
||||
.Shanks
|
||||
.Where(x => x.ShankId == shankId)
|
||||
.Include("Tools")
|
||||
.FirstOrDefault();
|
||||
|
||||
// Convert into DTOModel
|
||||
DTONcShankModel dtoShanks = (DTONcShankModel)dbShank;
|
||||
|
||||
return dtoShanks;
|
||||
}
|
||||
|
||||
public List<DbNcMagazinePositionModel> FindMagazinesPositions()
|
||||
{
|
||||
List<DbNcMagazinePositionModel> positions = dbCtx
|
||||
.MagazinePositions
|
||||
.ToList();
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
public List<DbNcMagazinePositionModel> FindMagazinePositions(byte magId)
|
||||
{
|
||||
return dbCtx
|
||||
.MagazinePositions
|
||||
.Where(x => x.MagazineId == magId)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
|
||||
public List<DTONcMagazinePositionModel> GetMagazinePositions(byte magId)
|
||||
{
|
||||
// Get only magazine positions that match with magazineId
|
||||
List<DTONcMagazinePositionModel> magPos = FindMagazinePositions(magId).Select(x => (DTONcMagazinePositionModel)x).ToList();
|
||||
// Get&filter shanks by magazineId in order to get only mounted shanks in the current magazineId
|
||||
List<DbNcShankModel> shanks = dbCtx.Shanks.Where(x => x.MagazineId == magId).ToList();
|
||||
|
||||
foreach(DbNcShankModel shank in shanks)
|
||||
{
|
||||
// Populate magazinePosition shank Id
|
||||
magPos
|
||||
.Where(x => x.PositionId == shank.PositionId)
|
||||
.FirstOrDefault()
|
||||
.ShankId = shank.ShankId;
|
||||
}
|
||||
// Convert in DTOModel and return
|
||||
return magPos;
|
||||
}
|
||||
|
||||
public DbNcMagazinePositionModel FindMagazinePosition(byte magId, byte posId)
|
||||
{
|
||||
DbNcMagazinePositionModel positions = dbCtx
|
||||
.MagazinePositions
|
||||
.Where(x => x.MagazineId == magId && x.PositionId == posId)
|
||||
.FirstOrDefault();
|
||||
|
||||
return positions;
|
||||
}
|
||||
|
||||
public List<DTONcShankModel> GetMountedShanks(int magazineId)
|
||||
{
|
||||
List<DTONcShankModel> dtoShanks = GetShanks()
|
||||
.Where(x => x.MagazineId != null)
|
||||
.ToList();
|
||||
|
||||
return dtoShanks;
|
||||
}
|
||||
|
||||
public List<DbNcToolModel> GetMountedTools()
|
||||
{
|
||||
List<DbNcToolModel> tools = FindToolsWithDependencies()
|
||||
.Where(x => x.Shank.MagazineId != null)
|
||||
.ToList();
|
||||
|
||||
return tools;
|
||||
}
|
||||
|
||||
public List<DTONcShankModel> GetAvailableShanks()
|
||||
{
|
||||
List<DTONcShankModel> dtoShanks = GetShanks()
|
||||
.Where(x => x.MagazineId == null && x.Tools.Count > 0)
|
||||
.ToList();
|
||||
|
||||
return dtoShanks;
|
||||
}
|
||||
|
||||
public DbNcToolModel AddTool(DTONewNcToolModel dtoTool)
|
||||
{
|
||||
DbNcToolModel tool = (DbNcToolModel)dtoTool;
|
||||
dbCtx.Tools.Add(tool);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
// Get foreign key data
|
||||
dbCtx.Entry(tool).Reference(x => x.Family).Load();
|
||||
dbCtx.Entry(tool).Reference(x => x.Shank).Load();
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
||||
public DbNcToolModel UpdateTool(int toolId, DTONewNcToolModel dtoTool)
|
||||
{
|
||||
DbNcToolModel tool = FindTool(toolId);
|
||||
|
||||
tool.Status = ((DbNcToolModel)dtoTool).Status;
|
||||
var shankId = tool.ShankId;
|
||||
|
||||
// Update db model
|
||||
SupportFunctions.CopyProperties(dtoTool, tool);
|
||||
tool.ShankId = shankId;
|
||||
|
||||
// Save
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return tool;
|
||||
}
|
||||
|
||||
public void DeleteTool(int toolId)
|
||||
{
|
||||
DbNcToolModel tool = FindTool(toolId);
|
||||
DeleteTool(tool);
|
||||
}
|
||||
|
||||
public void DeleteTool(DbNcToolModel tool)
|
||||
{
|
||||
dbCtx.Tools.Remove(tool);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public DbNcFamilyModel AddFamily(DTONewNcFamilyModel family)
|
||||
{
|
||||
DbNcFamilyModel dbFamily = (DbNcFamilyModel)family;
|
||||
dbCtx.Families.Add(dbFamily);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return dbFamily;
|
||||
}
|
||||
|
||||
public DbNcFamilyModel UpdateFamily(int familyId, DTONewNcFamilyModel family)
|
||||
{
|
||||
DbNcFamilyModel dbFamily = FindFamily(familyId);
|
||||
// Copy data from NewModel to DbModel
|
||||
SupportFunctions.CopyProperties(family, dbFamily);
|
||||
// Set cooling byte
|
||||
dbFamily.CoolingByte = ((DbNcFamilyModel)family).CoolingByte;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
// Connect tools data
|
||||
dbCtx.Entry(dbFamily).Collection(x => x.Tools).Load();
|
||||
|
||||
return dbFamily;
|
||||
}
|
||||
|
||||
public void DeleteFamily(DbNcFamilyModel family)
|
||||
{
|
||||
dbCtx.Families.Attach(family);
|
||||
dbCtx.Families.Remove(family);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public DbNcShankModel AddShank(DTONewNcShankModel shank)
|
||||
{
|
||||
DbNcShankModel dbShank = (DbNcShankModel)shank;
|
||||
dbCtx.Shanks.Add(dbShank);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
|
||||
return dbShank;
|
||||
}
|
||||
|
||||
public DbNcShankModel UpdateShank(int shankId, DTONewNcShankModel dtoShank)
|
||||
{
|
||||
DbNcShankModel ncShank = FindShankWithTools(shankId);
|
||||
|
||||
return UpdateShank(ncShank, dtoShank);
|
||||
}
|
||||
|
||||
public DbNcShankModel UpdateShank(DbNcShankModel dbShank, DTONewNcShankModel dtoShank)
|
||||
{
|
||||
dbShank.MagazinePositionType = dtoShank.MagazinePositionType;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
dbCtx.Entry(dbShank).Collection(x => x.Tools).Load();
|
||||
|
||||
return dbShank;
|
||||
}
|
||||
|
||||
public DbNcShankModel DeleteShank(int shankId)
|
||||
{
|
||||
DbNcShankModel shank = FindShankWithTools(shankId);
|
||||
DeleteShank(shank);
|
||||
|
||||
return shank;
|
||||
}
|
||||
|
||||
public void DeleteShank(DbNcShankModel shank)
|
||||
{
|
||||
dbCtx.Shanks.Remove(shank);
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public DbNcMagazinePositionModel UpdatePosition(DbNcMagazinePositionModel dbPos, DTONcMagazinePositionModel dtoPos)
|
||||
{
|
||||
dbCtx.MagazinePositions.Attach(dbPos);
|
||||
dbPos.Type = dtoPos.Type;
|
||||
dbPos.Disabled = dtoPos.Disabled;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return dbPos;
|
||||
}
|
||||
|
||||
public DbNcMagazinePositionModel LoadShankInMagazine(byte magazineId, byte positionId, DbNcShankModel shank)
|
||||
{
|
||||
dbCtx.Shanks.Attach(shank);
|
||||
// Set ids with new positions
|
||||
shank.MagazineId = magazineId;
|
||||
shank.PositionId = positionId;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return FindMagazinePosition(magazineId, positionId);
|
||||
}
|
||||
|
||||
public DbNcMagazinePositionModel UnloadShankInMagazine(byte magazineId, byte positionId, DbNcShankModel shank)
|
||||
{
|
||||
dbCtx.Shanks.Attach(shank);
|
||||
// set id to null
|
||||
shank.MagazineId = null;
|
||||
shank.PositionId = null;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return FindMagazinePosition(magazineId, positionId);
|
||||
}
|
||||
|
||||
public DTONcShankModel LoadToolIntoShank(DbNcToolModel tool, int shankId)
|
||||
{
|
||||
dbCtx.Tools.Attach(tool);
|
||||
// Set tool shankId
|
||||
tool.ShankId = shankId;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return GetShank(shankId);
|
||||
}
|
||||
|
||||
public DTONcShankModel UnloadToolFromShank(DbNcToolModel tool)
|
||||
{
|
||||
dbCtx.Tools.Attach(tool);
|
||||
int? shankId = tool.ShankId;
|
||||
// Set to null shankId
|
||||
tool.ShankId = null;
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
|
||||
return GetShank(shankId.Value);
|
||||
}
|
||||
|
||||
public void SetupMagazinePositions(List<DbNcMagazinePositionModel> config)
|
||||
{
|
||||
dbCtx.MagazinePositions.AddRange(config);
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
|
||||
public void UpdateToolsData(List<DbNcToolModel> tools)
|
||||
{
|
||||
foreach (var tool in tools)
|
||||
{
|
||||
DbNcToolModel tmpTool = dbCtx.Tools.Where(x => x.ToolId == tool.ToolId).FirstOrDefault();
|
||||
tmpTool = tool;
|
||||
}
|
||||
|
||||
dbCtx.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -30,8 +30,14 @@ namespace Step.Database
|
||||
public DbSet<MaintenanceFileModel> MaintenanceFiles { get; set; }
|
||||
public DbSet<FavoriteUserSoftkeyModel> FavoriteUserSoftkeys { get; set; }
|
||||
|
||||
public DbSet<DbNcFamilyModel> Families { get; set; }
|
||||
public DbSet<DbNcShankModel> Shanks { get; set; }
|
||||
public DbSet<DbNcToolModel> Tools { get; set; }
|
||||
public DbSet<DbNcMagazinePositionModel> MagazinePositions { get; set; }
|
||||
|
||||
// Create migration string
|
||||
public static string CONNECTION_STRING = "Server = " + "localhost" + "; Database=" + DATABASE_NAME +";Uid="+ DATABASE_USER +";Pwd="+ DATABASE_PWD +";";
|
||||
public static string CONNECTION_STRING = "Server = " + "localhost" + "; Database=" + DATABASE_NAME + ";Uid=" + DATABASE_USER + ";Pwd=" + DATABASE_PWD + ";";
|
||||
|
||||
// public static string CONNECTION_STRING = "Server = " + ServerStartupConfig.DatabaseAddress + "; Database=" + DATABASE_NAME +";Uid="+ DATABASE_USER +";Pwd="+ DATABASE_PWD +";";
|
||||
|
||||
public DatabaseContext()
|
||||
@@ -77,25 +83,19 @@ namespace Step.Database
|
||||
AllFunctionalityDisabled = functionsAccess.FindAllFunctionsAndDisableAll();
|
||||
}
|
||||
}
|
||||
catch (MySql.Data.MySqlClient.MySqlException ex)
|
||||
{
|
||||
if (ex.Number == 0)
|
||||
{
|
||||
//dbContext.Database.Initialize(true);
|
||||
}
|
||||
else if (ex.Number == 1042) // Can't find MySQLServer
|
||||
{
|
||||
Manage(ERROR_LEVEL.FATAL, ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
Manage(ERROR_LEVEL.ERROR, ex);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Manage(ERROR_LEVEL.FATAL, ex);
|
||||
}
|
||||
|
||||
|
||||
//catch (MySql.Data.MySqlClient.MySqlException ex)
|
||||
//{
|
||||
// if (ex.Number == 1042) // Can't find MySQLServer
|
||||
// Manage(ERROR_LEVEL.FATAL, ex);
|
||||
// else
|
||||
// Manage(ERROR_LEVEL.ERROR, ex);
|
||||
//}
|
||||
}
|
||||
|
||||
public static void FindOrCreateMachineUniqueId()
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
// <auto-generated />
|
||||
namespace Step.Database.Migrations
|
||||
{
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Data.Entity.Migrations;
|
||||
using System.Data.Entity.Migrations.Infrastructure;
|
||||
using System.Resources;
|
||||
|
||||
[GeneratedCode("EntityFramework.Migrations", "6.2.0-61023")]
|
||||
public sealed partial class InitMigration : IMigrationMetadata
|
||||
{
|
||||
private readonly ResourceManager Resources = new ResourceManager(typeof(InitMigration));
|
||||
|
||||
string IMigrationMetadata.Id
|
||||
{
|
||||
get { return "201807251330036_InitMigration"; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Source
|
||||
{
|
||||
get { return null; }
|
||||
}
|
||||
|
||||
string IMigrationMetadata.Target
|
||||
{
|
||||
get { return Resources.GetString("Target"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,268 @@
|
||||
namespace Step.Database.Migrations
|
||||
{
|
||||
using System;
|
||||
using System.Data.Entity.Migrations;
|
||||
|
||||
public partial class InitMigration : DbMigration
|
||||
{
|
||||
public override void Up()
|
||||
{
|
||||
CreateTable(
|
||||
"dbo.family",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
type = c.Byte(nullable: false),
|
||||
right_size = c.Byte(nullable: false),
|
||||
left_size = c.Byte(nullable: false),
|
||||
tcp_table = c.Byte(nullable: false),
|
||||
gamma = c.Byte(nullable: false),
|
||||
rotation_type = c.Byte(nullable: false),
|
||||
cooling_byte = c.Byte(nullable: false),
|
||||
max_speed = c.Int(nullable: false),
|
||||
max_load = c.Byte(nullable: false),
|
||||
min_load_pct_autoload = c.Byte(nullable: false),
|
||||
max_load_pct_autoload = c.Byte(nullable: false),
|
||||
dynamic_compensation = c.Byte(nullable: false),
|
||||
min_load_dynamic_comp = c.Byte(nullable: false),
|
||||
max_load_dynamic_comp = c.Byte(nullable: false),
|
||||
life_type = c.Byte(nullable: false),
|
||||
nominal_life = c.Int(nullable: false),
|
||||
revive_delta = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.tool",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
offset_length = c.Int(nullable: false),
|
||||
residual_life = c.Int(nullable: false),
|
||||
residual_revive = c.Int(nullable: false),
|
||||
status = c.Byte(nullable: false),
|
||||
family_id = c.Int(nullable: false),
|
||||
shank_id = c.Int(),
|
||||
offsetId1 = c.Int(),
|
||||
offsetId2 = c.Int(),
|
||||
offsetId3 = c.Int(),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.family", t => t.family_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.shank", t => t.shank_id)
|
||||
.Index(t => t.family_id)
|
||||
.Index(t => t.shank_id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.shank",
|
||||
c => new
|
||||
{
|
||||
magazine_id = c.Byte(),
|
||||
position_id = c.Byte(),
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
balluf = c.Int(),
|
||||
magazine_position_type = c.Byte(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.magazine_position", t => new { t.magazine_id, t.position_id })
|
||||
.Index(t => new { t.magazine_id, t.position_id });
|
||||
|
||||
CreateTable(
|
||||
"dbo.magazine_position",
|
||||
c => new
|
||||
{
|
||||
magazine_id = c.Byte(nullable: false),
|
||||
position_id = c.Byte(nullable: false),
|
||||
type = c.Byte(nullable: false),
|
||||
disabled = c.Boolean(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => new { t.magazine_id, t.position_id });
|
||||
|
||||
CreateTable(
|
||||
"dbo.function_access",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
write_level_min = c.Int(nullable: false),
|
||||
read_level_min = c.Int(nullable: false),
|
||||
area = c.String(unicode: false),
|
||||
enabled = c.Boolean(nullable: false),
|
||||
plc_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.machine",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
unique_id = c.String(unicode: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.machine_user",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
machine_id = c.Int(nullable: false),
|
||||
user_id = c.Int(nullable: false),
|
||||
role_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.machine", t => t.machine_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.role", t => t.role_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.user", t => t.user_id, cascadeDelete: true)
|
||||
.Index(t => new { t.machine_id, t.user_id }, unique: true, clustered: true, name: "unique_machine_user")
|
||||
.Index(t => t.role_id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.role",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
name = c.String(unicode: false),
|
||||
level = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.user",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
username = c.String(nullable: false, unicode: false),
|
||||
first_name = c.String(unicode: false),
|
||||
last_name = c.String(unicode: false),
|
||||
password = c.String(unicode: false),
|
||||
security_stamp = c.String(unicode: false),
|
||||
language = c.String(unicode: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.maintenance_file",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
file_name = c.String(unicode: false),
|
||||
local_file_name = c.String(unicode: false),
|
||||
maintenance_id = c.Int(nullable: false),
|
||||
user_id = c.Int(),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.maintenance", t => t.maintenance_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.user", t => t.user_id)
|
||||
.Index(t => t.maintenance_id)
|
||||
.Index(t => t.user_id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.maintenance",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
intervall = c.Double(),
|
||||
deadline = c.DateTime(nullable: false, precision: 0),
|
||||
type = c.Int(nullable: false),
|
||||
counter_id = c.Int(nullable: false),
|
||||
title = c.String(unicode: false),
|
||||
description = c.String(unicode: false),
|
||||
unit_of_measure = c.Int(),
|
||||
creation_date = c.DateTime(nullable: false, precision: 0),
|
||||
last_expiration_date = c.DateTime(precision: 0),
|
||||
user_id = c.Int(),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.user", t => t.user_id)
|
||||
.Index(t => t.user_id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.maintenance_note",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
message = c.String(unicode: false),
|
||||
user_id = c.Int(nullable: false),
|
||||
maintenance_id = c.Int(nullable: false),
|
||||
timestamp = c.DateTime(nullable: false, precision: 0),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.maintenance", t => t.maintenance_id, cascadeDelete: true)
|
||||
.ForeignKey("dbo.user", t => t.user_id, cascadeDelete: true)
|
||||
.Index(t => t.user_id)
|
||||
.Index(t => t.maintenance_id);
|
||||
|
||||
CreateTable(
|
||||
"dbo.performed_maintenance",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
date = c.DateTime(nullable: false, precision: 0),
|
||||
counter_value = c.Int(nullable: false),
|
||||
maintenance = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.maintenance", t => t.maintenance, cascadeDelete: true)
|
||||
.Index(t => t.maintenance);
|
||||
|
||||
CreateTable(
|
||||
"dbo.session",
|
||||
c => new
|
||||
{
|
||||
id = c.Int(nullable: false, identity: true),
|
||||
token = c.String(unicode: false),
|
||||
machine_user_id = c.Int(nullable: false),
|
||||
})
|
||||
.PrimaryKey(t => t.id)
|
||||
.ForeignKey("dbo.machine_user", t => t.machine_user_id, cascadeDelete: true)
|
||||
.Index(t => t.machine_user_id);
|
||||
|
||||
}
|
||||
|
||||
public override void Down()
|
||||
{
|
||||
DropForeignKey("dbo.session", "machine_user_id", "dbo.machine_user");
|
||||
DropForeignKey("dbo.performed_maintenance", "maintenance", "dbo.maintenance");
|
||||
DropForeignKey("dbo.maintenance_note", "user_id", "dbo.user");
|
||||
DropForeignKey("dbo.maintenance_note", "maintenance_id", "dbo.maintenance");
|
||||
DropForeignKey("dbo.maintenance_file", "user_id", "dbo.user");
|
||||
DropForeignKey("dbo.maintenance_file", "maintenance_id", "dbo.maintenance");
|
||||
DropForeignKey("dbo.maintenance", "user_id", "dbo.user");
|
||||
DropForeignKey("dbo.machine_user", "user_id", "dbo.user");
|
||||
DropForeignKey("dbo.machine_user", "role_id", "dbo.role");
|
||||
DropForeignKey("dbo.machine_user", "machine_id", "dbo.machine");
|
||||
DropForeignKey("dbo.tool", "shank_id", "dbo.shank");
|
||||
DropForeignKey("dbo.shank", new[] { "magazine_id", "position_id" }, "dbo.magazine_position");
|
||||
DropForeignKey("dbo.tool", "family_id", "dbo.family");
|
||||
DropIndex("dbo.session", new[] { "machine_user_id" });
|
||||
DropIndex("dbo.performed_maintenance", new[] { "maintenance" });
|
||||
DropIndex("dbo.maintenance_note", new[] { "maintenance_id" });
|
||||
DropIndex("dbo.maintenance_note", new[] { "user_id" });
|
||||
DropIndex("dbo.maintenance", new[] { "user_id" });
|
||||
DropIndex("dbo.maintenance_file", new[] { "user_id" });
|
||||
DropIndex("dbo.maintenance_file", new[] { "maintenance_id" });
|
||||
DropIndex("dbo.machine_user", new[] { "role_id" });
|
||||
DropIndex("dbo.machine_user", "unique_machine_user");
|
||||
DropIndex("dbo.shank", new[] { "magazine_id", "position_id" });
|
||||
DropIndex("dbo.tool", new[] { "shank_id" });
|
||||
DropIndex("dbo.tool", new[] { "family_id" });
|
||||
DropTable("dbo.session");
|
||||
DropTable("dbo.performed_maintenance");
|
||||
DropTable("dbo.maintenance_note");
|
||||
DropTable("dbo.maintenance");
|
||||
DropTable("dbo.maintenance_file");
|
||||
DropTable("dbo.user");
|
||||
DropTable("dbo.role");
|
||||
DropTable("dbo.machine_user");
|
||||
DropTable("dbo.machine");
|
||||
DropTable("dbo.function_access");
|
||||
DropTable("dbo.magazine_position");
|
||||
DropTable("dbo.shank");
|
||||
DropTable("dbo.tool");
|
||||
DropTable("dbo.family");
|
||||
}
|
||||
}
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
@@ -70,17 +70,17 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Controllers\UserSoftkeysController.cs" />
|
||||
<Compile Include="Controllers\FunctionsAccessController.cs" />
|
||||
<Compile Include="Controllers\MachinesController.cs" />
|
||||
<Compile Include="Controllers\MaintenancesController.cs" />
|
||||
<Compile Include="Controllers\NcToolManagerController.cs" />
|
||||
<Compile Include="Controllers\SessionsController.cs" />
|
||||
<Compile Include="Controllers\UsersController.cs" />
|
||||
<Compile Include="Controllers\MachinesUsersController.cs" />
|
||||
<Compile Include="DatabaseContext.cs" />
|
||||
<Compile Include="Migrations\201807120908403_InitMigration.cs" />
|
||||
<Compile Include="Migrations\201807120908403_InitMigration.Designer.cs">
|
||||
<DependentUpon>201807120908403_InitMigration.cs</DependentUpon>
|
||||
<Compile Include="Migrations\201807251330036_InitMigration.cs" />
|
||||
<Compile Include="Migrations\201807251330036_InitMigration.Designer.cs">
|
||||
<DependentUpon>201807251330036_InitMigration.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Migrations\Configuration.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
@@ -116,8 +116,8 @@
|
||||
<None Include="App.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="Migrations\201807120908403_InitMigration.resx">
|
||||
<DependentUpon>201807120908403_InitMigration.cs</DependentUpon>
|
||||
<EmbeddedResource Include="Migrations\201807251330036_InitMigration.resx">
|
||||
<DependentUpon>201807251330036_InitMigration.cs</DependentUpon>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.ConfigModels
|
||||
{
|
||||
public class ToolManagerConfigModel
|
||||
{
|
||||
public bool FamilyOptIsActive { get; set; }
|
||||
public bool ShankOptIsActive { get; set; }
|
||||
public bool MagPositionIsActive { get; set; }
|
||||
public bool OffsetOptIsActive { get; set; }
|
||||
public bool ReviveOptIsActive { get; set; }
|
||||
public bool GammaOptIsActive { get; set; }
|
||||
public bool LifeOptIsActive { get; set; }
|
||||
public bool TcpOptIsActive { get; set; }
|
||||
public bool CoolingOptIsActive { get; set; }
|
||||
public bool MultidimensionalShankOptIsActive { get; set; }
|
||||
public bool SelfAdaptivePathOptIsActive { get; set; }
|
||||
public bool DynamicCompensationOptIsActive { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.ConfigModels
|
||||
{
|
||||
public class ToolTableConfigModel
|
||||
{
|
||||
public bool FamilyOption;
|
||||
public bool MultiToolOption;
|
||||
public bool MagazinePosition;
|
||||
}
|
||||
}
|
||||
@@ -126,6 +126,9 @@ namespace Step.Model
|
||||
public const string NC_SOFTKEYS_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "ncSoftKeyConfigValidator.xsd";
|
||||
public const string NC_SOFTKEYS_CONFIG_PATH = CONFIG_DIRECTORY + "ncSoftKeyConfig.xml";
|
||||
|
||||
public const string TOOL_MANAGER_CONFIG_SCHEMA_PATH = CONFIG_DIRECTORY + "toolManagerConfigValidator.xsd";
|
||||
public const string TOOL_MANAGER_CONFIG_PATH = CONFIG_DIRECTORY + "toolManagerConfig.xml";
|
||||
|
||||
public static string WEBSITE_DIRECTORY = Path.Combine(BASE_PATH, "..", "wwwroot");
|
||||
public static string LANGUAGE_PACK_DIRECTORY = BASE_PATH + "\\languages\\";
|
||||
public static string LANGUAGE_SCHEMA_PATH = BASE_PATH + "\\LanguageValidator.xsd";
|
||||
@@ -136,6 +139,7 @@ namespace Step.Model
|
||||
public const string SEND_NC_STATUS = "NC_STATUS";
|
||||
public const string SEND_THREADS_STATUS = "THREAD_STATUS";
|
||||
public const string SHOW_MSG_UI = "SHOW_MSG_UI";
|
||||
public const string SEND_ERROR_TO_UI = "SEND_ERROR_TO_UI";
|
||||
|
||||
// MVVM Messages to signalR tasks
|
||||
public const string SEND_ALARMS = "SEND_ALARMS";
|
||||
@@ -151,6 +155,7 @@ namespace Step.Model
|
||||
public const string SEND_AXIS_NAMES_DATA = "SEND_AXIS_NAMES_DATA";
|
||||
public const string SEND_MAGAZINES_STATUS = "SEND_MAGAZINES_STATUS";
|
||||
public const string SEND_ACTIVE_PROGRAM_DATA = "SEND_ACTIVE_PROGRAM_DATA";
|
||||
public const string UPDATE_TOOLS_DATA = "UPDATE_TOOLS_DATA";
|
||||
|
||||
public const string BROADCAST_DATA = "BROADCAST_DATA";
|
||||
|
||||
@@ -175,5 +180,13 @@ namespace Step.Model
|
||||
public const string TOOL_MANAGER = "toolManager";
|
||||
public const string MAINTENANCE = "maintenance";
|
||||
}
|
||||
|
||||
public static class API_ERROR_KEYS
|
||||
{
|
||||
public const string INCORRECT_PARAMETERS = "error_incorrect_parameters";
|
||||
public const string MAGAZINE_POSITION_OCCUPIED = "error_magazine_position_occupied";
|
||||
public const string TOOL_IS_MOUNTED = "error_tool_mounted";
|
||||
public const string OPTION_NOT_ACTIVE = "error_option_not_active";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,6 +44,11 @@
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class DTOSpindleModel : DTOHeadModel
|
||||
@@ -73,6 +78,11 @@
|
||||
// Call Parent equals
|
||||
return base.Equals(item);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class DTOAbrasiveWaterJet : DTOHeadModel
|
||||
@@ -102,6 +112,11 @@
|
||||
// Call Parent equals
|
||||
return base.Equals(item);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
|
||||
public class DTOWaterJet : DTOHeadModel
|
||||
@@ -123,5 +138,10 @@
|
||||
// Call Parent equals
|
||||
return base.Equals(item);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return base.GetHashCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,242 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
public class DTONewNcFamilyModel
|
||||
{
|
||||
[Required]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte Type { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte RightSize { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte LeftSize { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte TcpTable { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte Gamma { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte RotationType { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool Cooling { get; set; }
|
||||
[Required]
|
||||
public bool Cooling1 { get; set; }
|
||||
[Required]
|
||||
public bool Cooling2 { get; set; }
|
||||
[Required]
|
||||
public bool Cooling3 { get; set; }
|
||||
[Required]
|
||||
public bool Cooling4 { get; set; }
|
||||
[Required]
|
||||
public bool Cooling5 { get; set; }
|
||||
[Required]
|
||||
public bool Cooling6 { get; set; }
|
||||
[Required]
|
||||
public bool Cooling7 { get; set; }
|
||||
|
||||
[Required]
|
||||
public int MaxSpeed { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte MaxLoad { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte MinLoadPctAutoload { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte MaxLoadPctAutoload { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte DynamicCompensation { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte MinLoadDynamicCompensation { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte MaxLoadDynamicCompensation { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte LifeType { get; set; }
|
||||
|
||||
[Required]
|
||||
public int NominalLife { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ReviveDelta { get; set; }
|
||||
|
||||
public static explicit operator DTONewNcFamilyModel(DbNcFamilyModel obj)
|
||||
{
|
||||
// Get bit values
|
||||
BitArray coolingByte = new BitArray(new byte[] { obj.CoolingByte });
|
||||
bool[] bits = new bool[8];
|
||||
coolingByte.CopyTo(bits, 0);
|
||||
|
||||
return new DTONcFamilyModel()
|
||||
{
|
||||
Id = obj.FamilyId,
|
||||
Name = obj.Name,
|
||||
Type = obj.Type,
|
||||
RightSize = obj.RightSize,
|
||||
LeftSize = obj.LeftSize,
|
||||
TcpTable = obj.TcpTable,
|
||||
Gamma = obj.Gamma,
|
||||
RotationType = obj.RotationType,
|
||||
Cooling = bits[0],
|
||||
Cooling1 = bits[1],
|
||||
Cooling2 = bits[2],
|
||||
Cooling3 = bits[3],
|
||||
Cooling4 = bits[4],
|
||||
Cooling5 = bits[5],
|
||||
Cooling6 = bits[6],
|
||||
Cooling7 = bits[7],
|
||||
MaxSpeed = obj.MaxSpeed,
|
||||
MaxLoad = obj.MaxLoad,
|
||||
MinLoadDynamicCompensation = obj.MinLoadDynamicCompensation,
|
||||
MaxLoadDynamicCompensation = obj.MaxLoadDynamicCompensation,
|
||||
MaxLoadPctAutoload = obj.MaxLoadPctAutoload,
|
||||
MinLoadPctAutoload = obj.MinLoadPctAutoload,
|
||||
DynamicCompensation = obj.DynamicCompensation,
|
||||
LifeType = obj.LifeType,
|
||||
NominalLife = obj.NominalLife,
|
||||
ReviveDelta = obj.ReviveDelta
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcFamilyModel(DTONewNcFamilyModel obj)
|
||||
{
|
||||
// Prepare status byte
|
||||
bool[] result = new bool[8] { obj.Cooling, obj.Cooling1, obj.Cooling2, obj.Cooling3, obj.Cooling4, obj.Cooling5, obj.Cooling6, obj.Cooling7 };
|
||||
byte coolingByte = ConvertArrayToByte(result);
|
||||
|
||||
return new DbNcFamilyModel()
|
||||
{
|
||||
Name = obj.Name,
|
||||
Type = obj.Type,
|
||||
RightSize = obj.RightSize,
|
||||
LeftSize = obj.LeftSize,
|
||||
TcpTable = obj.TcpTable,
|
||||
Gamma = obj.Gamma,
|
||||
RotationType = obj.RotationType,
|
||||
CoolingByte = coolingByte,
|
||||
MaxSpeed = obj.MaxSpeed,
|
||||
MaxLoad = obj.MaxLoad,
|
||||
MinLoadDynamicCompensation = obj.MinLoadDynamicCompensation,
|
||||
MaxLoadDynamicCompensation = obj.MaxLoadDynamicCompensation,
|
||||
MaxLoadPctAutoload = obj.MaxLoadPctAutoload,
|
||||
MinLoadPctAutoload = obj.MinLoadPctAutoload,
|
||||
DynamicCompensation = obj.DynamicCompensation,
|
||||
LifeType = obj.LifeType,
|
||||
NominalLife = obj.NominalLife,
|
||||
ReviveDelta = obj.ReviveDelta,
|
||||
};
|
||||
}
|
||||
|
||||
protected static byte ConvertArrayToByte(bool[] bits)
|
||||
{
|
||||
BitArray bitField = new BitArray(bits); //BitArray takes a bool[]
|
||||
byte[] bytes = new byte[1];
|
||||
bitField.CopyTo(bytes, 0);
|
||||
|
||||
return bytes[0];
|
||||
}
|
||||
}
|
||||
|
||||
public class DTONcFamilyModel : DTONewNcFamilyModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public List<DTONcToolModel> Tools { get; set; }
|
||||
|
||||
public static explicit operator DTONcFamilyModel(DbNcFamilyModel obj)
|
||||
{
|
||||
List<DTONcToolModel> tools = new List<DTONcToolModel>();
|
||||
|
||||
if (obj.Tools != null)
|
||||
foreach (var tool in obj.Tools)
|
||||
{
|
||||
tools.Add((DTONcToolModel)tool);
|
||||
}
|
||||
|
||||
// Get bit values
|
||||
BitArray coolingByte = new BitArray(new byte[] { obj.CoolingByte });
|
||||
bool[] bits = new bool[8];
|
||||
coolingByte.CopyTo(bits, 0);
|
||||
|
||||
return new DTONcFamilyModel()
|
||||
{
|
||||
Id = obj.FamilyId,
|
||||
Name = obj.Name,
|
||||
Type = obj.Type,
|
||||
RightSize = obj.RightSize,
|
||||
LeftSize = obj.LeftSize,
|
||||
TcpTable = obj.TcpTable,
|
||||
Gamma = obj.Gamma,
|
||||
RotationType = obj.RotationType,
|
||||
Cooling = bits[0],
|
||||
Cooling1 = bits[1],
|
||||
Cooling2 = bits[2],
|
||||
Cooling3 = bits[3],
|
||||
Cooling4 = bits[4],
|
||||
Cooling5 = bits[5],
|
||||
Cooling6 = bits[6],
|
||||
Cooling7 = bits[7],
|
||||
MaxSpeed = obj.MaxSpeed,
|
||||
MaxLoad = obj.MaxLoad,
|
||||
MinLoadDynamicCompensation = obj.MinLoadDynamicCompensation,
|
||||
MaxLoadDynamicCompensation = obj.MaxLoadDynamicCompensation,
|
||||
MaxLoadPctAutoload = obj.MaxLoadPctAutoload,
|
||||
MinLoadPctAutoload = obj.MinLoadPctAutoload,
|
||||
DynamicCompensation = obj.DynamicCompensation,
|
||||
LifeType = obj.LifeType,
|
||||
NominalLife = obj.NominalLife,
|
||||
ReviveDelta = obj.ReviveDelta,
|
||||
Tools = tools
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcFamilyModel(DTONcFamilyModel obj)
|
||||
{
|
||||
// Prepare status byte
|
||||
bool[] result = new bool[8] { obj.Cooling, obj.Cooling1, obj.Cooling2, obj.Cooling3, obj.Cooling4, obj.Cooling5, obj.Cooling6, obj.Cooling7 };
|
||||
byte coolingByte = ConvertArrayToByte(result);
|
||||
|
||||
return new DbNcFamilyModel()
|
||||
{
|
||||
FamilyId = obj.Id,
|
||||
Name = obj.Name,
|
||||
Type = obj.Type,
|
||||
RightSize = obj.RightSize,
|
||||
LeftSize = obj.LeftSize,
|
||||
TcpTable = obj.TcpTable,
|
||||
Gamma = obj.Gamma,
|
||||
RotationType = obj.RotationType,
|
||||
CoolingByte = coolingByte,
|
||||
MaxSpeed = obj.MaxSpeed,
|
||||
MaxLoad = obj.MaxLoad,
|
||||
MinLoadDynamicCompensation = obj.MinLoadDynamicCompensation,
|
||||
MaxLoadDynamicCompensation = obj.MaxLoadDynamicCompensation,
|
||||
MaxLoadPctAutoload = obj.MaxLoadPctAutoload,
|
||||
MinLoadPctAutoload = obj.MinLoadPctAutoload,
|
||||
DynamicCompensation = obj.DynamicCompensation,
|
||||
LifeType = obj.LifeType,
|
||||
NominalLife = obj.NominalLife,
|
||||
ReviveDelta = obj.ReviveDelta,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
public class DTONcMagazinePositionModel
|
||||
{
|
||||
public byte MagazineId { get; set; }
|
||||
|
||||
public byte PositionId { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte Type { get; set; }
|
||||
|
||||
public int? ShankId { get; set; }
|
||||
|
||||
public static explicit operator DTONcMagazinePositionModel(DbNcMagazinePositionModel obj)
|
||||
{
|
||||
return new DTONcMagazinePositionModel()
|
||||
{
|
||||
MagazineId = obj.MagazineId,
|
||||
PositionId = obj.PositionId,
|
||||
Disabled = obj.Disabled,
|
||||
Type = obj.Type
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcMagazinePositionModel(DTONcMagazinePositionModel obj)
|
||||
{
|
||||
return new DbNcMagazinePositionModel()
|
||||
{
|
||||
MagazineId = obj.MagazineId,
|
||||
PositionId = obj.PositionId,
|
||||
Disabled = obj.Disabled,
|
||||
Type = obj.Type
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
public class DTONcMountedShankModel
|
||||
{
|
||||
public byte PositionId;
|
||||
public byte MagazineId;
|
||||
public int ShankId;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
public class DTONewNcShankModel
|
||||
{
|
||||
[Required]
|
||||
public ushort? Balluf { get; set; }
|
||||
|
||||
[Required]
|
||||
public byte MagazinePositionType { get; set; }
|
||||
|
||||
public static explicit operator DTONewNcShankModel(DbNcShankModel obj)
|
||||
{
|
||||
return new DTONewNcShankModel()
|
||||
{
|
||||
Balluf = (ushort)obj.Balluf,
|
||||
MagazinePositionType = obj.MagazinePositionType
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcShankModel(DTONewNcShankModel obj)
|
||||
{
|
||||
return new DbNcShankModel()
|
||||
{
|
||||
Balluf = obj.Balluf,
|
||||
MagazinePositionType = obj.MagazinePositionType
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class DTONcShankModel : DTONewNcShankModel
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Range(1, byte.MaxValue)]
|
||||
public byte? MagazineId { get; set; }
|
||||
|
||||
[Range(1, byte.MaxValue)]
|
||||
public byte? PositionId { get; set; }
|
||||
|
||||
public List<DTONcToolModel> Tools { get; set; }
|
||||
|
||||
public static explicit operator DTONcShankModel(DbNcShankModel obj)
|
||||
{
|
||||
List<DTONcToolModel> tools = new List<DTONcToolModel>();
|
||||
|
||||
if (obj.Tools != null)
|
||||
foreach (var tool in obj.Tools)
|
||||
{
|
||||
tools.Add((DTONcToolModel)tool);
|
||||
}
|
||||
|
||||
return new DTONcShankModel()
|
||||
{
|
||||
Id = obj.ShankId,
|
||||
Balluf = (ushort)obj.Balluf,
|
||||
MagazinePositionType = obj.MagazinePositionType,
|
||||
MagazineId = obj.MagazineId,
|
||||
PositionId = obj.PositionId,
|
||||
Tools = tools
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcShankModel(DTONcShankModel obj)
|
||||
{
|
||||
return new DbNcShankModel()
|
||||
{
|
||||
ShankId = obj.Id,
|
||||
Balluf = obj.Balluf,
|
||||
MagazinePositionType = obj.MagazinePositionType,
|
||||
MagazineId = obj.MagazineId,
|
||||
PositionId = obj.PositionId
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,197 @@
|
||||
using Step.Model.DatabaseModels;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
|
||||
public class DTONcTool
|
||||
{
|
||||
[Required]
|
||||
public int OffsetLength { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ResidualLife { get; set; }
|
||||
|
||||
[Required]
|
||||
public int ResidualRevive { get; set; }
|
||||
|
||||
[Required]
|
||||
// Foreign keys
|
||||
public int FamilyId { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool Broken { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool Measured { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool ClockwiseRotation { get; set; }
|
||||
|
||||
[Required]
|
||||
public bool CounterClockwiseRotation { get; set; }
|
||||
|
||||
public int? ShankId { get; set; }
|
||||
|
||||
public static explicit operator DTONcTool(DbNcToolModel obj)
|
||||
{
|
||||
// Get bit values
|
||||
var statusBits = new BitArray(obj.Status);
|
||||
bool[] bits = new bool[8];
|
||||
statusBits.CopyTo(bits, 0);
|
||||
|
||||
return new DTONcTool()
|
||||
{
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId == null ? 0 : obj.ShankId.Value,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
Disabled = bits[0],
|
||||
Broken = bits[1],
|
||||
Measured = bits[2],
|
||||
ClockwiseRotation = bits[3],
|
||||
CounterClockwiseRotation = bits[4],
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcToolModel(DTONcTool obj)
|
||||
{
|
||||
// Prepare status byte
|
||||
bool[] result = new bool[8] { obj.Disabled, obj.Broken, obj.Measured, obj.ClockwiseRotation, obj.CounterClockwiseRotation, false, false, false };
|
||||
byte status = ConvertArrayToByte(result);
|
||||
|
||||
return new DbNcToolModel()
|
||||
{
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
Status = status
|
||||
};
|
||||
}
|
||||
|
||||
protected static byte ConvertArrayToByte(bool[] bits)
|
||||
{
|
||||
BitArray bitField = new BitArray(bits); //BitArray takes a bool[]
|
||||
byte[] bytes = new byte[1];
|
||||
bitField.CopyTo(bytes, 0);
|
||||
|
||||
return bytes[0];
|
||||
}
|
||||
}
|
||||
|
||||
public class DTONcToolModel : DTONcTool
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
public OffsetModel Offset1 { get; set; }
|
||||
|
||||
public OffsetModel Offset2 { get; set; }
|
||||
|
||||
public OffsetModel Offset3 { get; set; }
|
||||
|
||||
public static explicit operator DTONcToolModel(DbNcToolModel obj)
|
||||
{
|
||||
// Get bit values
|
||||
var statusBits = new BitArray(new byte[] { obj.Status });
|
||||
bool[] bits = new bool[8];
|
||||
statusBits.CopyTo(bits, 0);
|
||||
|
||||
return new DTONcToolModel()
|
||||
{
|
||||
Id = obj.ToolId,
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId == null ? 0 : obj.ShankId.Value,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
Disabled = bits[0],
|
||||
Broken = bits[1],
|
||||
Measured = bits[2],
|
||||
ClockwiseRotation = bits[3],
|
||||
CounterClockwiseRotation = bits[4],
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcToolModel(DTONcToolModel obj)
|
||||
{
|
||||
// Prepare status byte
|
||||
bool[] result = new bool[8] { obj.Disabled, obj.Broken, obj.Measured, obj.ClockwiseRotation, obj.CounterClockwiseRotation, false, false, false };
|
||||
byte status = ConvertArrayToByte(result);
|
||||
|
||||
return new DbNcToolModel()
|
||||
{
|
||||
ToolId = obj.Id,
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
Status = status
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
public class DTONewNcToolModel : DTONcTool
|
||||
{
|
||||
public int? OffsetId1 { get; set; }
|
||||
|
||||
public int? OffsetId2 { get; set; }
|
||||
|
||||
public int? OffsetId3 { get; set; }
|
||||
|
||||
|
||||
public static explicit operator DTONewNcToolModel(DbNcToolModel obj)
|
||||
{
|
||||
// Get bit values
|
||||
var statusBits = new BitArray(obj.Status);
|
||||
bool[] bits = new bool[8];
|
||||
statusBits.CopyTo(bits, 0);
|
||||
|
||||
return new DTONewNcToolModel()
|
||||
{
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId == null ? 0 : obj.ShankId.Value,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
Disabled = bits[0],
|
||||
Broken = bits[1],
|
||||
Measured = bits[2],
|
||||
ClockwiseRotation = bits[3],
|
||||
CounterClockwiseRotation = bits[4],
|
||||
OffsetId1 = obj.OffsetId1,
|
||||
OffsetId2 = obj.OffsetId2,
|
||||
OffsetId3 = obj.OffsetId3
|
||||
};
|
||||
}
|
||||
|
||||
public static explicit operator DbNcToolModel(DTONewNcToolModel obj)
|
||||
{
|
||||
// Prepare status byte
|
||||
bool[] result = new bool[8] { obj.Disabled, obj.Broken, obj.Measured, obj.ClockwiseRotation, obj.CounterClockwiseRotation, false, false, false};
|
||||
byte status = ConvertArrayToByte(result);
|
||||
|
||||
return new DbNcToolModel()
|
||||
{
|
||||
FamilyId = obj.FamilyId,
|
||||
ShankId = obj.ShankId,
|
||||
OffsetLength = obj.OffsetLength,
|
||||
ResidualLife = obj.ResidualLife,
|
||||
ResidualRevive = obj.ResidualRevive,
|
||||
Status = status,
|
||||
OffsetId1 = obj.OffsetId1,
|
||||
OffsetId2 = obj.OffsetId2,
|
||||
OffsetId3 = obj.OffsetId3
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Step.Model.DTOModels.ToolModels
|
||||
{
|
||||
public class DTONewToolDataModel
|
||||
{
|
||||
public Dictionary<int, byte> UpdatedStatus;
|
||||
public Dictionary<int, uint> UpdatedLives;
|
||||
}
|
||||
}
|
||||
@@ -61,6 +61,8 @@ namespace Step.Model.DTOModels.ToolModels
|
||||
[Required]
|
||||
public bool PreAlarm { get; set; }
|
||||
|
||||
public DTONcShankModel Shank { get; set; }
|
||||
|
||||
public static explicit operator SiemensToolModel(DTOSiemensToolModel dtoModel)
|
||||
{
|
||||
return new SiemensToolModel()
|
||||
@@ -91,7 +93,7 @@ namespace Step.Model.DTOModels.ToolModels
|
||||
|
||||
public class DTOMagazinesPositionsModel
|
||||
{
|
||||
[Required()]
|
||||
[Required]
|
||||
public bool Disabled { get; set; }
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("family")]
|
||||
public class DbNcFamilyModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int FamilyId { get; set; }
|
||||
|
||||
[Column("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public byte Type { get; set; }
|
||||
|
||||
[Column("right_size")]
|
||||
public byte RightSize { get; set; }
|
||||
|
||||
[Column("left_size")]
|
||||
public byte LeftSize { get; set; }
|
||||
|
||||
[Column("tcp_table")]
|
||||
public byte TcpTable { get; set; }
|
||||
|
||||
[Column("gamma")]
|
||||
public byte Gamma { get; set; }
|
||||
|
||||
[Column("rotation_type")]
|
||||
public byte RotationType { get; set; }
|
||||
|
||||
[Column("cooling_byte")]
|
||||
public byte CoolingByte { get; set; }
|
||||
|
||||
[Column("max_speed")]
|
||||
public int MaxSpeed { get; set; }
|
||||
|
||||
[Column("max_load")]
|
||||
public byte MaxLoad { get; set; }
|
||||
|
||||
[Column("min_load_pct_autoload")]
|
||||
public byte MinLoadPctAutoload { get; set; }
|
||||
|
||||
[Column("max_load_pct_autoload")]
|
||||
public byte MaxLoadPctAutoload { get; set; }
|
||||
|
||||
[Column("dynamic_compensation")]
|
||||
public byte DynamicCompensation { get; set; }
|
||||
|
||||
[Column("min_load_dynamic_comp")]
|
||||
public byte MinLoadDynamicCompensation { get; set; }
|
||||
|
||||
[Column("max_load_dynamic_comp")]
|
||||
public byte MaxLoadDynamicCompensation { get; set; }
|
||||
|
||||
[Column("life_type")]
|
||||
public byte LifeType { get; set; }
|
||||
|
||||
[Column("nominal_life")]
|
||||
public int NominalLife { get; set; }
|
||||
|
||||
[Column("revive_delta")]
|
||||
public int ReviveDelta { get; set; }
|
||||
|
||||
public List<DbNcToolModel> Tools { get; set; }
|
||||
|
||||
public static explicit operator NcFamilyModel(DbNcFamilyModel obj)
|
||||
{
|
||||
return new NcFamilyModel()
|
||||
{
|
||||
Id = (ushort)obj.FamilyId,
|
||||
Type = obj.Type,
|
||||
RightSize = obj.RightSize,
|
||||
LeftSize = obj.LeftSize,
|
||||
TcpTable = obj.TcpTable,
|
||||
Gamma = obj.Gamma,
|
||||
CoolingByte = obj.CoolingByte,
|
||||
RotationType = obj.RotationType,
|
||||
MaxLoad = obj.MaxLoad,
|
||||
MaxSpeed = (ushort)obj.MaxSpeed,
|
||||
MinLoadPctAutoload = obj.MinLoadPctAutoload,
|
||||
MaxLoadPctAutoload = obj.MaxLoadDynamicCompensation,
|
||||
MinLoadDynamicCompensation = obj.MinLoadDynamicCompensation,
|
||||
MaxLoadDynamicCompensation = obj.MaxLoadDynamicCompensation,
|
||||
LifeType = obj.LifeType,
|
||||
NominalLife = (uint)obj.NominalLife,
|
||||
ReviveDelta = (ushort)obj.ReviveDelta
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("magazine_position")]
|
||||
public class DbNcMagazinePositionModel
|
||||
{
|
||||
[Key, Column("magazine_id", Order = 0)]
|
||||
public byte MagazineId { get; set; }
|
||||
|
||||
[Key, Column("position_id", Order = 1)]
|
||||
public byte PositionId { get; set; }
|
||||
|
||||
[Column("type")]
|
||||
public byte Type { get; set; }
|
||||
|
||||
[Column("disabled")]
|
||||
public bool Disabled { get; set; }
|
||||
|
||||
public static explicit operator NcMagazinePositionModel(DbNcMagazinePositionModel obj)
|
||||
{
|
||||
return new NcMagazinePositionModel()
|
||||
{
|
||||
MagazineId = obj.MagazineId,
|
||||
PositionId = obj.PositionId,
|
||||
Disabled = obj.Disabled ? (byte)1 : (byte)0,
|
||||
Type = obj.Type
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("offset")]
|
||||
public class NcOffsetModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int OffsetId { get; set; }
|
||||
|
||||
[Column("nc_offset_id")]
|
||||
public int NcOffsetId { get; set; }
|
||||
|
||||
[Column("lenght")]
|
||||
public double Lenght { get; set; }
|
||||
|
||||
[Column("radius")]
|
||||
public double Radius { get; set; }
|
||||
|
||||
[Column("wear_length")]
|
||||
public double WearLength { get; set; }
|
||||
|
||||
[Column("wear_radius")]
|
||||
public double WearRadius { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("shank")]
|
||||
public class DbNcShankModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int ShankId { get; set; }
|
||||
|
||||
[Column("balluf")]
|
||||
public int? Balluf { get; set; }
|
||||
|
||||
[Column("magazine_position_type")]
|
||||
public byte MagazinePositionType { get; set; }
|
||||
|
||||
[ForeignKey("MagazinePosition"), Column("magazine_id", Order = 0)]
|
||||
public byte? MagazineId { get; set; }
|
||||
|
||||
[ForeignKey("MagazinePosition"), Column("position_id", Order = 1)]
|
||||
public byte? PositionId { get; set; }
|
||||
|
||||
public DbNcMagazinePositionModel MagazinePosition { get; set; }
|
||||
|
||||
public List<DbNcToolModel> Tools { get; set; }
|
||||
|
||||
public static explicit operator NcShankModel(DbNcShankModel obj)
|
||||
{
|
||||
return new NcShankModel()
|
||||
{
|
||||
Id = obj.ShankId,
|
||||
Balluf = obj.Balluf == null ? (ushort)0 : (ushort)obj.Balluf.Value,
|
||||
MagazineId = obj.MagazineId == null ? (byte)0 : obj.MagazineId.Value,
|
||||
PositionId = obj.PositionId == null ? (byte)0 : obj.PositionId.Value,
|
||||
MagazinePositionType = obj.MagazinePositionType,
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
|
||||
namespace Step.Model.DatabaseModels
|
||||
{
|
||||
[Table("tool")]
|
||||
public class DbNcToolModel
|
||||
{
|
||||
[Key]
|
||||
[Column("id")]
|
||||
public int ToolId { get; set; }
|
||||
|
||||
[Column("offset_length")]
|
||||
public int OffsetLength { get; set; }
|
||||
|
||||
[Column("residual_life")]
|
||||
public int ResidualLife { get; set; }
|
||||
|
||||
[Column("residual_revive")]
|
||||
public int ResidualRevive { get; set; }
|
||||
|
||||
[Column("status")]
|
||||
public byte Status { get; set; }
|
||||
|
||||
// Foreign keys
|
||||
[Column("family_id")]
|
||||
[ForeignKey("Family")]
|
||||
public int FamilyId { get; set; }
|
||||
|
||||
[Column("shank_id")]
|
||||
[DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
|
||||
[ForeignKey("Shank")]
|
||||
public int? ShankId { get; set; }
|
||||
|
||||
[Column("offsetId1")]
|
||||
public int? OffsetId1 { get; set; }
|
||||
|
||||
[Column("offsetId2")]
|
||||
public int? OffsetId2 { get; set; }
|
||||
|
||||
[Column("offsetId3")]
|
||||
public int? OffsetId3 { get; set; }
|
||||
|
||||
public virtual DbNcFamilyModel Family { get; set; }
|
||||
public virtual DbNcShankModel Shank { get; set; }
|
||||
|
||||
public static explicit operator NcToolModel(DbNcToolModel obj)
|
||||
{
|
||||
return new NcToolModel()
|
||||
{
|
||||
Id = (ushort)obj.ToolId,
|
||||
FamilyId = obj.FamilyId,
|
||||
OffsetLength = (ushort)obj.OffsetLength,
|
||||
ResidualLife = (ushort)obj.ResidualLife,
|
||||
Status = obj.Status,
|
||||
ResidualRevive = (ushort)obj.ResidualRevive,
|
||||
ShankId = obj.ShankId == null ? 0 : obj.ShankId.Value,
|
||||
OffsetId1 = obj.OffsetId1 == null ? 0 : obj.OffsetId1.Value,
|
||||
OffsetId2 = obj.OffsetId2 == null ? 0 : obj.OffsetId2.Value,
|
||||
OffsetId3 = obj.OffsetId3 == null ? 0 : obj.OffsetId3.Value
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
declare module server {
|
||||
interface roleModel {
|
||||
roleId: number;
|
||||
name: string;
|
||||
level: number;
|
||||
}
|
||||
}
|
||||
-130
@@ -1,130 +0,0 @@
|
||||
declare module server {
|
||||
interface userModel {
|
||||
userId: number;
|
||||
username: string;
|
||||
firstName: string;
|
||||
lastName: string;
|
||||
password: string;
|
||||
securityStamp: string;
|
||||
_language: string;
|
||||
language: {
|
||||
parent: any;
|
||||
lCID: number;
|
||||
keyboardLayoutId: number;
|
||||
name: string;
|
||||
ietfLanguageTag: string;
|
||||
displayName: string;
|
||||
nativeName: string;
|
||||
englishName: string;
|
||||
twoLetterISOLanguageName: string;
|
||||
threeLetterISOLanguageName: string;
|
||||
threeLetterWindowsLanguageName: string;
|
||||
compareInfo: {
|
||||
name: string;
|
||||
lCID: number;
|
||||
version: {
|
||||
fullVersion: number;
|
||||
sortId: any;
|
||||
};
|
||||
};
|
||||
textInfo: {
|
||||
aNSICodePage: number;
|
||||
oEMCodePage: number;
|
||||
macCodePage: number;
|
||||
eBCDICCodePage: number;
|
||||
lCID: number;
|
||||
cultureName: string;
|
||||
isReadOnly: boolean;
|
||||
listSeparator: string;
|
||||
isRightToLeft: boolean;
|
||||
};
|
||||
isNeutralCulture: boolean;
|
||||
cultureTypes: any;
|
||||
numberFormat: {
|
||||
currencyDecimalDigits: number;
|
||||
currencyDecimalSeparator: string;
|
||||
isReadOnly: boolean;
|
||||
currencyGroupSizes: number[];
|
||||
numberGroupSizes: number[];
|
||||
percentGroupSizes: number[];
|
||||
currencyGroupSeparator: string;
|
||||
currencySymbol: string;
|
||||
naNSymbol: string;
|
||||
currencyNegativePattern: number;
|
||||
numberNegativePattern: number;
|
||||
percentPositivePattern: number;
|
||||
percentNegativePattern: number;
|
||||
negativeInfinitySymbol: string;
|
||||
negativeSign: string;
|
||||
numberDecimalDigits: number;
|
||||
numberDecimalSeparator: string;
|
||||
numberGroupSeparator: string;
|
||||
currencyPositivePattern: number;
|
||||
positiveInfinitySymbol: string;
|
||||
positiveSign: string;
|
||||
percentDecimalDigits: number;
|
||||
percentDecimalSeparator: string;
|
||||
percentGroupSeparator: string;
|
||||
percentSymbol: string;
|
||||
perMilleSymbol: string;
|
||||
nativeDigits: string[];
|
||||
digitSubstitution: any;
|
||||
};
|
||||
dateTimeFormat: {
|
||||
aMDesignator: string;
|
||||
calendar: {
|
||||
minSupportedDateTime: Date;
|
||||
maxSupportedDateTime: Date;
|
||||
algorithmType: any;
|
||||
isReadOnly: boolean;
|
||||
eras: number[];
|
||||
twoDigitYearMax: number;
|
||||
};
|
||||
dateSeparator: string;
|
||||
firstDayOfWeek: any;
|
||||
calendarWeekRule: any;
|
||||
fullDateTimePattern: string;
|
||||
longDatePattern: string;
|
||||
longTimePattern: string;
|
||||
monthDayPattern: string;
|
||||
pMDesignator: string;
|
||||
rFC1123Pattern: string;
|
||||
shortDatePattern: string;
|
||||
shortTimePattern: string;
|
||||
sortableDateTimePattern: string;
|
||||
timeSeparator: string;
|
||||
universalSortableDateTimePattern: string;
|
||||
yearMonthPattern: string;
|
||||
abbreviatedDayNames: string[];
|
||||
shortestDayNames: string[];
|
||||
dayNames: string[];
|
||||
abbreviatedMonthNames: string[];
|
||||
monthNames: string[];
|
||||
isReadOnly: boolean;
|
||||
nativeCalendarName: string;
|
||||
abbreviatedMonthGenitiveNames: string[];
|
||||
monthGenitiveNames: string[];
|
||||
};
|
||||
calendar: {
|
||||
minSupportedDateTime: Date;
|
||||
maxSupportedDateTime: Date;
|
||||
algorithmType: any;
|
||||
isReadOnly: boolean;
|
||||
eras: number[];
|
||||
twoDigitYearMax: number;
|
||||
};
|
||||
optionalCalendars: {
|
||||
minSupportedDateTime: Date;
|
||||
maxSupportedDateTime: Date;
|
||||
algorithmType: any;
|
||||
isReadOnly: boolean;
|
||||
eras: number[];
|
||||
twoDigitYearMax: number;
|
||||
}[];
|
||||
useUserOverride: boolean;
|
||||
isReadOnly: boolean;
|
||||
};
|
||||
roleId: number;
|
||||
role: server.RoleModel;
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@
|
||||
<Compile Include="ConfigModels\ServerConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\AreasConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\NcConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\ToolManagerConfigModel.cs" />
|
||||
<Compile Include="ConfigModels\UserSoftKeyConfigModel.cs" />
|
||||
<Compile Include="Constants.cs" />
|
||||
<Compile Include="DatabaseModels\FavoriteUserSoftKeyModel.cs" />
|
||||
@@ -75,6 +76,11 @@
|
||||
<Compile Include="DatabaseModels\MachineModel.cs" />
|
||||
<Compile Include="DatabaseModels\MaintenanceFileModel.cs" />
|
||||
<Compile Include="DatabaseModels\MaintenanceModel.cs" />
|
||||
<Compile Include="DatabaseModels\NcOffsetModel.cs" />
|
||||
<Compile Include="DatabaseModels\NcFamilyModel.cs" />
|
||||
<Compile Include="DatabaseModels\NcMagazinePositionModel.cs" />
|
||||
<Compile Include="DatabaseModels\NcShankModel.cs" />
|
||||
<Compile Include="DatabaseModels\NcToolModel.cs" />
|
||||
<Compile Include="DatabaseModels\PerformedMaintenanceModel.cs" />
|
||||
<Compile Include="DatabaseModels\RoleModel.cs">
|
||||
<Generator>DtsGenerator</Generator>
|
||||
@@ -87,6 +93,7 @@
|
||||
<Compile Include="DTOModels\DTOAxesModel.cs" />
|
||||
<Compile Include="DTOModels\DTOAxisNameModel.cs" />
|
||||
<Compile Include="DTOModels\DTOClientConfigurationModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTONewToolDataModel.cs" />
|
||||
<Compile Include="DTOModels\MaintenanceModels\DTOExpiredMaintenanceModel.cs" />
|
||||
<Compile Include="DTOModels\DTOHeadModel.cs" />
|
||||
<Compile Include="DTOModels\DTOHeadsConfigModel.cs" />
|
||||
@@ -109,6 +116,11 @@
|
||||
<Compile Include="DatabaseModels\MaintenanceNoteModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTOEdgeModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTOMagazineStatusModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTONcFamilyModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTONcMagazinePositionModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTONcMountedShankModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTONcShankModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTONcToolModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTOShankModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTOSiemensToolModel.cs" />
|
||||
<Compile Include="DTOModels\ToolModels\DTOUpdateMagazineModel.cs" />
|
||||
@@ -120,16 +132,6 @@
|
||||
<Compile Include="DTOModels\DTOFunctionAccessModel.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<TypeScriptCompile Include="DatabaseModels\RoleModel.cs.d.ts">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>RoleModel.cs</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="DatabaseModels\UserModel.cs.d.ts">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
<DependentUpon>UserModel.cs</DependentUpon>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="DTOModels\DTOLanguageModel.cs.d.ts">
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTime>True</DesignTime>
|
||||
|
||||
+635
-17
@@ -12,6 +12,7 @@ using Step.Model.DTOModels.ToolModels;
|
||||
using Step.Utils;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Entity;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
@@ -238,7 +239,6 @@ namespace Step.NC
|
||||
// Select distints
|
||||
//alarms.NcAlarms = alarms.NcAlarms?.GroupBy(x => x.Id).Select(x => x.First()).ToList();
|
||||
|
||||
|
||||
// Get NC max process number
|
||||
ushort maxProcNumber = 0;
|
||||
cmsError = numericalControl.NC_RProcessesNum(ref maxProcNumber);
|
||||
@@ -459,7 +459,7 @@ namespace Step.NC
|
||||
counters = new List<CounterModel>();
|
||||
// Get counters values from PLC
|
||||
CmsError cmsError = numericalControl.PLC_RMachineCounters(ref counters);
|
||||
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
@@ -520,6 +520,7 @@ namespace Step.NC
|
||||
missingDays = TimeSpan.FromMinutes(-1 * (counter.Value - perfVal - SupportFunctions.ConvertInMinutes(currMaintenance.Interval.Value, currMaintenance.UnitOfMeasure.Value)));
|
||||
}
|
||||
break;
|
||||
|
||||
case MAINTENANCE_TYPE.EXP_DATE:
|
||||
{
|
||||
// Already performed
|
||||
@@ -536,6 +537,7 @@ namespace Step.NC
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case MAINTENANCE_TYPE.TIME_INTERVAL:
|
||||
{
|
||||
// Get last performed, default value is maintenance creation date
|
||||
@@ -550,7 +552,7 @@ namespace Step.NC
|
||||
|
||||
// percentage = Passed minutes since last maintenance * 100 / Interval
|
||||
percentage = (minutesPassedFromLastMaint * 100) / SupportFunctions.ConvertInMinutes(currMaintenance.Interval.Value, currMaintenance.UnitOfMeasure.Value);
|
||||
missingDays = TimeSpan.FromMinutes( -1 * (minutesPassedFromLastMaint - SupportFunctions.ConvertInMinutes(currMaintenance.Interval.Value, currMaintenance.UnitOfMeasure.Value)));
|
||||
missingDays = TimeSpan.FromMinutes(-1 * (minutesPassedFromLastMaint - SupportFunctions.ConvertInMinutes(currMaintenance.Interval.Value, currMaintenance.UnitOfMeasure.Value)));
|
||||
counter = new CounterModel();
|
||||
}
|
||||
break;
|
||||
@@ -559,7 +561,7 @@ namespace Step.NC
|
||||
canEdit = false;
|
||||
using (MachinesUsersController machineUsersController = new MachinesUsersController())
|
||||
{
|
||||
if(currMaintenance.UserId != null)
|
||||
if (currMaintenance.UserId != null)
|
||||
{
|
||||
// Check if user can edit the maintenance -> caller id - maintenance user id
|
||||
int comparision = machineUsersController.CompareUsersRole(userId, currMaintenance.UserId.Value, MachineConfig.MachineId);
|
||||
@@ -646,7 +648,7 @@ namespace Step.NC
|
||||
expiredMaintenance.Add(new DTOExpiredMaintenanceModel()
|
||||
{
|
||||
Id = currMaintenance.MaintenanceId,
|
||||
ExpirationDate = (DateTime)currMaintenance.LastExpirationDate,
|
||||
ExpirationDate = (DateTime)currMaintenance.LastExpirationDate,
|
||||
CreatedByCms = currMaintenance.UserId == null,
|
||||
Title = currMaintenance.UserId == null ? "" : currMaintenance.Title
|
||||
});
|
||||
@@ -674,7 +676,6 @@ namespace Step.NC
|
||||
Title = currMaintenance.UserId == null ? "" : currMaintenance.Title,
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -828,7 +829,7 @@ namespace Step.NC
|
||||
ActualSpeed = head.ActualSpeed_Pressure,
|
||||
Load = head.Load_Abrasive,
|
||||
MountedTool = (ushort)head.MountedTool_Vacum,
|
||||
Override = head.Override,
|
||||
Override = head.Override,
|
||||
IsActive = head.IsActive,
|
||||
IsSelected = head.IsSelected,
|
||||
AbrasiveIsActive = head.AbrasiveIsActive
|
||||
@@ -892,7 +893,7 @@ namespace Step.NC
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
if( selectedProcess != 0)
|
||||
if (selectedProcess != 0)
|
||||
{
|
||||
// Read axes names
|
||||
cmsError = numericalControl.AXES_RAxesNames(selectedProcess, ref plcAxes);
|
||||
@@ -902,7 +903,6 @@ namespace Step.NC
|
||||
Id = x.Id,
|
||||
Name = x.Name
|
||||
}).ToList();
|
||||
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
@@ -941,7 +941,7 @@ namespace Step.NC
|
||||
public CmsError GetMagazineStatus(out DTOMagazineActionModel magazineStatus)
|
||||
{
|
||||
// Set up models
|
||||
magazineStatus= new DTOMagazineActionModel();
|
||||
magazineStatus = new DTOMagazineActionModel();
|
||||
MagazineActionModel libModel = new MagazineActionModel();
|
||||
// Read status from NC
|
||||
CmsError cmsError = numericalControl.TOOLS_GetMagazinesStatus(ref libModel);
|
||||
@@ -953,6 +953,69 @@ namespace Step.NC
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// OSAI FANUC TOOL MANAGER
|
||||
|
||||
public CmsError GetToolsData(out List<DTONcToolModel> dtoTools)
|
||||
{
|
||||
dtoTools = new List<DTONcToolModel>();
|
||||
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DbNcToolModel> tools = toolsManager.FindToolsWithDependencies();
|
||||
|
||||
foreach (DbNcToolModel tool in tools)
|
||||
{
|
||||
DTONcToolModel dtoTool = (DTONcToolModel)tool;
|
||||
|
||||
cmsError = GetToolData(tool, ref dtoTool);
|
||||
|
||||
dtoTools.Add(dtoTool);
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError GetToolData(DbNcToolModel tool, ref DTONcToolModel dtoTool)
|
||||
{
|
||||
dtoTool = (DTONcToolModel)tool;
|
||||
|
||||
OffsetModel offset = new OffsetModel();
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
if (tool.OffsetId1 != null && tool.OffsetId1 != 0)
|
||||
{
|
||||
// Read first offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId1, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset1 = offset;
|
||||
}
|
||||
if (tool.OffsetId2 != null && tool.OffsetId2 != 0)
|
||||
{
|
||||
// Read second offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId2, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset2 = offset;
|
||||
}
|
||||
if (tool.OffsetId3 != null && tool.OffsetId3 != 0)
|
||||
{
|
||||
// Read third offset data
|
||||
cmsError = numericalControl.TOOLS_ROffset((short)tool.OffsetId3, ref offset);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
dtoTool.Offset3 = offset;
|
||||
}
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
#endregion Read Data
|
||||
|
||||
#region Write data
|
||||
@@ -982,7 +1045,7 @@ namespace Step.NC
|
||||
// Write in memory the request to restore the alarm
|
||||
return numericalControl.PLC_WRestoreMessage(id);
|
||||
}
|
||||
|
||||
|
||||
public CmsError RefreshAllAlarms()
|
||||
{
|
||||
return numericalControl.PLC_WRefreshAllMessages();
|
||||
@@ -1014,8 +1077,8 @@ namespace Step.NC
|
||||
return numericalControl.PLC_WPowerOnData(id, true);
|
||||
}
|
||||
|
||||
#region Tools
|
||||
|
||||
#region Siemens Tools
|
||||
|
||||
public CmsError AddTool(ref SiemensToolModel tool)
|
||||
{
|
||||
return numericalControl.TOOLS_WAddTool(ref tool);
|
||||
@@ -1106,7 +1169,7 @@ namespace Step.NC
|
||||
|
||||
public CmsError UnloadToolInMagazine(int magazineId, int positionId)
|
||||
{
|
||||
return numericalControl.TOOLS_WUnloadToolInMagazine(magazineId, positionId);
|
||||
return numericalControl.TOOLS_WUnloadToolFromMagazine(magazineId, positionId);
|
||||
}
|
||||
|
||||
public CmsError LoadTooolIntoShank(int shankId, int positionId, int toolId)
|
||||
@@ -1119,12 +1182,567 @@ namespace Step.NC
|
||||
return numericalControl.TOOLS_WUnloadToolFromShank(shankId, positionId);
|
||||
}
|
||||
|
||||
public CmsError GetFileList(string filePath, out PreviewFileModel fileList)
|
||||
#endregion Siemens Tools
|
||||
|
||||
// OSAI FANUC
|
||||
|
||||
#region Osai/Fanuc Tools
|
||||
|
||||
public DTONcToolModel AddTool(DTONewNcToolModel tool)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
DbNcToolModel ncTool = toolsManager.AddTool(tool);
|
||||
|
||||
DTONcToolModel dtoTool = new DTONcToolModel();
|
||||
GetToolData(ncTool, ref dtoTool);
|
||||
|
||||
return dtoTool;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
public CmsError UpdateTool(int toolId, DTONewNcToolModel newTool, out DTONcToolModel toolWithOffsets)
|
||||
{
|
||||
toolWithOffsets = new DTONcToolModel();
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// Update database tool Tool
|
||||
DbNcToolModel dbTool = toolsManager.UpdateTool(toolId, newTool);
|
||||
|
||||
// Populate updated tool with offset data
|
||||
CmsError cmsError = GetToolData(dbTool, ref toolWithOffsets);
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
dbContextTransaction.Rollback();
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
bool startIsActive = false;
|
||||
|
||||
// Check if tool is loaded into a shank
|
||||
if (dbTool.ShankId != null)
|
||||
{
|
||||
// Check if shank is loaded into magazine
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(dbTool.ShankId.Value);
|
||||
if (shank.MagazineId != null)
|
||||
{
|
||||
startIsActive = true;
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// Update tool
|
||||
cmsError = UpdateNcTools(toolsManager);
|
||||
}
|
||||
}
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError UpdateNcTools(NcToolManagerController toolsManager = null)
|
||||
{
|
||||
if (toolsManager == null)
|
||||
toolsManager = new NcToolManagerController();
|
||||
|
||||
List<NcShankModel> shanks = toolsManager
|
||||
.FindShanks()
|
||||
.Where(x => x.MagazineId != null)
|
||||
.Select(x => (NcShankModel)x)
|
||||
.ToList();
|
||||
|
||||
// Get tools
|
||||
List<NcToolModel> tools = toolsManager
|
||||
.FindTools()
|
||||
.Select(x => (NcToolModel)x)
|
||||
.Where(x => shanks.Any(y => y.Id == x.ShankId)) // Find only mounted tools
|
||||
.ToList();
|
||||
|
||||
// Update tools
|
||||
return numericalControl.TOOLS_WUpdateTools(tools);
|
||||
}
|
||||
|
||||
public CmsError DeleteNcTool(DbNcToolModel tool)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// Delete db tool
|
||||
toolsManager.DeleteTool(tool.ToolId);
|
||||
|
||||
bool startIsActive = false;
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
if (tool.ShankId != null)
|
||||
{
|
||||
// If tool is mounted than update Nc data
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(tool.ShankId.Value);
|
||||
if (shank.MagazineId != null)
|
||||
{
|
||||
startIsActive = true;
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// Update Nc data
|
||||
cmsError = UpdateNcTools(toolsManager);
|
||||
}
|
||||
}
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError UpdateShank(int shankId, DTONewNcShankModel dtoShank, out DTONcShankModel shank)
|
||||
{
|
||||
shank = new DTONcShankModel();
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
bool startIsActive = false;
|
||||
CmsError cmsError = NO_ERROR;
|
||||
|
||||
// Update db data
|
||||
shank = (DTONcShankModel)toolsManager.UpdateShank(shankId, dtoShank);
|
||||
if (shank.MagazineId != null)
|
||||
{
|
||||
startIsActive = true;
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// Update nc data
|
||||
cmsError = UpdateNcShank(toolsManager);
|
||||
}
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError DeleteNcShank(int shankId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
CmsError cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Delete database shank
|
||||
DbNcShankModel deletedShank = toolsManager.DeleteShank(shankId);
|
||||
bool startIsActive = false;
|
||||
if (deletedShank.MagazineId != null)
|
||||
{
|
||||
startIsActive = true;
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// Update nc data
|
||||
cmsError = UpdateNcShank(toolsManager);
|
||||
}
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, startIsActive);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CmsError UpdateNcShank(NcToolManagerController toolsManager)
|
||||
{
|
||||
// Get mounted shanks
|
||||
List<NcShankModel> shanks = toolsManager
|
||||
.FindShanks()
|
||||
.Where(x => x.MagazineId != null)
|
||||
.Select(x => (NcShankModel)x)
|
||||
.ToList();
|
||||
|
||||
// Update nc data
|
||||
return numericalControl.TOOLS_WUpdateShanks(shanks);
|
||||
}
|
||||
|
||||
public DTONcFamilyModel AddFamily(DTONewNcFamilyModel family)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
return (DTONcFamilyModel)toolsManager.AddFamily(family);
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError UpdateFamily(int familyId, DTONewNcFamilyModel family, out DTONcFamilyModel newFamily)
|
||||
{
|
||||
newFamily = new DTONcFamilyModel();
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// Update db family
|
||||
newFamily = (DTONcFamilyModel)toolsManager.UpdateFamily(familyId, family);
|
||||
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
CmsError cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// Update Nc families
|
||||
cmsError = UpdateNcFamily(toolsManager);
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError DeleteNcFamily(DbNcFamilyModel family)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (var dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
CmsError cmsError = numericalControl.TOOLS_WStartEditData();
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
toolsManager.DeleteFamily(family);
|
||||
// Update Nc families
|
||||
cmsError = UpdateNcFamily(toolsManager);
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CmsError UpdateNcFamily(NcToolManagerController toolsManager)
|
||||
{
|
||||
// Get mounted shanks
|
||||
List<NcShankModel> shanks = toolsManager
|
||||
.FindShanks()
|
||||
.Where(x => x.MagazineId != null)
|
||||
.Select(x => (NcShankModel)x)
|
||||
.ToList();
|
||||
|
||||
// Get tools
|
||||
List<NcToolModel> tools = toolsManager
|
||||
.FindTools()
|
||||
.Select(x => (NcToolModel)x)
|
||||
.Where(x => shanks.Any(y => y.Id == x.ShankId)) // Find only mounted tools
|
||||
.ToList();
|
||||
|
||||
List<NcFamilyModel> families = toolsManager
|
||||
.FindFamilies()
|
||||
.Select(x => (NcFamilyModel)x)
|
||||
.Where(x => tools.Any(y => y.FamilyId == x.Id)) // Find only families of mounted tools
|
||||
.ToList();
|
||||
|
||||
// Update nc families
|
||||
return numericalControl.TOOLS_WUpdateFamilies(families);
|
||||
}
|
||||
|
||||
public CmsError UpdateMagazinePosition(DbNcMagazinePositionModel dbPos, DTONcMagazinePositionModel dtoPos, out DTONcMagazinePositionModel magPos)
|
||||
{
|
||||
magPos = new DTONcMagazinePositionModel();
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
using (DbContextTransaction dbContextTransaction = toolsManager.dbCtx.Database.BeginTransaction())
|
||||
{
|
||||
// Create backup of data stored on the NC and block file accesses
|
||||
CmsError cmsError = StartEditData();
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
// Update database data
|
||||
magPos = (DTONcMagazinePositionModel)toolsManager.UpdatePosition(dbPos, dtoPos);
|
||||
|
||||
// Get magazines positions
|
||||
List<NcMagazinePositionModel> positions = toolsManager.FindMagazinesPositions()
|
||||
.Select(x => (NcMagazinePositionModel)x)
|
||||
.ToList();
|
||||
// Update Nc data
|
||||
cmsError = numericalControl.TOOLS_WUpdateMagazinePositions(positions);
|
||||
|
||||
ManageErrorAndTransaction(cmsError, dbContextTransaction, true);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ManageErrorAndTransaction(CmsError cmsError, DbContextTransaction dbContextTransaction, bool ncStartIsActive)
|
||||
{
|
||||
// Check cmsError, manage transaction and if startIsActive = true manage Nc backup created with TOOLS_WStartEditData()
|
||||
if (cmsError.IsError())
|
||||
{
|
||||
// Close transaction
|
||||
dbContextTransaction.Rollback();
|
||||
// Restore backup
|
||||
if(ncStartIsActive)
|
||||
numericalControl.TOOLS_WRestoreBackup();
|
||||
}
|
||||
else
|
||||
{
|
||||
// Close transaction
|
||||
dbContextTransaction.Commit();
|
||||
// Stop editing ncData
|
||||
if (ncStartIsActive)
|
||||
numericalControl.TOOLS_WStopEditData();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public DTONcShankModel LoadIntoShank(DbNcToolModel tool, int shankId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
return toolsManager.LoadToolIntoShank(tool, shankId);
|
||||
}
|
||||
}
|
||||
|
||||
public DTONcShankModel UnloadFromShank(DbNcToolModel tool)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
return toolsManager.UnloadToolFromShank(tool);
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError SetupNcToolManager()
|
||||
{
|
||||
if (NcConfig.NcVendor != NC_VENDOR.SIEMENS)
|
||||
{
|
||||
return UpdateMagazinePositionConf();
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
public CmsError UpdateMagazinePositionConf()
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Get database configured positions
|
||||
List<DbNcMagazinePositionModel> dbPositions = toolsManager.FindMagazinesPositions();
|
||||
if (dbPositions.Count <= 0)
|
||||
{
|
||||
CmsError cmsError = GetMagazineConfiguration(out List<NcMagazineConfigModel> config);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Setup new positions list in order to be saved in the database
|
||||
List<DbNcMagazinePositionModel> fromConfigPosition = new List<DbNcMagazinePositionModel>();
|
||||
foreach (var conf in config)
|
||||
{
|
||||
for (byte i = 1; i <= conf.MaxPositions; i++)
|
||||
{
|
||||
// Create new position
|
||||
fromConfigPosition.Add(new DbNcMagazinePositionModel()
|
||||
{
|
||||
MagazineId = conf.Id,
|
||||
PositionId = i,
|
||||
Disabled = false,
|
||||
Type = 0
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Update database
|
||||
toolsManager.SetupMagazinePositions(fromConfigPosition);
|
||||
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
public CmsError GetMagazineConfiguration(out List<NcMagazineConfigModel> config)
|
||||
{
|
||||
config = new List<NcMagazineConfigModel>();
|
||||
// Read configuration
|
||||
return numericalControl.TOOLS_RMagazineConfig(ref config);
|
||||
}
|
||||
|
||||
public CmsError StartEditData()
|
||||
{
|
||||
return numericalControl.TOOLS_WStartEditData();
|
||||
}
|
||||
|
||||
public CmsError StopEditData()
|
||||
{
|
||||
return numericalControl.TOOLS_WStopEditData();
|
||||
}
|
||||
|
||||
public CmsError StartEditTooling(int magazineId)
|
||||
{
|
||||
return numericalControl.TOOLS_WStartEditTooling(magazineId);
|
||||
}
|
||||
|
||||
public CmsError StopEditTooling(int magazineId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Get mounted shanks
|
||||
List<NcShankModel> shanks = toolsManager
|
||||
.FindShanks()
|
||||
.Where(x => x.MagazineId != null)
|
||||
.Select(x => (NcShankModel)x)
|
||||
.ToList();
|
||||
|
||||
CmsError cmsError = numericalControl.TOOLS_WUpdateShanks(shanks);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Get magazine positions
|
||||
List<NcMagazinePositionModel> positions = toolsManager.FindMagazinesPositions()
|
||||
.Select(x => (NcMagazinePositionModel)x)
|
||||
.ToList();
|
||||
cmsError = numericalControl.TOOLS_WUpdateMagazinePositions(positions);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
// Get tools
|
||||
List<NcToolModel> tools = toolsManager
|
||||
.FindTools()
|
||||
.Select(x => (NcToolModel)x)
|
||||
.Where(x => shanks.Any(y => y.Id == x.ShankId)) // Find only mounted tools
|
||||
.ToList();
|
||||
|
||||
// Update tools
|
||||
cmsError = numericalControl.TOOLS_WUpdateTools(tools);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
List<NcFamilyModel> families = toolsManager
|
||||
.FindFamilies()
|
||||
.Select(x => (NcFamilyModel)x)
|
||||
.Where(x => tools.Any(y => y.FamilyId == x.Id)) // Find only families of mounted tools
|
||||
.ToList();
|
||||
// Update families
|
||||
cmsError = numericalControl.TOOLS_WUpdateFamilies(families);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
}
|
||||
|
||||
return numericalControl.TOOLS_WStopEditTooling(magazineId);
|
||||
}
|
||||
|
||||
public CmsError GetUpdatedToolsData(out Dictionary<int, byte> updatedStatus, out Dictionary<int, uint> updatedLives)
|
||||
{
|
||||
updatedStatus = new Dictionary<int, byte>();
|
||||
updatedLives = new Dictionary<int, uint>();
|
||||
return numericalControl.TOOLS_RUpdatedToolsData(ref updatedStatus, ref updatedLives);
|
||||
}
|
||||
|
||||
public CmsError CheckIfShankCanFit(int magazineId, int positionId, DbNcShankModel shankToBeLoaded)
|
||||
{
|
||||
CmsError cmsError = GetMagazineConfiguration(out List<NcMagazineConfigModel> magazinesConfig);
|
||||
if (cmsError.IsError())
|
||||
return cmsError;
|
||||
|
||||
NcMagazineConfigModel magConfig = magazinesConfig.Where(x => x.Id == magazineId).FirstOrDefault();// Get only current magazine config
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DbNcToolModel> magazineMountedTools = toolsManager.GetMountedTools();
|
||||
|
||||
// Check if there is a tool already mounted in magazineId and positionId
|
||||
var toolAlreadyMounted = magazineMountedTools.Where(x => x.Shank.MagazineId == magazineId && x.Shank.PositionId == positionId).FirstOrDefault();
|
||||
if (toolAlreadyMounted != null)
|
||||
return MAGAZINE_POSITION_OCCUPIED_ERROR;
|
||||
|
||||
List<DbNcFamilyModel> families = toolsManager.FindFamiliesByShankId(shankToBeLoaded.ShankId);
|
||||
|
||||
int maxRight = families.Max(x => x.RightSize);
|
||||
int maxLeft = families.Max(x => x.LeftSize);
|
||||
|
||||
// Check if tool can fit in the position considering other tools
|
||||
foreach (var mountedTool in magazineMountedTools)
|
||||
{
|
||||
// Check if is not the same position && if is different check if the position is on the same magazine
|
||||
if (mountedTool.Shank.PositionId != positionId && mountedTool.Shank.MagazineId == magazineId)
|
||||
{
|
||||
int decPosition, incPosition;
|
||||
decPosition = incPosition = mountedTool.Shank.PositionId.Value;
|
||||
// if it 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 != NC_MAGAZINE_TYPE.BOX_MAGAZINE)
|
||||
{
|
||||
decPosition = decPosition < positionId ? decPosition + magConfig.MaxPositions : decPosition;
|
||||
incPosition = incPosition > positionId ? incPosition - magConfig.MaxPositions : incPosition;
|
||||
}
|
||||
|
||||
if (!(magConfig.Type == NC_MAGAZINE_TYPE.BOX_MAGAZINE && mountedTool.Shank.PositionId == 1))
|
||||
{
|
||||
// Right check
|
||||
// Calculate left space occupied (with mounted shank)
|
||||
double leftMounted = decPosition - (mountedTool.Family.LeftSize / 2.0);
|
||||
// Calculate right space needed (with shank to be loaded)
|
||||
double rightToBeMount = positionId + (maxRight / 2.0);
|
||||
if (leftMounted < rightToBeMount)
|
||||
return MAGAZINE_POSITION_OCCUPIED_ERROR;
|
||||
}
|
||||
|
||||
if (!(magConfig.Type == NC_MAGAZINE_TYPE.BOX_MAGAZINE && mountedTool.Shank.PositionId == magConfig.MaxPositions))
|
||||
{
|
||||
// Left check
|
||||
// Calculate right space occupied (with mounted shank)
|
||||
double rightMounted = incPosition + (mountedTool.Family.RightSize / 2.0);
|
||||
// Calculate left space needed (with shank to be loaded)
|
||||
double leftToBeMounted = positionId - (maxLeft / 2.0);
|
||||
if (rightMounted > leftToBeMounted)
|
||||
return MAGAZINE_POSITION_OCCUPIED_ERROR;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
#endregion Osai/Fanuc Tools
|
||||
#endregion Write data
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,7 @@
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\Libs\CMS_CORE_Library.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="System.Xml.Linq" />
|
||||
|
||||
Generated
+51
-421
@@ -37,24 +37,6 @@ namespace Step.UI
|
||||
this.StopServerItem = new System.Windows.Forms.ToolStripMenuItem();
|
||||
this.openUiButton = new MetroFramework.Controls.MetroButton();
|
||||
this.metroTabControl1 = new MetroFramework.Controls.MetroTabControl();
|
||||
this.NCInfo = new MetroFramework.Controls.MetroTabPage();
|
||||
this.CHNcConnected = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.TXTTime = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTLang = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTNCProc = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTSftVers = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTCMSMach = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTNcSerial = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTName = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTType = new MetroFramework.Controls.MetroTextBox();
|
||||
this.metroLabel8 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel7 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel6 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel5 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel4 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel3 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel2 = new MetroFramework.Controls.MetroLabel();
|
||||
this.metroLabel1 = new MetroFramework.Controls.MetroLabel();
|
||||
this.ThreadsInfo = new MetroFramework.Controls.MetroTabPage();
|
||||
this.LISTThreadStatus = new MetroFramework.Controls.MetroListView();
|
||||
this.columnHeader1 = ((System.Windows.Forms.ColumnHeader)(new System.Windows.Forms.ColumnHeader()));
|
||||
@@ -62,9 +44,11 @@ namespace Step.UI
|
||||
this.stopServerButton = new MetroFramework.Controls.MetroButton();
|
||||
this.TestJSButton = new MetroFramework.Controls.MetroButton();
|
||||
this.TXTstatus = new MetroFramework.Controls.MetroTextBox();
|
||||
this.TXTType = new System.Windows.Forms.Label();
|
||||
this.CHNcConnected = new MetroFramework.Controls.MetroCheckBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.NotifyIconMenu.SuspendLayout();
|
||||
this.metroTabControl1.SuspendLayout();
|
||||
this.NCInfo.SuspendLayout();
|
||||
this.ThreadsInfo.SuspendLayout();
|
||||
this.SuspendLayout();
|
||||
//
|
||||
@@ -95,7 +79,7 @@ namespace Step.UI
|
||||
// openUiButton
|
||||
//
|
||||
this.openUiButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.openUiButton.Location = new System.Drawing.Point(12, 381);
|
||||
this.openUiButton.Location = new System.Drawing.Point(8, 371);
|
||||
this.openUiButton.Name = "openUiButton";
|
||||
this.openUiButton.Size = new System.Drawing.Size(104, 42);
|
||||
this.openUiButton.TabIndex = 1;
|
||||
@@ -106,385 +90,14 @@ namespace Step.UI
|
||||
//
|
||||
// metroTabControl1
|
||||
//
|
||||
this.metroTabControl1.Controls.Add(this.NCInfo);
|
||||
this.metroTabControl1.Controls.Add(this.ThreadsInfo);
|
||||
this.metroTabControl1.Location = new System.Drawing.Point(12, 56);
|
||||
this.metroTabControl1.Location = new System.Drawing.Point(8, 26);
|
||||
this.metroTabControl1.Name = "metroTabControl1";
|
||||
this.metroTabControl1.SelectedIndex = 0;
|
||||
this.metroTabControl1.Size = new System.Drawing.Size(328, 323);
|
||||
this.metroTabControl1.TabIndex = 7;
|
||||
this.metroTabControl1.UseSelectable = true;
|
||||
//
|
||||
// NCInfo
|
||||
//
|
||||
this.NCInfo.Controls.Add(this.CHNcConnected);
|
||||
this.NCInfo.Controls.Add(this.TXTTime);
|
||||
this.NCInfo.Controls.Add(this.TXTLang);
|
||||
this.NCInfo.Controls.Add(this.TXTNCProc);
|
||||
this.NCInfo.Controls.Add(this.TXTSftVers);
|
||||
this.NCInfo.Controls.Add(this.TXTCMSMach);
|
||||
this.NCInfo.Controls.Add(this.TXTNcSerial);
|
||||
this.NCInfo.Controls.Add(this.TXTName);
|
||||
this.NCInfo.Controls.Add(this.TXTType);
|
||||
this.NCInfo.Controls.Add(this.metroLabel8);
|
||||
this.NCInfo.Controls.Add(this.metroLabel7);
|
||||
this.NCInfo.Controls.Add(this.metroLabel6);
|
||||
this.NCInfo.Controls.Add(this.metroLabel5);
|
||||
this.NCInfo.Controls.Add(this.metroLabel4);
|
||||
this.NCInfo.Controls.Add(this.metroLabel3);
|
||||
this.NCInfo.Controls.Add(this.metroLabel2);
|
||||
this.NCInfo.Controls.Add(this.metroLabel1);
|
||||
this.NCInfo.HorizontalScrollbarBarColor = true;
|
||||
this.NCInfo.HorizontalScrollbarHighlightOnWheel = false;
|
||||
this.NCInfo.HorizontalScrollbarSize = 10;
|
||||
this.NCInfo.Location = new System.Drawing.Point(4, 38);
|
||||
this.NCInfo.Name = "NCInfo";
|
||||
this.NCInfo.Size = new System.Drawing.Size(320, 281);
|
||||
this.NCInfo.TabIndex = 0;
|
||||
this.NCInfo.Text = "NC Info";
|
||||
this.NCInfo.VerticalScrollbarBarColor = true;
|
||||
this.NCInfo.VerticalScrollbarHighlightOnWheel = false;
|
||||
this.NCInfo.VerticalScrollbarSize = 10;
|
||||
//
|
||||
// CHNcConnected
|
||||
//
|
||||
this.CHNcConnected.AutoCheck = false;
|
||||
this.CHNcConnected.AutoSize = true;
|
||||
this.CHNcConnected.Location = new System.Drawing.Point(173, 17);
|
||||
this.CHNcConnected.Name = "CHNcConnected";
|
||||
this.CHNcConnected.Size = new System.Drawing.Size(81, 15);
|
||||
this.CHNcConnected.TabIndex = 50;
|
||||
this.CHNcConnected.Text = "Connected";
|
||||
this.CHNcConnected.UseSelectable = true;
|
||||
//
|
||||
// TXTTime
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTTime.CustomButton.Image = null;
|
||||
this.TXTTime.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTTime.CustomButton.Name = "";
|
||||
this.TXTTime.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTTime.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTTime.CustomButton.TabIndex = 1;
|
||||
this.TXTTime.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTTime.CustomButton.UseSelectable = true;
|
||||
this.TXTTime.CustomButton.Visible = false;
|
||||
this.TXTTime.Lines = new string[0];
|
||||
this.TXTTime.Location = new System.Drawing.Point(173, 241);
|
||||
this.TXTTime.MaxLength = 32767;
|
||||
this.TXTTime.Name = "TXTTime";
|
||||
this.TXTTime.PasswordChar = '\0';
|
||||
this.TXTTime.ReadOnly = true;
|
||||
this.TXTTime.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTTime.SelectedText = "";
|
||||
this.TXTTime.SelectionLength = 0;
|
||||
this.TXTTime.SelectionStart = 0;
|
||||
this.TXTTime.ShortcutsEnabled = true;
|
||||
this.TXTTime.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTTime.TabIndex = 49;
|
||||
this.TXTTime.UseSelectable = true;
|
||||
this.TXTTime.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTTime.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTLang
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTLang.CustomButton.Image = null;
|
||||
this.TXTLang.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTLang.CustomButton.Name = "";
|
||||
this.TXTLang.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTLang.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTLang.CustomButton.TabIndex = 1;
|
||||
this.TXTLang.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTLang.CustomButton.UseSelectable = true;
|
||||
this.TXTLang.CustomButton.Visible = false;
|
||||
this.TXTLang.Lines = new string[0];
|
||||
this.TXTLang.Location = new System.Drawing.Point(173, 212);
|
||||
this.TXTLang.MaxLength = 32767;
|
||||
this.TXTLang.Name = "TXTLang";
|
||||
this.TXTLang.PasswordChar = '\0';
|
||||
this.TXTLang.ReadOnly = true;
|
||||
this.TXTLang.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTLang.SelectedText = "";
|
||||
this.TXTLang.SelectionLength = 0;
|
||||
this.TXTLang.SelectionStart = 0;
|
||||
this.TXTLang.ShortcutsEnabled = true;
|
||||
this.TXTLang.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTLang.TabIndex = 48;
|
||||
this.TXTLang.UseSelectable = true;
|
||||
this.TXTLang.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTLang.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTNCProc
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTNCProc.CustomButton.Image = null;
|
||||
this.TXTNCProc.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTNCProc.CustomButton.Name = "";
|
||||
this.TXTNCProc.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTNCProc.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTNCProc.CustomButton.TabIndex = 1;
|
||||
this.TXTNCProc.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTNCProc.CustomButton.UseSelectable = true;
|
||||
this.TXTNCProc.CustomButton.Visible = false;
|
||||
this.TXTNCProc.Lines = new string[0];
|
||||
this.TXTNCProc.Location = new System.Drawing.Point(173, 183);
|
||||
this.TXTNCProc.MaxLength = 32767;
|
||||
this.TXTNCProc.Name = "TXTNCProc";
|
||||
this.TXTNCProc.PasswordChar = '\0';
|
||||
this.TXTNCProc.ReadOnly = true;
|
||||
this.TXTNCProc.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTNCProc.SelectedText = "";
|
||||
this.TXTNCProc.SelectionLength = 0;
|
||||
this.TXTNCProc.SelectionStart = 0;
|
||||
this.TXTNCProc.ShortcutsEnabled = true;
|
||||
this.TXTNCProc.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTNCProc.TabIndex = 47;
|
||||
this.TXTNCProc.UseSelectable = true;
|
||||
this.TXTNCProc.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTNCProc.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTSftVers
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTSftVers.CustomButton.Image = null;
|
||||
this.TXTSftVers.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTSftVers.CustomButton.Name = "";
|
||||
this.TXTSftVers.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTSftVers.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTSftVers.CustomButton.TabIndex = 1;
|
||||
this.TXTSftVers.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTSftVers.CustomButton.UseSelectable = true;
|
||||
this.TXTSftVers.CustomButton.Visible = false;
|
||||
this.TXTSftVers.Lines = new string[0];
|
||||
this.TXTSftVers.Location = new System.Drawing.Point(173, 154);
|
||||
this.TXTSftVers.MaxLength = 32767;
|
||||
this.TXTSftVers.Name = "TXTSftVers";
|
||||
this.TXTSftVers.PasswordChar = '\0';
|
||||
this.TXTSftVers.ReadOnly = true;
|
||||
this.TXTSftVers.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTSftVers.SelectedText = "";
|
||||
this.TXTSftVers.SelectionLength = 0;
|
||||
this.TXTSftVers.SelectionStart = 0;
|
||||
this.TXTSftVers.ShortcutsEnabled = true;
|
||||
this.TXTSftVers.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTSftVers.TabIndex = 46;
|
||||
this.TXTSftVers.UseSelectable = true;
|
||||
this.TXTSftVers.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTSftVers.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTCMSMach
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTCMSMach.CustomButton.Image = null;
|
||||
this.TXTCMSMach.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTCMSMach.CustomButton.Name = "";
|
||||
this.TXTCMSMach.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTCMSMach.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTCMSMach.CustomButton.TabIndex = 1;
|
||||
this.TXTCMSMach.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTCMSMach.CustomButton.UseSelectable = true;
|
||||
this.TXTCMSMach.CustomButton.Visible = false;
|
||||
this.TXTCMSMach.Lines = new string[0];
|
||||
this.TXTCMSMach.Location = new System.Drawing.Point(173, 125);
|
||||
this.TXTCMSMach.MaxLength = 32767;
|
||||
this.TXTCMSMach.Name = "TXTCMSMach";
|
||||
this.TXTCMSMach.PasswordChar = '\0';
|
||||
this.TXTCMSMach.ReadOnly = true;
|
||||
this.TXTCMSMach.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTCMSMach.SelectedText = "";
|
||||
this.TXTCMSMach.SelectionLength = 0;
|
||||
this.TXTCMSMach.SelectionStart = 0;
|
||||
this.TXTCMSMach.ShortcutsEnabled = true;
|
||||
this.TXTCMSMach.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTCMSMach.TabIndex = 45;
|
||||
this.TXTCMSMach.UseSelectable = true;
|
||||
this.TXTCMSMach.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTCMSMach.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTNcSerial
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTNcSerial.CustomButton.Image = null;
|
||||
this.TXTNcSerial.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTNcSerial.CustomButton.Name = "";
|
||||
this.TXTNcSerial.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTNcSerial.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTNcSerial.CustomButton.TabIndex = 1;
|
||||
this.TXTNcSerial.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTNcSerial.CustomButton.UseSelectable = true;
|
||||
this.TXTNcSerial.CustomButton.Visible = false;
|
||||
this.TXTNcSerial.Lines = new string[0];
|
||||
this.TXTNcSerial.Location = new System.Drawing.Point(173, 96);
|
||||
this.TXTNcSerial.MaxLength = 32767;
|
||||
this.TXTNcSerial.Name = "TXTNcSerial";
|
||||
this.TXTNcSerial.PasswordChar = '\0';
|
||||
this.TXTNcSerial.ReadOnly = true;
|
||||
this.TXTNcSerial.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTNcSerial.SelectedText = "";
|
||||
this.TXTNcSerial.SelectionLength = 0;
|
||||
this.TXTNcSerial.SelectionStart = 0;
|
||||
this.TXTNcSerial.ShortcutsEnabled = true;
|
||||
this.TXTNcSerial.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTNcSerial.TabIndex = 44;
|
||||
this.TXTNcSerial.UseSelectable = true;
|
||||
this.TXTNcSerial.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTNcSerial.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTName
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTName.CustomButton.Image = null;
|
||||
this.TXTName.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTName.CustomButton.Name = "";
|
||||
this.TXTName.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTName.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTName.CustomButton.TabIndex = 1;
|
||||
this.TXTName.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTName.CustomButton.UseSelectable = true;
|
||||
this.TXTName.CustomButton.Visible = false;
|
||||
this.TXTName.Lines = new string[0];
|
||||
this.TXTName.Location = new System.Drawing.Point(173, 67);
|
||||
this.TXTName.MaxLength = 32767;
|
||||
this.TXTName.Name = "TXTName";
|
||||
this.TXTName.PasswordChar = '\0';
|
||||
this.TXTName.ReadOnly = true;
|
||||
this.TXTName.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTName.SelectedText = "";
|
||||
this.TXTName.SelectionLength = 0;
|
||||
this.TXTName.SelectionStart = 0;
|
||||
this.TXTName.ShortcutsEnabled = true;
|
||||
this.TXTName.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTName.TabIndex = 43;
|
||||
this.TXTName.UseSelectable = true;
|
||||
this.TXTName.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTName.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTType
|
||||
//
|
||||
//
|
||||
//
|
||||
//
|
||||
this.TXTType.CustomButton.Image = null;
|
||||
this.TXTType.CustomButton.Location = new System.Drawing.Point(116, 1);
|
||||
this.TXTType.CustomButton.Name = "";
|
||||
this.TXTType.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTType.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTType.CustomButton.TabIndex = 1;
|
||||
this.TXTType.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
this.TXTType.CustomButton.UseSelectable = true;
|
||||
this.TXTType.CustomButton.Visible = false;
|
||||
this.TXTType.Lines = new string[0];
|
||||
this.TXTType.Location = new System.Drawing.Point(173, 38);
|
||||
this.TXTType.MaxLength = 32767;
|
||||
this.TXTType.Name = "TXTType";
|
||||
this.TXTType.PasswordChar = '\0';
|
||||
this.TXTType.ReadOnly = true;
|
||||
this.TXTType.ScrollBars = System.Windows.Forms.ScrollBars.None;
|
||||
this.TXTType.SelectedText = "";
|
||||
this.TXTType.SelectionLength = 0;
|
||||
this.TXTType.SelectionStart = 0;
|
||||
this.TXTType.ShortcutsEnabled = true;
|
||||
this.TXTType.Size = new System.Drawing.Size(138, 23);
|
||||
this.TXTType.TabIndex = 42;
|
||||
this.TXTType.UseSelectable = true;
|
||||
this.TXTType.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTType.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// metroLabel8
|
||||
//
|
||||
this.metroLabel8.AutoSize = true;
|
||||
this.metroLabel8.Location = new System.Drawing.Point(103, 245);
|
||||
this.metroLabel8.Name = "metroLabel8";
|
||||
this.metroLabel8.Size = new System.Drawing.Size(64, 19);
|
||||
this.metroLabel8.TabIndex = 41;
|
||||
this.metroLabel8.Text = "NC Time:";
|
||||
this.metroLabel8.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel7
|
||||
//
|
||||
this.metroLabel7.AutoSize = true;
|
||||
this.metroLabel7.Location = new System.Drawing.Point(75, 216);
|
||||
this.metroLabel7.Name = "metroLabel7";
|
||||
this.metroLabel7.Size = new System.Drawing.Size(92, 19);
|
||||
this.metroLabel7.TabIndex = 40;
|
||||
this.metroLabel7.Text = "NC Language:";
|
||||
this.metroLabel7.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel6
|
||||
//
|
||||
this.metroLabel6.AutoSize = true;
|
||||
this.metroLabel6.Location = new System.Drawing.Point(85, 187);
|
||||
this.metroLabel6.Name = "metroLabel6";
|
||||
this.metroLabel6.Size = new System.Drawing.Size(82, 19);
|
||||
this.metroLabel6.TabIndex = 39;
|
||||
this.metroLabel6.Text = "Processes N:";
|
||||
this.metroLabel6.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel5
|
||||
//
|
||||
this.metroLabel5.AutoSize = true;
|
||||
this.metroLabel5.Location = new System.Drawing.Point(34, 158);
|
||||
this.metroLabel5.Name = "metroLabel5";
|
||||
this.metroLabel5.Size = new System.Drawing.Size(133, 19);
|
||||
this.metroLabel5.TabIndex = 38;
|
||||
this.metroLabel5.Text = "NC Software Version:";
|
||||
this.metroLabel5.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel4
|
||||
//
|
||||
this.metroLabel4.AutoSize = true;
|
||||
this.metroLabel4.Location = new System.Drawing.Point(62, 129);
|
||||
this.metroLabel4.Name = "metroLabel4";
|
||||
this.metroLabel4.Size = new System.Drawing.Size(105, 19);
|
||||
this.metroLabel4.TabIndex = 37;
|
||||
this.metroLabel4.Text = "CMS Machine Id";
|
||||
this.metroLabel4.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel3
|
||||
//
|
||||
this.metroLabel3.AutoSize = true;
|
||||
this.metroLabel3.Location = new System.Drawing.Point(89, 100);
|
||||
this.metroLabel3.Name = "metroLabel3";
|
||||
this.metroLabel3.Size = new System.Drawing.Size(78, 19);
|
||||
this.metroLabel3.TabIndex = 36;
|
||||
this.metroLabel3.Text = "Nc Serial N:";
|
||||
this.metroLabel3.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel2
|
||||
//
|
||||
this.metroLabel2.AutoSize = true;
|
||||
this.metroLabel2.Location = new System.Drawing.Point(117, 71);
|
||||
this.metroLabel2.Name = "metroLabel2";
|
||||
this.metroLabel2.Size = new System.Drawing.Size(50, 19);
|
||||
this.metroLabel2.TabIndex = 35;
|
||||
this.metroLabel2.Text = "Model:";
|
||||
this.metroLabel2.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// metroLabel1
|
||||
//
|
||||
this.metroLabel1.AutoSize = true;
|
||||
this.metroLabel1.Location = new System.Drawing.Point(112, 42);
|
||||
this.metroLabel1.Name = "metroLabel1";
|
||||
this.metroLabel1.Size = new System.Drawing.Size(55, 19);
|
||||
this.metroLabel1.TabIndex = 34;
|
||||
this.metroLabel1.Text = "Vendor:";
|
||||
this.metroLabel1.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
|
||||
//
|
||||
// ThreadsInfo
|
||||
//
|
||||
this.ThreadsInfo.Controls.Add(this.LISTThreadStatus);
|
||||
@@ -512,13 +125,13 @@ namespace Step.UI
|
||||
this.LISTThreadStatus.Font = new System.Drawing.Font("Segoe UI", 12F);
|
||||
this.LISTThreadStatus.FullRowSelect = true;
|
||||
this.LISTThreadStatus.HeaderStyle = System.Windows.Forms.ColumnHeaderStyle.None;
|
||||
this.LISTThreadStatus.Location = new System.Drawing.Point(0, 3);
|
||||
this.LISTThreadStatus.Location = new System.Drawing.Point(-4, 0);
|
||||
this.LISTThreadStatus.MultiSelect = false;
|
||||
this.LISTThreadStatus.Name = "LISTThreadStatus";
|
||||
this.LISTThreadStatus.OwnerDraw = true;
|
||||
this.LISTThreadStatus.Scrollable = false;
|
||||
this.LISTThreadStatus.ShowGroups = false;
|
||||
this.LISTThreadStatus.Size = new System.Drawing.Size(324, 288);
|
||||
this.LISTThreadStatus.Size = new System.Drawing.Size(328, 275);
|
||||
this.LISTThreadStatus.TabIndex = 2;
|
||||
this.LISTThreadStatus.UseCompatibleStateImageBehavior = false;
|
||||
this.LISTThreadStatus.UseSelectable = true;
|
||||
@@ -539,7 +152,7 @@ namespace Step.UI
|
||||
// stopServerButton
|
||||
//
|
||||
this.stopServerButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.stopServerButton.Location = new System.Drawing.Point(234, 381);
|
||||
this.stopServerButton.Location = new System.Drawing.Point(230, 371);
|
||||
this.stopServerButton.Name = "stopServerButton";
|
||||
this.stopServerButton.Size = new System.Drawing.Size(106, 42);
|
||||
this.stopServerButton.TabIndex = 3;
|
||||
@@ -551,7 +164,7 @@ namespace Step.UI
|
||||
// TestJSButton
|
||||
//
|
||||
this.TestJSButton.AutoSizeMode = System.Windows.Forms.AutoSizeMode.GrowAndShrink;
|
||||
this.TestJSButton.Location = new System.Drawing.Point(122, 381);
|
||||
this.TestJSButton.Location = new System.Drawing.Point(118, 371);
|
||||
this.TestJSButton.Name = "TestJSButton";
|
||||
this.TestJSButton.Size = new System.Drawing.Size(106, 42);
|
||||
this.TestJSButton.TabIndex = 2;
|
||||
@@ -568,9 +181,9 @@ namespace Step.UI
|
||||
//
|
||||
//
|
||||
this.TXTstatus.CustomButton.Image = null;
|
||||
this.TXTstatus.CustomButton.Location = new System.Drawing.Point(334, 1);
|
||||
this.TXTstatus.CustomButton.Location = new System.Drawing.Point(324, 2);
|
||||
this.TXTstatus.CustomButton.Name = "";
|
||||
this.TXTstatus.CustomButton.Size = new System.Drawing.Size(21, 21);
|
||||
this.TXTstatus.CustomButton.Size = new System.Drawing.Size(25, 25);
|
||||
this.TXTstatus.CustomButton.Style = MetroFramework.MetroColorStyle.Blue;
|
||||
this.TXTstatus.CustomButton.TabIndex = 1;
|
||||
this.TXTstatus.CustomButton.Theme = MetroFramework.MetroThemeStyle.Light;
|
||||
@@ -579,7 +192,7 @@ namespace Step.UI
|
||||
this.TXTstatus.Enabled = false;
|
||||
this.TXTstatus.Lines = new string[] {
|
||||
"..."};
|
||||
this.TXTstatus.Location = new System.Drawing.Point(-1, 434);
|
||||
this.TXTstatus.Location = new System.Drawing.Point(-1, 427);
|
||||
this.TXTstatus.MaxLength = 32767;
|
||||
this.TXTstatus.Name = "TXTstatus";
|
||||
this.TXTstatus.PasswordChar = '\0';
|
||||
@@ -589,23 +202,56 @@ namespace Step.UI
|
||||
this.TXTstatus.SelectionLength = 0;
|
||||
this.TXTstatus.SelectionStart = 0;
|
||||
this.TXTstatus.ShortcutsEnabled = true;
|
||||
this.TXTstatus.Size = new System.Drawing.Size(356, 23);
|
||||
this.TXTstatus.Size = new System.Drawing.Size(352, 30);
|
||||
this.TXTstatus.TabIndex = 8;
|
||||
this.TXTstatus.Text = "...";
|
||||
this.TXTstatus.UseSelectable = true;
|
||||
this.TXTstatus.WaterMarkColor = System.Drawing.Color.FromArgb(((int)(((byte)(109)))), ((int)(((byte)(109)))), ((int)(((byte)(109)))));
|
||||
this.TXTstatus.WaterMarkFont = new System.Drawing.Font("Segoe UI", 12F, System.Drawing.FontStyle.Italic, System.Drawing.GraphicsUnit.Pixel);
|
||||
//
|
||||
// TXTType
|
||||
//
|
||||
this.TXTType.AutoSize = true;
|
||||
this.TXTType.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.TXTType.Location = new System.Drawing.Point(179, 348);
|
||||
this.TXTType.Name = "TXTType";
|
||||
this.TXTType.Size = new System.Drawing.Size(51, 13);
|
||||
this.TXTType.TabIndex = 53;
|
||||
this.TXTType.Text = "NcType";
|
||||
//
|
||||
// CHNcConnected
|
||||
//
|
||||
this.CHNcConnected.AutoCheck = false;
|
||||
this.CHNcConnected.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.CHNcConnected.Location = new System.Drawing.Point(246, 345);
|
||||
this.CHNcConnected.Name = "CHNcConnected";
|
||||
this.CHNcConnected.Size = new System.Drawing.Size(81, 20);
|
||||
this.CHNcConnected.TabIndex = 52;
|
||||
this.CHNcConnected.Text = "Connected";
|
||||
this.CHNcConnected.UseSelectable = true;
|
||||
//
|
||||
// label1
|
||||
//
|
||||
this.label1.AutoSize = true;
|
||||
this.label1.Location = new System.Drawing.Point(134, 348);
|
||||
this.label1.Name = "label1";
|
||||
this.label1.Size = new System.Drawing.Size(44, 13);
|
||||
this.label1.TabIndex = 54;
|
||||
this.label1.Text = "Vendor:";
|
||||
//
|
||||
// ServerControlWindow
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(350, 457);
|
||||
this.Controls.Add(this.label1);
|
||||
this.Controls.Add(this.TXTType);
|
||||
this.Controls.Add(this.CHNcConnected);
|
||||
this.Controls.Add(this.TXTstatus);
|
||||
this.Controls.Add(this.TestJSButton);
|
||||
this.Controls.Add(this.stopServerButton);
|
||||
this.Controls.Add(this.metroTabControl1);
|
||||
this.Controls.Add(this.openUiButton);
|
||||
this.Controls.Add(this.TestJSButton);
|
||||
this.ForeColor = System.Drawing.SystemColors.ControlText;
|
||||
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
|
||||
this.Margin = new System.Windows.Forms.Padding(2);
|
||||
@@ -618,10 +264,9 @@ namespace Step.UI
|
||||
this.Theme = MetroFramework.MetroThemeStyle.Default;
|
||||
this.NotifyIconMenu.ResumeLayout(false);
|
||||
this.metroTabControl1.ResumeLayout(false);
|
||||
this.NCInfo.ResumeLayout(false);
|
||||
this.NCInfo.PerformLayout();
|
||||
this.ThreadsInfo.ResumeLayout(false);
|
||||
this.ResumeLayout(false);
|
||||
this.PerformLayout();
|
||||
|
||||
}
|
||||
|
||||
@@ -631,24 +276,6 @@ namespace Step.UI
|
||||
private System.Windows.Forms.ToolStripMenuItem StopServerItem;
|
||||
private MetroFramework.Controls.MetroButton openUiButton;
|
||||
private MetroFramework.Controls.MetroTabControl metroTabControl1;
|
||||
private MetroFramework.Controls.MetroTabPage NCInfo;
|
||||
private MetroFramework.Controls.MetroCheckBox CHNcConnected;
|
||||
private MetroFramework.Controls.MetroTextBox TXTTime;
|
||||
private MetroFramework.Controls.MetroTextBox TXTLang;
|
||||
private MetroFramework.Controls.MetroTextBox TXTNCProc;
|
||||
private MetroFramework.Controls.MetroTextBox TXTSftVers;
|
||||
private MetroFramework.Controls.MetroTextBox TXTCMSMach;
|
||||
private MetroFramework.Controls.MetroTextBox TXTNcSerial;
|
||||
private MetroFramework.Controls.MetroTextBox TXTName;
|
||||
private MetroFramework.Controls.MetroTextBox TXTType;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel8;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel7;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel6;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel5;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel4;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel3;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel2;
|
||||
private MetroFramework.Controls.MetroLabel metroLabel1;
|
||||
private MetroFramework.Controls.MetroButton stopServerButton;
|
||||
private MetroFramework.Controls.MetroButton TestJSButton;
|
||||
private MetroFramework.Controls.MetroTabPage ThreadsInfo;
|
||||
@@ -656,5 +283,8 @@ namespace Step.UI
|
||||
private System.Windows.Forms.ColumnHeader columnHeader1;
|
||||
private System.Windows.Forms.ColumnHeader columnHeader2;
|
||||
private MetroFramework.Controls.MetroTextBox TXTstatus;
|
||||
private Label TXTType;
|
||||
private MetroFramework.Controls.MetroCheckBox CHNcConnected;
|
||||
private Label label1;
|
||||
}
|
||||
}
|
||||
@@ -42,7 +42,7 @@ namespace Step.UI
|
||||
|
||||
MessageServices.Current.Subscribe(SHOW_MSG_UI, (a, b) =>
|
||||
{
|
||||
this.Invoke((MethodInvoker)delegate () { this.Focus(); MessageBox.Show(a.ToString()); });
|
||||
Invoke((MethodInvoker)delegate () { Focus(); MessageBox.Show(a.ToString()); });
|
||||
});
|
||||
}
|
||||
|
||||
@@ -139,122 +139,92 @@ namespace Step.UI
|
||||
|
||||
private void InitializeMessageListeners()
|
||||
{
|
||||
MVVMListeners = new List<RegistrationInfo>();
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
|
||||
MVVMListeners = new List<RegistrationInfo>
|
||||
{
|
||||
MessageServices.Current.Subscribe(SEND_MESSAGE, (a, b) =>
|
||||
{
|
||||
// Cast object to ErrorMessageModel
|
||||
ErrorMessageModel message = (ErrorMessageModel)a;
|
||||
// If error has a fatal level, icon must be error
|
||||
message.ErrorLevel = message.ErrorLevel > (int)ERROR_LEVEL.ERROR ? (int)ERROR_LEVEL.ERROR : message.ErrorLevel;
|
||||
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
// Open BalloonTip with data
|
||||
StepNotifyIcon.ShowBalloonTip(1000, message.Title, message.Message, (ToolTipIcon)message.ErrorLevel);
|
||||
|
||||
//ShowMessage on UI
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + message.Message;
|
||||
});
|
||||
}));
|
||||
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
|
||||
{
|
||||
bool newNcStatus = (bool)a;
|
||||
|
||||
if (ncStatus != newNcStatus)
|
||||
});
|
||||
}),
|
||||
// NC status handler
|
||||
MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
|
||||
{
|
||||
ncStatus = newNcStatus;
|
||||
string title = "NC not connected";
|
||||
string message = "Check NC connection";
|
||||
ToolTipIcon toolTipIcon = ToolTipIcon.Error;
|
||||
bool newNcStatus = (bool)a;
|
||||
|
||||
if (ncStatus == true)
|
||||
if (ncStatus != newNcStatus)
|
||||
{
|
||||
title = "Nc connection established";
|
||||
message = "Comunication started";
|
||||
toolTipIcon = ToolTipIcon.Info;
|
||||
}
|
||||
ncStatus = newNcStatus;
|
||||
string title = "NC not connected";
|
||||
string message = "Check NC connection";
|
||||
ToolTipIcon toolTipIcon = ToolTipIcon.Error;
|
||||
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
if (ncStatus)
|
||||
{
|
||||
StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon);
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + title;
|
||||
});
|
||||
}
|
||||
title = "Nc connection established";
|
||||
message = "Comunication started";
|
||||
toolTipIcon = ToolTipIcon.Info;
|
||||
}
|
||||
|
||||
if (ncStatus)
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
StepNotifyIcon.Icon = Properties.Resources.Step_Icon;
|
||||
});
|
||||
else
|
||||
{
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
TXTName.Text = "";
|
||||
TXTNcSerial.Text = "";
|
||||
TXTCMSMach.Text = "";
|
||||
TXTSftVers.Text = "";
|
||||
TXTNCProc.Text = "";
|
||||
TXTTime.Text = "";
|
||||
TXTLang.Text = "";
|
||||
StepNotifyIcon.Icon = Properties.Resources.Step_Disconnected;
|
||||
// Show balloon with new status
|
||||
StepNotifyIcon.ShowBalloonTip(1000, title, message, toolTipIcon);
|
||||
TXTstatus.Text = "[" + DateTime.Now.ToString("T") + "] " + title;
|
||||
});
|
||||
}
|
||||
|
||||
//Other type
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
CHNcConnected.Checked = ncStatus;
|
||||
});
|
||||
}));
|
||||
if (ncStatus)
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
StepNotifyIcon.Icon = Properties.Resources.Step_Icon;
|
||||
});
|
||||
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
|
||||
{
|
||||
//Other type
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (!isUpdatingThreads)
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
isUpdatingThreads = true;
|
||||
Dictionary<String, String> Threads = new Dictionary<String, String>((Dictionary<String, String>)a);
|
||||
CHNcConnected.Checked = ncStatus;
|
||||
});
|
||||
}),
|
||||
// Threads status handler
|
||||
MessageServices.Current.Subscribe(SEND_THREADS_STATUS, (a, b) =>
|
||||
{
|
||||
//Other type
|
||||
if (!IsDisposed)
|
||||
Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
if (!isUpdatingThreads)
|
||||
{
|
||||
isUpdatingThreads = true;
|
||||
Dictionary<String, String> Threads = new Dictionary<String, String>((Dictionary<String, String>)a);
|
||||
//Begin the update
|
||||
LISTThreadStatus.BeginUpdate();
|
||||
//clear the List
|
||||
LISTThreadStatus.Items.Clear();
|
||||
//Add all items
|
||||
foreach (KeyValuePair<string, String> Thr in Threads)
|
||||
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { Thr.Key, Thr.Value }));
|
||||
LISTThreadStatus.Items.Add(new ListViewItem(new string[] { Thr.Key, Thr.Value }));
|
||||
//End the update
|
||||
LISTThreadStatus.EndUpdate();
|
||||
isUpdatingThreads = false;
|
||||
}
|
||||
});
|
||||
}));
|
||||
|
||||
MVVMListeners.Add(MessageServices.Current.Subscribe(SEND_GENERIC_DATA, (a, b) =>
|
||||
{
|
||||
DTONcGenericDataModel data = (DTONcGenericDataModel)a;
|
||||
|
||||
//Other type
|
||||
if (!this.IsDisposed)
|
||||
this.Invoke((MethodInvoker)delegate ()
|
||||
{
|
||||
TXTName.Text = data.NcModel;
|
||||
TXTNcSerial.Text = data.SerialNumber;
|
||||
TXTCMSMach.Text = data.CmsMachineIdNumber;
|
||||
TXTSftVers.Text = data.NcSoftwareVersion;
|
||||
TXTNCProc.Text = data.ProcessNumber.ToString();
|
||||
TXTLang.Text = data.Language;
|
||||
TXTTime.Text = data.DateTime.ToShortDateString() + " " + data.DateTime.ToShortTimeString();
|
||||
});
|
||||
}));
|
||||
isUpdatingThreads = false;
|
||||
}
|
||||
});
|
||||
})
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using static Step.Model.Constants;
|
||||
using System.Reflection;
|
||||
using static Step.Model.Constants;
|
||||
|
||||
namespace Step.Utils
|
||||
{
|
||||
@@ -21,7 +22,6 @@ namespace Step.Utils
|
||||
case "SPINDLE": return HEAD_TYPE.SPINDLE;
|
||||
case "AWJ": return HEAD_TYPE.AWJ;
|
||||
default: return HEAD_TYPE.WJ;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,16 +66,39 @@ namespace Step.Utils
|
||||
switch (unit)
|
||||
{
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.mm:
|
||||
return number;
|
||||
return number;
|
||||
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.H:
|
||||
return number * 60;
|
||||
return number * 60;
|
||||
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.D:
|
||||
return number * (24 * 60);
|
||||
return number * (24 * 60);
|
||||
|
||||
case MAINTENANCE_UNIT_OF_MEASURE.M:
|
||||
return (30 * number) * (24 * 60);
|
||||
return (30 * number) * (24 * 60);
|
||||
|
||||
default:
|
||||
return number;
|
||||
return number;
|
||||
}
|
||||
}
|
||||
|
||||
public static void CopyProperties<TParent, TChild>(TParent parent, TChild child) where TParent : class where TChild : class
|
||||
{
|
||||
var parentProperties = parent.GetType().GetProperties();
|
||||
var childProperties = child.GetType().GetProperties();
|
||||
|
||||
foreach (var parentProperty in parentProperties)
|
||||
{
|
||||
foreach (var childProperty in childProperties)
|
||||
{
|
||||
if (parentProperty.Name == childProperty.Name && parentProperty.PropertyType == childProperty.PropertyType)
|
||||
{
|
||||
childProperty.SetValue(child, parentProperty.GetValue(parent));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,575 @@
|
||||
using Step.Database.Controllers;
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels.ToolModels;
|
||||
using Step.NC;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Web.Http;
|
||||
using static CMS_CORE_Library.DataStructures;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Model.Constants;
|
||||
|
||||
namespace Step.Controllers.WebApi
|
||||
{
|
||||
[RoutePrefix("api/tool_manager/nc")]
|
||||
public class NcToolManagerApiController : ApiController
|
||||
{
|
||||
#region Tools
|
||||
|
||||
[Route("tools"), HttpGet]
|
||||
public IHttpActionResult GetNcToolTable()
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
CmsError cmsError = ncHandler.GetToolsData(out List<DTONcToolModel> tools);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok(tools);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("tool"), HttpPost]
|
||||
public IHttpActionResult AddTool([FromBody][Required]DTONewNcToolModel dtoTool)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if family exists
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(dtoTool.FamilyId);
|
||||
if (fam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// If option is active check if shank exists
|
||||
if (ToolManagerConfig.ShankOptIsActive)
|
||||
{
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(dtoTool.ShankId.Value);
|
||||
if (shank == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
else
|
||||
{
|
||||
// If option is not active create a shank
|
||||
DTONewNcShankModel newShank = new DTONewNcShankModel()
|
||||
{
|
||||
Balluf = 0,
|
||||
MagazinePositionType = 0
|
||||
};
|
||||
|
||||
// Create a new shank
|
||||
DbNcShankModel ncShank = toolsManager.AddShank(newShank);
|
||||
// Connect tool to new shank
|
||||
dtoTool.ShankId = ncShank.ShankId;
|
||||
}
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
// Add tool
|
||||
DTONcToolModel newTool = ncHandler.AddTool(dtoTool);
|
||||
|
||||
return Ok(newTool);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("tool/{toolId:int}"), HttpPut]
|
||||
public IHttpActionResult PutTool(int toolId, [FromBody][Required]DTONewNcToolModel dtoTool)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
DbNcToolModel tool = null;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if tool exists
|
||||
tool = toolsManager.FindTool(toolId);
|
||||
if (tool == null)
|
||||
return NotFound();
|
||||
|
||||
if (tool.FamilyId != dtoTool.FamilyId)
|
||||
{
|
||||
// Check if family exists
|
||||
DbNcFamilyModel fam = toolsManager.FindFamily(dtoTool.FamilyId);
|
||||
if (fam == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
// Update
|
||||
CmsError cmsError = ncHandler.UpdateTool(toolId, dtoTool, out DTONcToolModel newTool);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok(newTool);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Route("tool/{toolId:int}"), HttpDelete]
|
||||
public IHttpActionResult DeleteTool(int toolId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
DbNcToolModel tool = toolsManager.FindTool(toolId);
|
||||
if (tool == null)
|
||||
return NotFound();
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
if (!ToolManagerConfig.ShankOptIsActive && tool.ShankId != null)
|
||||
{
|
||||
// If option is active find & delete tool shank
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(tool.ShankId.Value);
|
||||
|
||||
CmsError cmsError = ncHandler.DeleteNcShank(shank.ShankId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
}
|
||||
|
||||
ncHandler.DeleteNcTool(tool);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Tools
|
||||
|
||||
#region Shanks
|
||||
|
||||
[Route("shanks"), HttpGet]
|
||||
public IHttpActionResult GetShanks()
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
return Ok(toolsManager.GetShanks());
|
||||
}
|
||||
}
|
||||
|
||||
[Route("shank"), HttpPost]
|
||||
public IHttpActionResult AddShank([FromBody][Required] DTONewNcShankModel dtoShank)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
if (!ToolManagerConfig.ShankOptIsActive)
|
||||
return BadRequest(API_ERROR_KEYS.OPTION_NOT_ACTIVE);
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
DTONcShankModel shank = (DTONcShankModel)toolsManager.AddShank(dtoShank);
|
||||
|
||||
return Ok(shank);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("shank/{shankId:int}"), HttpPut]
|
||||
public IHttpActionResult PutShank(int shankId, [FromBody][Required]DTONewNcShankModel dtoShank)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if shank exists
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(shankId);
|
||||
if (shank == null)
|
||||
return NotFound();
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
// Update shank
|
||||
cmsError = ncHandler.UpdateShank(shankId, dtoShank, out DTONcShankModel newShank);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok(newShank);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Route("shank/{shankId:int}"), HttpDelete]
|
||||
public IHttpActionResult DeleteShank(int shankId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if shank exists
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(shankId);
|
||||
if (shank == null)
|
||||
return NotFound();
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
cmsError = ncHandler.DeleteNcShank(shank.ShankId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Shanks
|
||||
|
||||
#region Families
|
||||
|
||||
[Route("family"), HttpPost]
|
||||
public IHttpActionResult AddFamily([FromBody][Required]DTONewNcFamilyModel dtoFamily)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
DTONcFamilyModel newFamily = ncHandler.AddFamily(dtoFamily);
|
||||
|
||||
return Ok(newFamily);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("families"), HttpGet]
|
||||
public IHttpActionResult GetFamilies()
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DTONcFamilyModel> families = toolsManager.GetFamilies();
|
||||
|
||||
return Ok(families);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("family/{familyId:int}"), HttpPut]
|
||||
public IHttpActionResult PutFamily(int familyId, [FromBody][Required]DTONewNcFamilyModel dtoFamily)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if family exists
|
||||
DbNcFamilyModel family = toolsManager.FindFamily(familyId);
|
||||
if (family == null)
|
||||
return NotFound();
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
// Update into db and NC
|
||||
cmsError = ncHandler.UpdateFamily(familyId, dtoFamily, out DTONcFamilyModel newFamily);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok(newFamily);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[Route("family/{familyId:int}"), HttpDelete]
|
||||
public IHttpActionResult DeleteFamily(int familyId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Find if exists
|
||||
DbNcFamilyModel family = toolsManager.FindFamily(familyId);
|
||||
if (family == null)
|
||||
return NotFound();
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
CmsError cmsError = ncHandler.Connect();
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
//Delete
|
||||
cmsError = ncHandler.DeleteNcFamily(family);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Families
|
||||
|
||||
#region Magazine positions
|
||||
|
||||
[Route("magazines_positions"), HttpGet]
|
||||
public IHttpActionResult GetMagazinesPositions()
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DbNcMagazinePositionModel> magazines = toolsManager.FindMagazinesPositions();
|
||||
|
||||
return Ok(magazines);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/{magazineId:int}/positions"), HttpGet]
|
||||
public IHttpActionResult GetMagazinesPositions(byte magazineId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DTONcMagazinePositionModel> magazine = toolsManager.GetMagazinePositions(magazineId);
|
||||
|
||||
return Ok(magazine);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/{magazineId}/position/{positionId}"), HttpPut]
|
||||
public IHttpActionResult PutMagazinePosition([Required]byte magazineId, [Required]byte positionId, [FromBody]DTONcMagazinePositionModel dtoPos)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if magazine&position exists
|
||||
DbNcMagazinePositionModel pos = toolsManager.FindMagazinePosition(magazineId, positionId);
|
||||
if (pos == null)
|
||||
return NotFound();
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
CmsError cmsError = ncHandler.UpdateMagazinePosition(pos, dtoPos, out DTONcMagazinePositionModel newPos);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok(newPos);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Magazine positions
|
||||
|
||||
[Route("magazine/{magazineId:int}/mounted_shanks"), HttpGet]
|
||||
public IHttpActionResult GetMagazineTools(byte magazineId)
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if magazine exists
|
||||
List<DbNcMagazinePositionModel> pos = toolsManager.FindMagazinePositions(magazineId);
|
||||
if (pos.Count <= 0)
|
||||
return NotFound();
|
||||
|
||||
List<DTONcShankModel> mountedShank = toolsManager.GetMountedShanks(magazineId);
|
||||
|
||||
return Ok(mountedShank);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/available_shanks"), HttpGet]
|
||||
public IHttpActionResult GetAvailableTools()
|
||||
{
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
List<DTONcShankModel> shanks = toolsManager.GetAvailableShanks();
|
||||
|
||||
return Ok(shanks);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/{magazineId:int}/load/position/{positionId:int}"), HttpPut]
|
||||
public IHttpActionResult LoadToolInToMagazine(byte magazineId, byte positionId, [FromBody][Required] DTOUpdateMagazineModel shankId)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
if (shankId.ToolId == 0)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Check data
|
||||
DbNcShankModel shank;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if shank exists
|
||||
shank = toolsManager.FindShankWithTools(shankId.ToolId);
|
||||
if (shank == null)
|
||||
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
// Check if shank is already loaded somewhere
|
||||
if (shank.MagazineId != null)
|
||||
return BadRequest(API_ERROR_KEYS.TOOL_IS_MOUNTED);
|
||||
|
||||
// Check if magazine position exists
|
||||
DbNcMagazinePositionModel magPos = toolsManager.FindMagazinePosition(magazineId, positionId);
|
||||
if (magPos == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
// Check if the mag pos is disabled
|
||||
if (magPos.Disabled == true)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
// Get Configuration
|
||||
ncHandler.Connect();
|
||||
|
||||
// Check if shank can fit
|
||||
CmsError cmsError = ncHandler.CheckIfShankCanFit(
|
||||
magazineId,
|
||||
positionId,
|
||||
shank // Get mounted tools
|
||||
);
|
||||
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
}
|
||||
|
||||
// Update shank data
|
||||
DTONcMagazinePositionModel magazinePos = (DTONcMagazinePositionModel)toolsManager.LoadShankInMagazine(magazineId, positionId, shank);
|
||||
// Set shankId
|
||||
magazinePos.ShankId = shank.ShankId;
|
||||
|
||||
return Ok(magazinePos);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("magazine/{magazineId:int}/unload/position/{positionId:int}"), HttpPut]
|
||||
public IHttpActionResult UnloadToolInToMagazine(byte magazineId, byte positionId, [FromBody][Required] DTOUpdateMagazineModel shankId)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
if (shankId.ToolId == 0)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Check data
|
||||
DbNcShankModel shank;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if shank exists
|
||||
shank = toolsManager.FindShankWithTools(shankId.ToolId);
|
||||
if (shank == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Check if magazine position exists
|
||||
DbNcMagazinePositionModel magPos = toolsManager.FindMagazinePosition(magazineId, positionId);
|
||||
if (magPos == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
// Check if the mag pos is disabled
|
||||
if (magPos.Disabled == true)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
// Check if magazine position is not occupied
|
||||
DbNcShankModel shankMounted = toolsManager.FindShanksByPositions(magazineId, positionId);
|
||||
if (shankMounted == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
DTONcMagazinePositionModel magazinePos = (DTONcMagazinePositionModel)toolsManager.UnloadShankInMagazine(magazineId, positionId, shank);
|
||||
|
||||
return Ok(magazinePos);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("shank/{shankId:int}/load/tool/{toolId:int}"), HttpPut]
|
||||
public IHttpActionResult LoadToolIntoShank(int shankId, int toolId)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
DbNcToolModel tool;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if shank exists
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(shankId);
|
||||
if (shank == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
tool = toolsManager.FindTool(toolId);
|
||||
if (tool == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
DTONcShankModel shank = ncHandler.LoadIntoShank(tool, shankId);
|
||||
|
||||
return Ok(shank);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("shank/{shankId:int}/unload/tool/{toolId:int}"), HttpPut]
|
||||
public IHttpActionResult UnloadToolIntoShank(int shankId, int toolId)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
|
||||
DbNcToolModel tool;
|
||||
using (NcToolManagerController toolsManager = new NcToolManagerController())
|
||||
{
|
||||
// Check if shank exists
|
||||
DbNcShankModel shank = toolsManager.FindShankWithTools(shankId);
|
||||
if (shank == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
|
||||
tool = toolsManager.FindTool(toolId);
|
||||
if (tool == null)
|
||||
return BadRequest(API_ERROR_KEYS.INCORRECT_PARAMETERS);
|
||||
}
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
DTONcShankModel shank = ncHandler.UnloadFromShank(tool);
|
||||
|
||||
return Ok(shank);
|
||||
}
|
||||
}
|
||||
|
||||
[Route("start_edit_tooling/{magazineId:int}"), HttpPut]
|
||||
public IHttpActionResult StartEditTooling(int magazineId)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError = ncHandler.StartEditTooling(magazineId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
|
||||
[Route("stop_edit_tooling/{magazineId:int}"), HttpPut]
|
||||
public IHttpActionResult StopEditTooling(int magazineId)
|
||||
{
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
|
||||
CmsError cmsError = ncHandler.StopEditTooling(magazineId);
|
||||
if (cmsError.IsError())
|
||||
return BadRequest(cmsError.localizationKey);
|
||||
|
||||
return Ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+4
-3
@@ -1,4 +1,5 @@
|
||||
using Step.Model.DTOModels.ToolModels;
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels.ToolModels;
|
||||
using Step.NC;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -10,7 +11,7 @@ using static CMS_CORE_Library.DataStructures;
|
||||
namespace Step.Controllers.WebApi
|
||||
{
|
||||
[RoutePrefix("api/tool_manager")]
|
||||
public class ToolTableController : ApiController
|
||||
public class SiemensToolManagerController : ApiController
|
||||
{
|
||||
[Route("tools"), HttpGet]
|
||||
public IHttpActionResult GetToolTable()
|
||||
@@ -416,7 +417,7 @@ namespace Step.Controllers.WebApi
|
||||
}
|
||||
|
||||
[Route("shank/{shankId:int}/load/{positionId:int}/tool/{toolId:int}"), HttpPut]
|
||||
public IHttpActionResult LoadToolFromShank(int shankId, int positionId, int toolId)
|
||||
public IHttpActionResult LoadToolIntoShank(int shankId, int positionId, int toolId)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
return BadRequest(ModelState);
|
||||
@@ -1,26 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Step.Database.Controllers;
|
||||
using TeamDev.SDK.MVVM;
|
||||
|
||||
namespace Step.Listeners.Database
|
||||
{
|
||||
public static class DatabaseTest
|
||||
{
|
||||
public static void DbTest(string taskName)
|
||||
{
|
||||
Stopwatch stopwatch = new Stopwatch();
|
||||
stopwatch.Start();
|
||||
using (UsersController usersController = new UsersController())
|
||||
{
|
||||
//user.Create("test", "nuova", "nome", "last", 1, "italian");
|
||||
Console.WriteLine("DB scritto " + taskName + " Thread:" + Thread.CurrentThread.ManagedThreadId + " " + stopwatch.ElapsedMilliseconds);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Step.Database.Controllers;
|
||||
using Step.Model.DatabaseModels;
|
||||
using Step.Model.DTOModels;
|
||||
using Step.Model.DTOModels.ToolModels;
|
||||
using Step.NC;
|
||||
using TeamDev.SDK.MVVM;
|
||||
|
||||
namespace Step.Listeners.Database
|
||||
{
|
||||
public static class SignalRDatabaseHandler
|
||||
{
|
||||
public static void UpdateToolsData(object newData)
|
||||
{
|
||||
using (NcToolManagerController controller = new NcToolManagerController())
|
||||
{
|
||||
// Convert input parameter
|
||||
DTONewToolDataModel data = newData as DTONewToolDataModel;
|
||||
|
||||
List<DbNcToolModel> updatedTools = new List<DbNcToolModel>();
|
||||
// Check if there are new data
|
||||
if (data.UpdatedLives.Count != 0 || data.UpdatedStatus.Count != 0)
|
||||
{
|
||||
List<DbNcToolModel> dbTools = controller.FindTools();
|
||||
if(dbTools.Count > 0)
|
||||
{
|
||||
// Loop through new data
|
||||
foreach (var live in data.UpdatedLives)
|
||||
{
|
||||
// Find tool and update residual life
|
||||
var tmp = dbTools
|
||||
.Where(x => x.ToolId == live.Key) // Get tool by id
|
||||
?.Select(x => {
|
||||
x.ResidualLife = (int)live.Value; // Update data
|
||||
return x;
|
||||
})
|
||||
.FirstOrDefault();
|
||||
|
||||
if(tmp != null)
|
||||
updatedTools.Add(tmp);
|
||||
}
|
||||
|
||||
foreach (var status in data.UpdatedStatus)
|
||||
{
|
||||
var tmp = dbTools
|
||||
.Where(x => x.ToolId == status.Key) // Get tool by id
|
||||
?.Select(x => {
|
||||
x.Status = status.Value;
|
||||
return x;
|
||||
})
|
||||
.FirstOrDefault();
|
||||
|
||||
if (tmp != null)
|
||||
updatedTools.Add(tmp);
|
||||
}
|
||||
}
|
||||
|
||||
// Update database
|
||||
controller.UpdateToolsData(updatedTools);
|
||||
|
||||
using (NcHandler ncHandler = new NcHandler())
|
||||
{
|
||||
ncHandler.Connect();
|
||||
// Update nc data
|
||||
ncHandler.UpdateNcTools(controller);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -19,67 +19,71 @@ namespace Step.Listeners
|
||||
public static void Start()
|
||||
{
|
||||
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_ALARMS, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_ALARMS, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendAlarmsToClient(a as DTOAlarmsModel);
|
||||
}));
|
||||
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_POWER_ON_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_POWER_ON_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendPowerOnDataToClient(a);
|
||||
}));
|
||||
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_NC_STATUS, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_NC_STATUS, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendNcNetworkStatus(a);
|
||||
}));
|
||||
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_PROCESSES_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_PROCESSES_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendProcessesData(a);
|
||||
}));
|
||||
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_FUNCTIONALITY_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_FUNCTIONALITY_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendFunctionalityData(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_EXPIRED_MAINTENANCES_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_EXPIRED_MAINTENANCES_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendExpMaintenancesData(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_NC_SOFTKEYS_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_NC_SOFTKEYS_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendNcSoftKeysData(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_USER_SOFTKEYS_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_USER_SOFTKEYS_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendUserSoftKeysData(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_HEADS_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_HEADS_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendHeadsData(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_AXIS_NAMES_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_AXIS_NAMES_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendAxesNamesData(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_AXES, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_AXES, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendAxesToClient(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_MAGAZINES_STATUS, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_MAGAZINES_STATUS, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendMagazinesStatus(a);
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_ACTIVE_PROGRAM_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(SEND_ACTIVE_PROGRAM_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.SendActiveProgramData(a);
|
||||
}));
|
||||
|
||||
infos.Add(MessageServices.Current.Subscribe(BROADCAST_DATA, async (a, b) =>
|
||||
infos.Add(MessageServices.Current.Subscribe(BROADCAST_DATA, (a, b) =>
|
||||
{
|
||||
SignalRListener.BroadcastData();
|
||||
}));
|
||||
infos.Add(MessageServices.Current.Subscribe(UPDATE_TOOLS_DATA, (a, b) =>
|
||||
{
|
||||
SignalRDatabaseHandler.UpdateToolsData(a);
|
||||
}));
|
||||
}
|
||||
|
||||
public static void Stop()
|
||||
|
||||
+3
-4
@@ -172,14 +172,13 @@
|
||||
<Compile Include="Controllers\SignalR\NcHub.cs" />
|
||||
<Compile Include="Controllers\WebApi\AuthorizationController.cs" />
|
||||
<Compile Include="Controllers\WebApi\ConfigurationController.cs" />
|
||||
<Compile Include="Controllers\WebApi\FavoriteUserSoftKeyController.cs" />
|
||||
<Compile Include="Controllers\WebApi\LanguageController.cs" />
|
||||
<Compile Include="Controllers\WebApi\MaintenanceController.cs" />
|
||||
<Compile Include="Controllers\WebApi\NcFileController.cs" />
|
||||
<Compile Include="Controllers\WebApi\ToolTableController.cs" />
|
||||
<Compile Include="Controllers\WebApi\NcToolManagerController.cs" />
|
||||
<Compile Include="Controllers\WebApi\SiemensToolManagerController.cs" />
|
||||
<Compile Include="Controllers\WebApi\UserController.cs" />
|
||||
<Compile Include="Controllers\WebApi\NcApiController.cs" />
|
||||
<Compile Include="Listeners\Database\DatabaseTest.cs" />
|
||||
<Compile Include="Listeners\Database\SignalRDatabaseHandler.cs" />
|
||||
<Compile Include="Listeners\ListenersHandler.cs" />
|
||||
<Compile Include="Listeners\SignalR\SignalRListener.cs" />
|
||||
<Compile Include="program.cs" />
|
||||
|
||||
+28
-20
@@ -1,26 +1,26 @@
|
||||
using Microsoft.Owin.Hosting;
|
||||
using Step.UI;
|
||||
using System.Threading;
|
||||
using TeamDev.SDK.MVVM;
|
||||
using Step.Config;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Utils.StepLogger;
|
||||
using static Step.Model.Constants;
|
||||
using Step.Database;
|
||||
using Step.Core;
|
||||
using Step.Database;
|
||||
using Step.Listeners;
|
||||
using System;
|
||||
using Step.NC;
|
||||
using Step.UI;
|
||||
using Step.Utils;
|
||||
using System.Net.NetworkInformation;
|
||||
using System;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
using System.Threading;
|
||||
using TeamDev.SDK.MVVM;
|
||||
using static Step.Config.ServerConfig;
|
||||
using static Step.Model.Constants;
|
||||
using static Step.Utils.StepLogger;
|
||||
|
||||
namespace Step
|
||||
{
|
||||
public class Application
|
||||
{
|
||||
|
||||
public static readonly ManualResetEvent StopRequest = new ManualResetEvent(false);
|
||||
|
||||
//Set the Mutef of GUID
|
||||
private static Mutex CmsStepMutex = new Mutex(true, "{689e76ce-b845-49f0-919c-c26491079fca}");
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace Step
|
||||
public static void Main()
|
||||
{
|
||||
LogInfo("Application started");
|
||||
|
||||
|
||||
//Check if is already running an instance of this application
|
||||
if (!CmsStepMutex.WaitOne(TimeSpan.Zero, true))
|
||||
ExceptionManager.Manage(ERROR_LEVEL.FATAL, "Only one istance of Step-Server can be executed!");
|
||||
@@ -41,7 +41,7 @@ namespace Step
|
||||
ServerConfigController.ReadStartupConfig();
|
||||
|
||||
DatabaseContext.SetUpDbConnectionAndDbConfig();
|
||||
|
||||
|
||||
// Register listener to "close application" messages
|
||||
MessageServices.Current.Subscribe(SEND_STOP_SERVER, (a, b) =>
|
||||
{
|
||||
@@ -50,20 +50,26 @@ namespace Step
|
||||
ThreadSiemensHmi.StopWindow();
|
||||
});
|
||||
|
||||
// Setup Osai/fanuc toolManager
|
||||
using (NcHandler handler = new NcHandler())
|
||||
{
|
||||
handler.Connect();
|
||||
handler.SetupNcToolManager();
|
||||
}
|
||||
|
||||
// Start server services
|
||||
if(!ValidateAddress(ServerStartupConfig.ServerAddress))
|
||||
if (!ValidateAddress(ServerStartupConfig.ServerAddress))
|
||||
ExceptionManager.Manage(ERROR_LEVEL.FATAL, "IP Address not valid (must be one configured in Windows-OS)!");
|
||||
|
||||
StartOptions opt = new StartOptions();
|
||||
opt.Urls.Add("http://localhost:" + ServerStartupConfig.ServerPort.ToString());
|
||||
opt.Urls.Add("http://127.0.0.1:" + ServerStartupConfig.ServerPort.ToString());
|
||||
|
||||
if (!String.IsNullOrWhiteSpace(ServerStartupConfig.ServerAddress.ToString()))
|
||||
if (!string.IsNullOrWhiteSpace(ServerStartupConfig.ServerAddress.ToString()))
|
||||
opt.Urls.Add("http://" + ServerStartupConfig.ServerAddress.ToString() + ":" + ServerStartupConfig.ServerPort.ToString());
|
||||
|
||||
using (WebApp.Start<Step.App_Start.Startup>(opt))
|
||||
using (WebApp.Start<App_Start.Startup>(opt))
|
||||
{
|
||||
|
||||
// Start Threads
|
||||
ThreadsHandler.Start();
|
||||
// Start listeners
|
||||
@@ -71,8 +77,9 @@ namespace Step
|
||||
|
||||
// Wait interrupt from client
|
||||
StopRequest.WaitOne();
|
||||
LogInfo("Application closed");
|
||||
LogInfo("Application closed");
|
||||
}
|
||||
|
||||
// Stop Threads
|
||||
ThreadsHandler.Close();
|
||||
// Stop messageservice listeners
|
||||
@@ -81,11 +88,12 @@ namespace Step
|
||||
ServerControlWindow.Stop();
|
||||
}
|
||||
|
||||
private static Boolean ValidateAddress(String Addr) {
|
||||
private static bool ValidateAddress(String Addr)
|
||||
{
|
||||
//If is an asterisk is OK
|
||||
if (String.IsNullOrWhiteSpace(Addr) || Addr == "*")
|
||||
return true;
|
||||
|
||||
|
||||
//Find an IP Address
|
||||
foreach (IPAddress ipAddr in Array.FindAll(Dns.GetHostEntry(string.Empty).AddressList, a => a.AddressFamily == AddressFamily.InterNetwork))
|
||||
{
|
||||
@@ -96,4 +104,4 @@ namespace Step
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user