Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.64 KB | None | 0 0
  1. function sanitize(data) {
  2. return Number(data.toString().replace(",", "."));
  3. }
  4.  
  5. function calculatePossibleDieCutPlacements() {
  6. var possibleDieCutPlacements = {};
  7. console.log("WUP" + "\t" +
  8. "LUP" + "\t" +
  9. "AOUp" + "\t" +
  10. "Width" + "\t" +
  11. "Lenght" + "\t" +
  12. "KLenght" + "\t" +
  13. "WWaste" + "\t" +
  14. "LWaste" + "\t" +
  15. "AWaste"+ "\t" +
  16. "WW" + "\t" +
  17. "WL" + "\t" +
  18. "mKnife"+ "\t" +
  19. "APR"+ "\t" +
  20. "minArea");
  21. for (var WidthUP = 1; WidthUP <= DieCutSettings.restrictions().maxWidthUP(); WidthUP++) {
  22. for (var LenghtUP = 1; LenghtUP <= DieCutSettings.restrictions().maxLengthUP(); LenghtUP++) {
  23. var placement = {
  24. amountOfUp: function() {
  25. return WidthUP * LenghtUP
  26. },
  27. width: function() {
  28. return DieCutSettings.UP.Width * WidthUP
  29. },
  30. lenght: function() {
  31. return DieCutSettings.UP.Lenght * LenghtUP
  32. },
  33. knifeLenght: function() {
  34. return DieCutSettings.UP.KnifeLenght * this.amountOfUp()
  35. },
  36. widthWaste: function() {
  37. return Math.ceil((this.width() + DieCutSettings.wasteWidth())/5)*5
  38. },
  39. lenghtWaste: function() {
  40. return Math.ceil((this.lenght() + DieCutSettings.wasteLenght())/5)*5
  41. },
  42. areaWaste: function() {
  43. return this.widthWaste() * this.lenghtWaste()
  44. },
  45. panoramaRatio: function() {
  46. return this.widthWaste() / this.lenghtWaste()
  47. },
  48. hitsOfCutter: function() {
  49. return Order.Volume / this.amountOfUp;
  50. },
  51. flags: function() {
  52. return setFlags(this.knifeLenght(), this.widthWaste(), this.lenghtWaste(), this.areaWaste(), this.panoramaRatio());
  53. }
  54. }
  55.  
  56. console.log(WidthUP + "\t" +
  57. LenghtUP + "\t" +
  58. placement.amountOfUp() + "\t" +
  59. placement.width() + "\t" +
  60. placement.lenght() + "\t" +
  61. placement.knifeLenght() + "\t" +
  62. placement.widthWaste() + "\t" +
  63. placement.lenghtWaste() + "\t" +
  64. Math.round((placement.areaWaste()/1000000)*100)/100 + "\t" +
  65. "%c" + placement.flags.widthWaste() + "\t" +
  66. "%c" + placement.flags.lenghtWaste() + "\t" +
  67. "%c" + placement.flags.maxKnifeLength() + "\t" +
  68. "%c" + placement.flags.allowedPanoramaRatio() + "\t" +
  69. "%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())
  70. )
  71.  
  72. }
  73. }
  74. }
  75.  
  76. function color(data){
  77. if(data)
  78. return "green";
  79. else
  80. return "red";
  81. }
  82.  
  83. function setFlags(KnifeLenght, WidthWithWaste, LenghtWithWaste, AreaWithWaste, PanoramaRatio) {
  84. var Flags = {
  85. wasteWidth: false,
  86. wasteLenght: false,
  87. maxKnifeLength: false,
  88. allowedPanoramaRatio: false,
  89. minArea: false,
  90. }
  91. if (LenghtWithWaste < DieCutSettings.restrictions().maxLenght()) {
  92. Flags.wasteLenght = true;
  93. }
  94. if (WidthWithWaste < DieCutSettings.restrictions().maxWidth()) {
  95. Flags.wasteWidth = true;
  96. }
  97. if (KnifeLenght < DieCutSettings.restrictions().maxKnifeLength()) {
  98. Flags.maxKnifeLength = true;
  99. }
  100. if (PanoramaRatio < DieCutSettings.restrictions().allowedPanoramaRatio()) {
  101. Flags.allowedPanoramaRatio = true;
  102. }
  103. if (AreaWithWaste > DieCutSettings.restrictions().minArea()) {
  104. Flags.minArea = true;
  105. }
  106. return Flags;
  107. }
  108.  
  109. var UP = {
  110. Width: sanitize("838"), //mm
  111. Lenght: sanitize("364"), //mm
  112. KnifeLenght: sanitize("5,79"), //m
  113. Area: sanitize("0,295392"), //m^2
  114. OverlapHeight: sanitize("123"), //mm
  115. Fefco: sanitize("123"), //AEF0123
  116. ConstructionType: function () {
  117. return this.Fefco;
  118. },
  119. };
  120.  
  121. var Order = {
  122. Volume: sanitize("12400"), //units
  123. Printed: true,
  124. }
  125.  
  126. var DieCutSettings = {
  127. Technology: "Flexo",
  128. UP: UP,
  129. restrictions: function () {
  130. return {
  131. Technology: this.Technology,
  132. UP: this.UP,
  133. maxKnifeLength: function () {
  134. return sanitize("45"); //m
  135. },
  136. maxLengthUP: function () {
  137. return 4;
  138. },
  139. allowedPanoramaRatio: function () {
  140. return sanitize("2,6");
  141. },
  142. minArea: function () {
  143. return sanitize("1") * 1000000; //mm^2
  144. },
  145. maxWidth: function () {
  146. if (this.Technology === "Flexo") {
  147. return Number(2100); //mm
  148. } else if (this.Technology === "Offset") {
  149. return Number(1620); //mm
  150. }
  151. },
  152. maxLenght: function () {
  153. if (this.Technology === "Flexo") {
  154. return Number(1300); //mm
  155. } else if (this.Technology === "Offset") {
  156. return Number(1200); //mm
  157. }
  158. },
  159. maxWidthUP: function () {
  160. return Math.floor(this.maxWidth() / this.UP.Width);
  161. }
  162. }
  163. },
  164. wasteWidth: function () {
  165. if (this.Technology === "Flexo") {
  166. return Number(25);
  167. } else if (this.Technology === "Offset") {
  168. return Number(30);
  169. }
  170. },
  171. wasteLenght: function () {
  172. if (this.Technology === "Flexo") {
  173. return Number(30);
  174. } else if (this.Technology === "Offset") {
  175. return Number(35);
  176. }
  177. },
  178. };
  179.  
  180. calculatePossibleDieCutPlacements(DieCutSettings);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement