Commit 472698f3 authored by Scott Sun's avatar Scott Sun

s

parent b9d75c41
This diff is collapsed.
This diff is collapsed.
......@@ -170,6 +170,96 @@
"type": "ODB",
"format": "ODB"
},
{
"valid": function(props){
var file = props.file;
return /.+\.art$/ig.test(file.name)
},
"type": "Gerber274x",
"format": "Gerber274x_2",
"format_params": function(props){
var params = props.params
if(params.art_param){
var leading = params.art_param["SUPPRESS_LEAD_ZEROES"]
var trailing = params.art_param["SUPPRESS_TRAIL_ZEROES"]
var zeroes = "none"
if(/yes/ig.test(leading)){
zeroes = "leading"
}
if(/yes/ig.test(trailing)){
zeroes = "trailing"
}
var nf1,nf2
if(params.art_param.hasOwnProperty("FORMAT")){
var tmp = params.art_param["FORMAT"].split(".")
if(/\d+/ig.test(tmp[0])){nf1 = Number(tmp[0])}
if(/\d+/ig.test(tmp[1])){nf2 = Number(tmp[1])}
}
return {
"nf1": nf1 || 3,
"nf2": nf2 || 5,
"units": /METRIC|MM/ig.test(params.art_param["OUTPUT_UNITS"])? "mm" :"inch",
"zeroes": zeroes,
"decimal": "no",
"nf_comp": 0,
"break_sr": "yes",
"data_type": "ascii",
"separator": "*",
"threshold": 200,
"drill_only": "no",
"multiplier": 1,
"resolution": 3,
"tool_units": /METRIC|MM/ig.test(params.art_param["OUTPUT_UNITS"])? "mm" :"inch",
"coordinates": "absolute",
"merge_by_rule": "no",
"signed_coords": "no",
"text_line_width": 0.0024
}
}
}
},
{
"valid": function(props){
var file = props.file;
return /.+\.drl$/ig.test(file.name)
},
"type": "Excellon2",
"format": "Excellon2_1",
"format_params": function(props){
var params = props.params
if(params.nc_param){
var leading = params.nc_param["SUPPRESS_LEAD_ZEROES"]
var trailing = params.nc_param["SUPPRESS_TRAIL_ZEROES"]
var zeroes = "none"
if(/yes/ig.test(leading)){
zeroes = "leading"
}
if(/yes/ig.test(trailing)){
zeroes = "trailing"
}
return {
"nf1": params.nc_param["INTEGER_PLACES"]? Number(params.nc_param["INTEGER_PLACES"]) : 3,
"nf2": params.nc_param["DECIMAL_PLACES"]? Number(params.nc_param["DECIMAL_PLACES"]) : 5,
"units": /METRIC|MM/ig.test(params.nc_param["OUTPUT_UNITS"])? "mm" :"inch",
"zeroes": zeroes,
"decimal": "no",
"nf_comp": 0,
"break_sr": "yes",
"data_type": "ascii",
"separator": "nl",
"threshold": 200,
"drill_only": "no",
"multiplier": 1,
"resolution": 3,
"tool_units": /METRIC|MM/ig.test(params.nc_param["OUTPUT_UNITS"])? "mm" :"inch",
"coordinates": params.nc_param["COORDINATES"]? params.nc_param["COORDINATES"].toLowerCase() :"absolute",
"merge_by_rule": "no",
"signed_coords": "no",
"text_line_width": 0.0024
}
}
}
},
{
"valid": function(props){
var file = props.file;
......@@ -337,7 +427,7 @@
{"orig_name" : ["\\.rou$","^rout$"], "tl_name" : "rout" },
{"orig_name" : "fab.art", "tl_name" : "fab.art" },
{"orig_name" : ["multipack.art","^array$"], "tl_name" : "array" },
{"orig_name" : ["outline.art","^outline$"], "tl_name" : "outline" },
{"orig_name" : ["^outline"], "tl_name" : "outline" },
{"orig_name" : "top-enig", "tl_name" : "top-enig" },
{"orig_name" : "bot-enig", "tl_name" : "bot-enig" },
{"orig_name" : "fab_page2", "tl_name" : "fab_page2" },
......
......@@ -98,9 +98,6 @@ try {
if(par.outline == "" || par.outline == undefined || par.outline == null || par.outline == "null"){
outline_symbol = "null";
} else {
if(!/^(([^0][0-9]+|0)\.([0-9]{1,2})$)|^([^0][0-9]+|0)$/ig.test(par.outline_width)){
throw "outline_width failed"
}
par.outline_width = parseFloat(par.outline_width)
outline_symbol = "r" + String(par.outline_width * 1000);
}
......@@ -117,36 +114,44 @@ try {
if(GEN.checkInout({job:job,mode:"test"}) != 0){ throw "the job check" }
GEN.checkInout({job:job,mode:"out"});
// 判断参考层(ref_outline)是否存在并不为空
if(!GEN.isLayerExists({job:job,layer:ref_outline})){throw "ref_outline不存在"}
var is_outline_exist = GEN.isLayerExists({job:job,layer:outline})
if(!GEN.isLayerExists({job:job,layer:ref_outline})){
if(!is_outline_exist){
throw "外形层不存在"
}
}
var steplist = GEN.getStepList({job:job})
if(!is_outline_exist){
steplist.forEach(function(step){
if(!GEN.isLayerEmpty({job:job,step:step,layer:ref_outline})){
// 创建新的外形层(outline)
GEN.openStep({job:job,name:step})
if(GEN.isLayerExists({job:job,layer:outline})){
GEN.workLayer({name:outline,display_number:2,clear_before:'yes'})
GEN.selDelete()
}else {
GEN.createLayer({job:job,layer:outline,conext:"misc",type:"document"})
}
GEN.createLayer({job:job,layer:outline,conext:"board",type:"rout"})
// 将参考层copy到外形层中
GEN.selClearFeature()
GEN.workLayer({name:ref_outline,display_number:2,clear_before:'yes'})
GEN.selAllFeat()
GEN.selCopyOther({dest:"layer_name", target_layer:outline})
GEN.closeStep()
}
})
}
steplist.forEach(function(step){
// 修改外形层
GEN.openStep({job:job,name:step})
GEN.affectedLayer({affected:'no',mode:'all'})
GEN.selClearFeature()
GEN.workLayer({name:outline,display_number:2,clear_before:'yes'})
if(outline_symbol != "null"){
GEN.selChangeSym({symbol: outline_symbol})
GEN.selClearFeature()
}
GEN.selCreateProfile()
GEN.clearLayers()
GEN.closeStep()
}
})
// 保存
if(/yes/ig.test(par.auto_save)){
GEN.checkInout({job:job,mode:"out"}) // 结束保存料号 关闭料号
......@@ -157,7 +162,14 @@ try {
GEN.checkInout({job:job,mode:"in"})
}
if(/yes/ig.test(par.auto_save)){
GEN.checkInout({job:job,mode:"out"}) // 结束保存料号 关闭料号
GEN.saveJob({ job: job });
GEN.checkInout({job:job,mode:"in"})
GEN.closeJob({job:job})
} else {
GEN.checkInout({job:job,mode:"in"})
}
QDfm.updateRow({
table: "pdm_aimdfm_task",
......
......@@ -113,7 +113,10 @@ try {
include_syms:cutting_marign_symbol,
profile: "out"
})
GEN.selDelete() // ?
if(GEN.getSelectCount()> 0){
GEN.selDelete()
}
GEN.affectedLayer({affected:'no',mode:'all'})
GEN.closeStep()
})
......
......@@ -73,14 +73,14 @@ if (!$.hasOwnProperty('auto_save')){
PAR.auto_save = "no"
}
// drill tool manage
var drill_toll_manage = []
var drill_toll_manage = {}
try {
var par = PAR;
var config = {
format: {
"Gerber274x_1": {
"nf1": 2,
"nf1": 5,
"nf2": 5,
"units": "inch",
"zeroes": "leading",
......@@ -101,7 +101,7 @@ try {
},
"Excellon2_1": {
"nf1": 2,
"nf2": 5,
"nf2": 3,
"units": "inch",
"zeroes": "none",
"decimal": "no",
......@@ -167,7 +167,9 @@ try {
if(/\.drl$/ig.test(file.name)){
var backUpName = file.name+".backup"
// 备份
if(!fs.fileExists(file.dir+"/"+backUpName)){
fs.copyFile(file.path,file.dir+"/"+backUpName)
}
// 读取
var data = fs.readFile(file.path)
data = data.split("\n")
......@@ -177,6 +179,7 @@ try {
var headData = head.filter(function(v){
return /Holesize.+Tolerance.+PLATED/ig.test(v)
})
headData.map(function(v){
var res = {
holesize: {},
......@@ -195,12 +198,18 @@ try {
res.tolerance.bot = Tolerance_tmp[1].trim()
res.attr = /NON_PLATED/ig.test(v) ? "non_plated" : "plated"
res.unit = /MILES/ig.test(v) ? "inch" : "mm"
res.unit = /MILS/ig.test(v) ? "inch" : "mm"
res.quantity = parseInt(v.split("=").pop())
drill_toll_manage.push(res)
if(!drill_toll_manage.hasOwnProperty(file.name)){
drill_toll_manage[file.name] = {}
}
drill_toll_manage[file.name][/(\d+)/ig.exec(res.holesize.key)[1]] = res
})
// 给body添加刀
var count = 0
body = body.filter(function(v){
return !(/T\d+/ig.test(v))
})
body.forEach(function(v, i){
if(/^%$|^M00/ig.test(v)){
var k = "T" + getK(++count)
......@@ -212,10 +221,31 @@ try {
fs.writeFile(file.path,resStr)
}
})
drill_toll_manage.forEach(function(v){
console.log(v);
importGerber({job:job,step:"orig",db:"genesis",data:inputInfo.data})
var stepList = GEN.getStepList({job:job})
var matrix = GEN.getMatrix({job:job})
var drill_layers = Object.keys(matrix).filter(function(v){return matrix[v].layer_type=="drill"})
stepList.forEach(function(step){
GEN.openStep({job:job,name:step})
drill_layers.forEach(function(layer){
var drill_tool_manage_info = drill_toll_manage[layer]
var drill_tool_keys = Object.keys(drill_tool_manage_info).sort(function(a,b){return a-b})
GEN.COM("tools_tab_reset")
drill_tool_keys.forEach(function(key){
var val = drill_tool_manage_info[key]
GEN.COM("tools_tab_add", {
num: key,
type: /plated/ig.test(val.attr) ? "plate" : "nplate",
min_tol: Number(val.tolerance.top),
max_tol: Number(val.tolerance.bot),
finish_size: Number(val.holesize.value),
drill_size: Number(val.holesize.value)
})
})
GEN.COM("tools_set",{layer:layer,thickness:0,user_params:1,slots:"by_length"})
})
GEN.closeStep()
})
// importGerber({job:job,step:"pcs",db:"genesis",data:inputInfo.data})
}
// 保存
......
......@@ -42,7 +42,7 @@ PARAMETER:
*/
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
console.log("==============================>设置零点");
console.log("==============================>set origin");
// 引入模块 包
var $ = require('topcam.scriptfunc').argv();
var fs = require('fs');
......@@ -80,7 +80,7 @@ try {
par[key] = default_par[key]
}
}
if(_.isEmpty(Job))
if(_.isEmpty(Job)){throw "Job参数未拿到"}
var job = Job.toLowerCase()
var outline = par.outline
// 检查料号是否存在
......@@ -103,19 +103,13 @@ try {
var outline_symbol = GEN.getSymbolLimits({job:job,symbol:outline})
GEN.affectedLayer({affected:"yes",mode:"all"})
GEN.selMove({dx:-outline_symbol.xmin,dy:-outline_symbol.ymin})
// 创建为profile
GEN.affectedLayer({affected:"no",mode:"all"})
GEN.workLayer({name:outline,display_number:2,clear_before:'yes'})
GEN.selAllFeat()
GEN.selCreateProfile()
GEN.clearLayers()
GEN.selClearFeature()
GEN.closeJob()
GEN.closeStep()
}
})
// 保存
if(/yes/ig.test(par.auto_save)){
GEN.checkInout({job:job,mode:"out"}) // 结束保存料号 关闭料号
......@@ -126,6 +120,7 @@ try {
GEN.checkInout({job:job,mode:"in"})
}
console.log("set origin end")
QDfm.updateRow({
......
This diff is collapsed.
This diff is collapsed.
......@@ -148,7 +148,6 @@ try {
// })
// })
// })
// stepList.forEach(function(step){
// GEN.openStep({ job: Job, step: step })
// GEN.clearLayers()
......
......@@ -10,19 +10,24 @@ var Job = $.job;
var JobId = $.job_id;
try {
var job = "4"
var tmp = [{signalL:"top",solderL:"sm_top"}, {signalL:"top",solderL:null}]
// exposed
tmp.forEach(function(item){
if(item.solderL){
IKM.msg(GEN.exposedArea({layer1:item.signalL,mask1:item.solderL}))
// {"area":"0.73817","percent":"8.986"}
}
})
var job = "1"
var step = "cad"
var matrix = GEN.getMatrix({job:job})
IKM.msg(matrix)
return "Done"
} catch (e) {
IKM.msg(e)
return "Error"
}
// COM sel_cut_data,det_tol=1,con_tol=1,rad_tol=0.1,filter_overlaps=no,delete_doubles=no,use_order=yes,ignore_width=yes,ignore_holes=none,start_positive=yes,polarity_of_touching=same
// COM sel_single_feat,operation=select,x=-0.3463252953,y=0.7876788386,tol=25.4822834646,cyclic=no
// COM sel_surf2outline,width=15
function selCopyLayer(props){ // 拷贝选择的到辅助层
var layer = props.layer
var job = props.job
if(GEN.isLayerExists({job:job,layer:layer})){
GEN.deleteLayer({job:job,layer:layer})
}
GEN.selCopyOther({dest:'layer_name',target_layer:layer})
}
\ No newline at end of file
try {
var query = new TSqlQueryV2(T_SQLCNT_POOL.getSqlDatabase());
var selector = new TSqlSelectorV2;
selector.setTable("pdm_job_work_layer");
selector.setField(["name"]);
selector.setWhere("job_id", this.jobId);
selector.addWhere('type', 'outer');
selector.setOrder("row_num", 1);
var layerList = query.selectArrayValue(selector);
if (query.lastError().isValid()) {
throw query.lastError();
}
selector.clear();
selector.setTable("pdm_job_layerattr");
selector.setField(["attr_name", "layer", "value"]);
selector.setWhere("job_id", this.jobId);
selector.addWhere('layer', layerList);
var attrList = query.selectArrayMap(selector);
if (query.lastError().isValid()) {
throw query.lastError();
}
var tmp = "12.5466"
selector.clear();
selector.setTable("pdm_job_work_layer");
selector.setField(["odb_name", "side"]);
selector.setWhere("job_id", this.jobId);
selector.addWhere('odb_context', 'board');
selector.setOrder("type", "solder_mask");
var nameList = query.selectArrayMap(selector);
if (query.lastError().isValid()) {
throw query.lastError();
}
var goldMap = {};
var refLayerMap = {};
_.each(nameList, function (item) {
if (item["odb_name"] == "gold") {
goldMap[item["side"]] = item["odb_name"];
} else if (item["odb_name"] == "ref_layer") {
refLayerMap[item["side"]] = item["odb_name"];
}
})
var dataMap = {};
_.each(attrList, function (valueMap) {
var tempList = [];
if (!_.isEmpty(dataMap[valueMap["layer"]])) {
tempList = dataMap[valueMap["layer"]];
}
tempList.push(valueMap);
dataMap[valueMap["layer"]] = tempList;
})
var retMap = {};
for (var key in dataMap) {
var tempMap = {};
_.each(dataMap[key], function (itemMap) {
tempMap[itemMap["attr_name"]] = itemMap["value"];
})
retMap[key] = tempMap;
}
var itemList = ["top", "bottom"];
var retList = [];
_.each(itemList, function (item) {
var tempMap = retMap[item];
tempMap["gold"] = goldMap[item];
tempMap["ref_layer"] = refLayerMap[item];
retList.push(tempMap);
})
return JSON.stringify(retList);
} catch (e) {
print(e);
GUI.msgbox({
title: 'Error',
detail: e
});
}
\ No newline at end of file
console.log(tmp.toFixed(2));
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment