Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function sanitize(data) {
- return Number(data.toString().replace(",", "."));
- }
- function calculatePossibleDieCutPlacements() {
- var possibleDieCutPlacements = {};
- console.log("WUP" + "\t" +
- "LUP" + "\t" +
- "AOUp" + "\t" +
- "Width" + "\t" +
- "Lenght" + "\t" +
- "KLenght" + "\t" +
- "WWaste" + "\t" +
- "LWaste" + "\t" +
- "AWaste"+ "\t" +
- "WW" + "\t" +
- "WL" + "\t" +
- "mKnife"+ "\t" +
- "APR"+ "\t" +
- "minArea");
- for (var WidthUP = 1; WidthUP <= DieCutSettings.restrictions().maxWidthUP(); WidthUP++) {
- for (var LenghtUP = 1; LenghtUP <= DieCutSettings.restrictions().maxLengthUP(); LenghtUP++) {
- var placement = {
- amountOfUp: function() {
- return WidthUP * LenghtUP
- },
- width: function() {
- return DieCutSettings.UP.Width * WidthUP
- },
- lenght: function() {
- return DieCutSettings.UP.Lenght * LenghtUP
- },
- knifeLenght: function() {
- return DieCutSettings.UP.KnifeLenght * this.amountOfUp()
- },
- widthWaste: function() {
- return Math.ceil((this.width() + DieCutSettings.wasteWidth())/5)*5
- },
- lenghtWaste: function() {
- return Math.ceil((this.lenght() + DieCutSettings.wasteLenght())/5)*5
- },
- areaWaste: function() {
- return this.widthWaste() * this.lenghtWaste()
- },
- panoramaRatio: function() {
- return this.widthWaste() / this.lenghtWaste()
- },
- hitsOfCutter: function() {
- return Order.Volume / this.amountOfUp;
- },
- flags: function() {
- return setFlags(this.knifeLenght(), this.widthWaste(), this.lenghtWaste(), this.areaWaste(), this.panoramaRatio());
- }
- }
- console.log(WidthUP + "\t" +
- LenghtUP + "\t" +
- placement.amountOfUp() + "\t" +
- placement.width() + "\t" +
- placement.lenght() + "\t" +
- placement.knifeLenght() + "\t" +
- placement.widthWaste() + "\t" +
- placement.lenghtWaste() + "\t" +
- Math.round((placement.areaWaste()/1000000)*100)/100 + "\t" +
- "%c" + placement.flags.widthWaste() + "\t" +
- "%c" + placement.flags.lenghtWaste() + "\t" +
- "%c" + placement.flags.maxKnifeLength() + "\t" +
- "%c" + placement.flags.allowedPanoramaRatio() + "\t" +
- "%c" + placement.flags.minArea(), "color:" + color(placement.flags.widhtWaste()), "color:" + color(placement.flags.lenghtWaste()), "color:" + color(placement.flags.maxKnifeLength()), "color:" + color(placement.flags.allowedPanoramaRatio()), "color:" + color(placement.flags.minArea())
- )
- }
- }
- }
- function color(data){
- if(data)
- return "green";
- else
- return "red";
- }
- function setFlags(KnifeLenght, WidthWithWaste, LenghtWithWaste, AreaWithWaste, PanoramaRatio) {
- var Flags = {
- wasteWidth: false,
- wasteLenght: false,
- maxKnifeLength: false,
- allowedPanoramaRatio: false,
- minArea: false,
- }
- if (LenghtWithWaste < DieCutSettings.restrictions().maxLenght()) {
- Flags.wasteLenght = true;
- }
- if (WidthWithWaste < DieCutSettings.restrictions().maxWidth()) {
- Flags.wasteWidth = true;
- }
- if (KnifeLenght < DieCutSettings.restrictions().maxKnifeLength()) {
- Flags.maxKnifeLength = true;
- }
- if (PanoramaRatio < DieCutSettings.restrictions().allowedPanoramaRatio()) {
- Flags.allowedPanoramaRatio = true;
- }
- if (AreaWithWaste > DieCutSettings.restrictions().minArea()) {
- Flags.minArea = true;
- }
- return Flags;
- }
- var UP = {
- Width: sanitize("838"), //mm
- Lenght: sanitize("364"), //mm
- KnifeLenght: sanitize("5,79"), //m
- Area: sanitize("0,295392"), //m^2
- OverlapHeight: sanitize("123"), //mm
- Fefco: sanitize("123"), //AEF0123
- ConstructionType: function () {
- return this.Fefco;
- },
- };
- var Order = {
- Volume: sanitize("12400"), //units
- Printed: true,
- }
- var DieCutSettings = {
- Technology: "Flexo",
- UP: UP,
- restrictions: function () {
- return {
- Technology: this.Technology,
- UP: this.UP,
- maxKnifeLength: function () {
- return sanitize("45"); //m
- },
- maxLengthUP: function () {
- return 4;
- },
- allowedPanoramaRatio: function () {
- return sanitize("2,6");
- },
- minArea: function () {
- return sanitize("1") * 1000000; //mm^2
- },
- maxWidth: function () {
- if (this.Technology === "Flexo") {
- return Number(2100); //mm
- } else if (this.Technology === "Offset") {
- return Number(1620); //mm
- }
- },
- maxLenght: function () {
- if (this.Technology === "Flexo") {
- return Number(1300); //mm
- } else if (this.Technology === "Offset") {
- return Number(1200); //mm
- }
- },
- maxWidthUP: function () {
- return Math.floor(this.maxWidth() / this.UP.Width);
- }
- }
- },
- wasteWidth: function () {
- if (this.Technology === "Flexo") {
- return Number(25);
- } else if (this.Technology === "Offset") {
- return Number(30);
- }
- },
- wasteLenght: function () {
- if (this.Technology === "Flexo") {
- return Number(30);
- } else if (this.Technology === "Offset") {
- return Number(35);
- }
- },
- };
- calculatePossibleDieCutPlacements(DieCutSettings);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement