Files
cms_thermo_active/Step/wwwroot/src/services/toolingService.ts
T
2018-09-27 15:17:41 +02:00

317 lines
11 KiB
TypeScript

import { baseRestService } from "src/_base/baseRestService";
import { toolingActions } from "../store/tooling.store";
import { store, AppModel } from "../store";
export class ToolingService extends baseRestService {
BASE_URL = "api/tool_manager/";
async GetTools() {
let result = await this.Get<server.Tool[]>(this.BASE_URL + "tools");
toolingActions.updateTools(store, result);
}
async GetNcTools(){
let result = await this.Get<server.ToolNc[]>(this.BASE_URL + "nc/tools");
toolingActions.updateNcTools(store, result);
}
async GetFamilies() {
let result = await this.Get<server.Families[]>(this.BASE_URL + "families");
toolingActions.clearFamilies(store);
toolingActions.updateFamilies(store, result);
}
async GetNcFamilies(){
let result = await this.Get<server.FamiliesNc[]>(this.BASE_URL + "nc/families");
// toolingActions.clearFamilies(store);
toolingActions.updateNcFamilies(store, result);
}
async GetShanks() {
let result = await this.Get<server.Shanks[]>(this.BASE_URL + "shanks");
toolingActions.updateShanks(store, result);
}
async GetNcShanks(){
let result = await this.Get<server.ShankNc[]>(this.BASE_URL + "nc/shanks");
toolingActions.updateNcShanks(store, result);
}
async GetMagazinesPositions() {
let result = await this.Get<server.MagazinesPositions[]>(
this.BASE_URL + "magazines_positions"
);
toolingActions.updateMagazinesPositions(store, result);
}
async GetNcMagazinesPositions(){
let result = await this.Get<server.MagazinesPositions[]>(this.BASE_URL + "nc/magazines_positions");
toolingActions.updateMagazinesPositions(store, result);
}
async GetMagazinePosition(id) {
let result = await this.Get<server.MagazinesPositions[]>(
this.BASE_URL + "magazine/" + id + "/positions"
);
toolingActions.updateMagPos(store, result);
}
async GetNcMagazinePosition(id){
let result = await this.Get<server.MagazinesPositions[]>(this.BASE_URL + "nc/magazine/" + id + "/positions");
toolingActions.updateMagPos(store, result);
}
async GetToolsConfiguration() {
let result = await this.Get<server.ToolTableInfoModel>(
"api/configuration/tool_manager"
);
var ts = (store.state as any).tooling;
if(!ts.magazines || ts.magazines.length ==0)
toolingActions.updateMagazine(store, result.magazines);
toolingActions.setMaxTools(store, result.maxTools);
toolingActions.setMaxOffset(store, result.maxOffsets);
toolingActions.setMaxEdgesPerTools(store, result.maxEdgesPerTools);
toolingActions.setMaxMultitools(store, result.maxMultitools);
toolingActions.setToolsPerMultitools(store, result.maxToolsPerMultitools);
toolingActions.setMultitoolOptionActive(store, result.multitoolOptionActive);
toolingActions.setFamilyOptionActive(store, result.familyOptionActive);
toolingActions.setOffsetOptionActive(store, result.offsetOptionActive);
toolingActions.setMagPositionOptionActive(store, result.magPositionOptionActive);
toolingActions.updateToolsConfigurations(store, result.toolsConfiguration);
toolingActions.updateMagazinePosConfigurations(
store,
result.magazinePosConfiguration
);
toolingActions.updateFamilyConfigurations(
store,
result.familiesConfiguration.familyConfiguration
);
toolingActions.updateShankConfigurations(
store,
result.shanksConfiguration.shankConfiguration
);
toolingActions.updateChildToolFamilies(
store,
result.familiesConfiguration.toolsConfiguration
);
toolingActions.updateChildToolShanks(
store,
result.shanksConfiguration.toolsConfiguration
);
toolingActions.updateEdgeConfigurations(
store,
result.edgesConfiguration.edgeConfiguration
);
toolingActions.updateEdgeAdditionalParamsConfiguration(
store,
result.edgesConfiguration.edgesAdditionalParamsConfiguration
);
}
async SetFamily(model: any) {
var response = await this.Post<any>(this.BASE_URL + "family", model);
toolingActions.updateFamily(store, response);
return response;
}
async SetNcFamily(model: any){
var response = await this.Post<any>(this.BASE_URL + "nc/family", model);
toolingActions.updateNcFamily(store, response);
return response;
}
async UpdateFamily(model: server.Families){
var response = await this.Put<any>(this.BASE_URL + "family/" + (model as any).oldName , model);
// debo salvare il modello perch le families non hanno ID e quindi devo utilizzare il vecchio ID che mi genero lato client.
model.name = response.name;
toolingActions.updateFamily(store, model);
return response;
}
async UpdateNcFamily(model: server.FamiliesNc){
var response = await this.Put<any>(this.BASE_URL + "nc/family/" + model.id, model);
toolingActions.updateNcFamily(store, model);
return response;
}
async SetShank(model: any) {
var response = await this.Post<any>(this.BASE_URL + "shank", model);
toolingActions.updateShank(store, response);
return response;
}
async SetNcShank(model: any){
var response = await this.Post<any>(this.BASE_URL + "nc/shank", model);
toolingActions.updateNcShank(store, response);
return response;
}
async SetSiemensTool(model: any) {
var response = await this.Post<any>(this.BASE_URL + "siemens/tool", model);
toolingActions.updateTool(store, response);
return response;
}
async SetNcTool(model: any){
var response = await this.Post<any>(this.BASE_URL + "nc/tool", model);
toolingActions.updateNcTool(store, response);
return response;
}
async UpdateSiemensTool(model: any){
var response = await this.Put<any>(this.BASE_URL + "siemens/tool/" + model.id, model);
// debo salvare il modello perch le families non hanno ID e quindi devo utilizzare il vecchio ID che mi genero lato client.
toolingActions.updateTool(store, model);
return response;
}
async UpdateNcTool(model: any){
var response = await this.Put<any>(this.BASE_URL + "nc/tool/" + model.id, model);
toolingActions.updateNcTool(store, response);
return response;
}
async DeleteTool(model: any) {
var result = await this.Delete<any>(this.BASE_URL + "tool/" + model.id);
toolingActions.deleteTool(store, model);
return result;
}
async DeleteNcTool(model: any){
var result = await this.Delete<any>(this.BASE_URL + "nc/tool/" + model.id);
toolingActions.deleteNcTool(store, model);
return result;
}
async SetEdgeData(tool: any,model: any){
var result = await this.Post<any>(this.BASE_URL + "tool/" + tool.id + "/edge", model);
toolingActions.setEdgeData(store, {tool,result});
return result;
}
async UpdateEdgeData(tool: any, model: any){
var result = await this.Put<any>(this.BASE_URL + "tool/"+ tool.id + "/edge/" + model.id, model);
toolingActions.updateEdgeData(store, model);
return result;
}
async UpdateNcEdgeData(tool: any, model: any){
var result = await this.Put<any>(this.BASE_URL + "nc/offset/" + model.id,model);
toolingActions.updateNcTool(store, tool);
return result;
}
async DeleteEdgeData(tool: any, model: any){
var result = await this.Delete<any>(this.BASE_URL + "tool/" + tool.id + "/edge/" + model.id);
toolingActions.deleteEdgeData(store, {tool,model});
return result;
}
async DeleteOffsetFromTool(pos,toolId){
let result = await this.Put<any>(this.BASE_URL + "nc/tool/" + toolId + "/position/" + pos + "/offset/" + 0,{});
toolingActions.updateNcTool(store, result);
return result;
}
async DeleteFamily(model: any) {
var result = await this.Delete<any>(this.BASE_URL + "family/" + model.oldName);
toolingActions.deleteFamily(store, model);
return result;
}
async DeleteNcFamily(model: any){
var result = await this.Delete<any>(this.BASE_URL + "nc/family/" + model.id);
toolingActions.deleteNcFamily(store,model);
return result;
}
async DeleteShank(model: any) {
var result = await this.Delete<any>(this.BASE_URL + "shank/" + model.id);
toolingActions.deleteShank(store, model);
return result;
}
async DeleteNcShank(model: any){
var result = await this.Delete<any>(this.BASE_URL + "nc/shank/" + model.id);
toolingActions.deleteNcShank(store, model);
return result;
}
async UpdateShank(model: server.Shanks){
var response = await this.Put<server.Shanks>(this.BASE_URL + "shank/" + model.id, model);
toolingActions.updateShank(store, model);
return response;
}
async UpdateNcShank(model: any){
var response = await this.Put<any>(this.BASE_URL + "nc/shank/" + model.id, model);
toolingActions.updateNcShank(store, model);
return response;
}
async UpdateMagPos(model: server.MagazinesPositions){
var response = await this.Put<server.MagazinesPositions>(this.BASE_URL + "magazine/" + model.magazineId + "/position/" + model.positionId, model);
toolingActions.updateMagazinePosition(store, model);
return response;
}
async UpdateNcMagPos(model: server.MagazinesPositions){
var response = await this.Put<server.MagazinesPositions>(this.BASE_URL + "nc/magazine/" + model.magazineId + "/position/" + model.positionId, model);
toolingActions.updateMagazinePosition(store, model);
return response;
}
async addToolToShank(shank: any, model: any){
var response = await this.Put<any>(this.BASE_URL + "shank/"+ shank.id + "/load/" + model.multitoolId + "/tool/" + model.id, model);
toolingActions.addToolToShank(store,{shank, model});
return response;
}
async addToolToShankNc(shank: any, model: any){
var response = await this.Put<any>(this.BASE_URL + "nc/shank/"+ shank.id + "/load/tool/" + model.id, model);
toolingActions.addToolToShankNc(store,{shank, model});
return response;
}
async removeToolToShank(shank: any, model: any){
var response = await this.Put<any>(this.BASE_URL + "shank/"+ shank.id + "/unload/" + model.multitoolId, model);
toolingActions.removeToolToShank(store,{shank, model});
return response;
}
async removeToolToShankNc(shank: any, model: any){
var response = await this.Put<any>(this.BASE_URL + "nc/shank/"+ shank.id + "/unload/tool/" + model.id, model);
toolingActions.removeToolToNcShank(store,{shank, model});
return response;
}
async GetMagazinePositionDepot(id) {
let result = await this.Get<server.MagazinesPositions[]>(
this.BASE_URL + "magazine/" + id + "/positions"
);
toolingActions.setMagPosDepot(store, result);
}
async GetNcMagazinePositionDepot(id) {
let result = await this.Get<server.NcMagazinesPositions[]>(
this.BASE_URL + "nc/magazine/" + id + "/positions"
);
toolingActions.setMagPosNcDepot(store, result);
}
async AddOffsetToToolPosition(pos,toolId,offsetId){
let result = await this.Put<any>(this.BASE_URL + "nc/tool/" + toolId + "/position/" + pos + "/offset/" + offsetId,{});
toolingActions.updateNcTool(store, result);
return result;
}
}