Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
S
Scott
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Scott Sun
Scott
Commits
431f8581
Commit
431f8581
authored
Jun 19, 2020
by
Scott Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
s
parent
f35174ce
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
185 additions
and
277 deletions
+185
-277
analysis_test.js
ats/scott_test/analysis_test.js
+69
-6
format_test.js
ats/scott_test/format_test.js
+3
-2
config_ats.js
config_ats.js
+1
-0
ATS_AIM_input_data.js
test/ATS_AIM_input_data.js
+112
-261
mytest.js
test/mytest.js
+0
-8
No files found.
ats/scott_test/analysis_test.js
View file @
431f8581
...
@@ -429,8 +429,9 @@ try {
...
@@ -429,8 +429,9 @@ try {
depth_drilling
:
{
api
:
"layer_exist"
,
props
:
"depth_drill"
},
// yes|no :存在 depth_drill 层时 ,存yes
depth_drilling
:
{
api
:
"layer_exist"
,
props
:
"depth_drill"
},
// yes|no :存在 depth_drill 层时 ,存yes
depth_routing
:
{
api
:
"layer_exist"
,
props
:
"depth_routing"
},
// tmp yes|no :存在 depth_routing 层时,,存yes
depth_routing
:
{
api
:
"layer_exist"
,
props
:
"depth_routing"
},
// tmp yes|no :存在 depth_routing 层时,,存yes
laser_via_on_buried_hole
:
true
,
// via孔在埋孔上时,存yes
laser_via_on_buried_hole
:
true
,
// via孔在埋孔上时,存yes
milling_bit_size
:
true
,
// todo 检查array中pcs的最小间距值
milling_bit_size
:
false
,
// todo 检查array中pcs的最小间距值
milling_length
:
true
,
// todo 检查array中铣切长度
milling_length_card
:
true
,
milling_length_array
:
true
,
vc_src_01005_pad_result
:
{
api
:
"board_has_attr"
,
props
:
vc_src_01005_pad_result
},
// 本地使用 .pth_pad ats 01005_pad
vc_src_01005_pad_result
:
{
api
:
"board_has_attr"
,
props
:
vc_src_01005_pad_result
},
// 本地使用 .pth_pad ats 01005_pad
ATS_technology_25dc
:
{
api
:
"layer_exist"
,
props
:[
"bot_coverlay"
,
"top_coverlay"
]},
// yes|no:存在cavity层别时存yes
ATS_technology_25dc
:
{
api
:
"layer_exist"
,
props
:[
"bot_coverlay"
,
"top_coverlay"
]},
// yes|no:存在cavity层别时存yes
ATS_technology_25dr
:
{
api
:
"layer_exist"
,
props
:[
"bot_coverlay"
,
"top_coverlay"
]},
// yes|no:存在cavity层别时存yes
ATS_technology_25dr
:
{
api
:
"layer_exist"
,
props
:[
"bot_coverlay"
,
"top_coverlay"
]},
// yes|no:存在cavity层别时存yes
...
@@ -468,6 +469,7 @@ try {
...
@@ -468,6 +469,7 @@ try {
jobInfo
[
key
]
=
analysis_obj
[
"analysis_"
+
key
](
props
)
jobInfo
[
key
]
=
analysis_obj
[
"analysis_"
+
key
](
props
)
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
console
.
log
(
"========================================error:"
);
console
.
log
(
e
);
console
.
log
(
e
);
jobInfo
[
key
]
=
"_error"
jobInfo
[
key
]
=
"_error"
}
}
...
@@ -1464,8 +1466,60 @@ function analysis(props){
...
@@ -1464,8 +1466,60 @@ function analysis(props){
T_m_p
.
prototype
.
analysis_milling_bit_size
=
function
(){
// todo
T_m_p
.
prototype
.
analysis_milling_bit_size
=
function
(){
// todo
return
"_todo"
return
"_todo"
}
}
T_m_p
.
prototype
.
analysis_milling_length
=
function
(){
// todo
T_m_p
.
prototype
.
analysis_milling_length_card
=
function
(){
// todo
return
"_todo"
var
allStep
=
[
this
.
pcs_step
,
this
.
array_step
]
var
res
=
0
var
that
=
this
;
console
.
log
(
"============analysis_milling_length_card============="
);
console
.
log
(
"========step========:"
+
_
.
toString
(
allStep
));
var
steps
=
GEN
.
getStepList
({
job
:
this
.
job
})
allStep
.
forEach
(
function
(
step
){
if
(
steps
.
indexOf
(
step
)
>=
0
){
GEN
.
openStep
({
job
:
that
.
job
,
name
:
step
})
var
tmp
=
"length_tmp"
if
(
GEN
.
isLayerExists
({
job
:
that
.
job
,
layer
:
tmp
})){
GEN
.
deleteLayer
({
job
:
that
.
job
,
layer
:[
tmp
]})}
GEN
.
createLayer
({
job
:
that
.
job
,
layer
:
tmp
,
conext
:
'misc'
,
type
:
'document'
})
GEN
.
COM
(
"profile_to_rout,layer="
+
tmp
+
",width=1"
)
var
feautres
=
GEN
.
getFeatures
({
job
:
that
.
job
,
step
:
step
,
layer
:
tmp
,
units
:
"mm"
})
fs
.
writeFile
(
"/home/samba/tmp/tmp.js"
,
_
.
toString
(
feautres
))
// 根据feautres 算出周长
var
milling
=
Object
.
keys
(
feautres
).
reduce
(
function
(
a
,
b
){
var
value
=
feautres
[
b
]
if
(
value
.
type
==
"line"
){
length
=
Math
.
sqrt
((
Number
(
value
.
xe
)
-
Number
(
value
.
xs
))
*
(
Number
(
value
.
xe
)
-
Number
(
value
.
xs
))
+
(
Number
(
value
.
ye
)
-
Number
(
value
.
ys
))
*
(
Number
(
value
.
ye
)
-
Number
(
value
.
ys
)))
a
+=
length
}
else
if
(
value
.
type
==
"arc"
)
{
a
+=
arcLength
(
Number
(
value
.
xs
),
Number
(
value
.
ys
),
Number
(
value
.
xe
),
Number
(
value
.
ye
),
Number
(
value
.
xc
),
Number
(
value
.
yc
))
}
return
a
},
0
)
console
.
log
(
"========milling:"
+
milling
);
res
+=
milling
console
.
log
(
"========res:"
+
res
);
GEN
.
deleteLayer
({
job
:
that
.
job
,
layer
:[
tmp
]})
}
})
return
res
.
toFixed
(
3
)
}
T_m_p
.
prototype
.
analysis_milling_length_array
=
function
(){
// todo
if
(
!
this
.
array_step
){
return
"_error"
}
GEN
.
openStep
({
job
:
this
.
job
,
name
:
this
.
array_step
})
var
tmp
=
"length_tmp"
GEN
.
COM
(
"profile_to_rout,layer="
+
tmp
+
",width=1"
)
var
feautres
=
GEN
.
getFeatures
({
job
:
this
.
job
,
step
:
this
.
array_step
,
layer
:
tmp
,
units
:
"mm"
})
// 根据feautres 算出周长
var
milling
=
Object
.
keys
(
feautres
).
reduce
(
function
(
a
,
b
){
var
value
=
feautres
[
b
]
if
(
value
.
type
==
"line"
){
length
=
Math
.
sqrt
((
value
.
xe
-
value
.
xs
)
*
(
value
.
xe
-
value
.
xs
)
+
(
value
.
ye
-
value
.
ys
)
*
(
value
.
ye
-
value
.
ys
))
a
+=
length
}
else
if
(
value
.
type
==
"arc"
)
{
a
+=
arcLength
(
Number
(
value
.
xs
),
Number
(
value
.
ys
),
Number
(
value
.
xe
),
Number
(
value
.
ye
),
Number
(
value
.
xc
),
Number
(
value
.
yc
))
}
return
a
},
0
)
GEN
.
closeStep
()
return
milling
}
}
T_m_p
.
prototype
.
analysis_board_has_attr
=
function
(
props
){
// board层中检查存在01005属性物件时
T_m_p
.
prototype
.
analysis_board_has_attr
=
function
(
props
){
// board层中检查存在01005属性物件时
GEN
.
openStep
({
job
:
this
.
job
,
name
:
this
.
pcs_step
})
GEN
.
openStep
({
job
:
this
.
job
,
name
:
this
.
pcs_step
})
...
@@ -1544,7 +1598,7 @@ function analysis(props){
...
@@ -1544,7 +1598,7 @@ function analysis(props){
}
else
if
(
solder_paste_info
.
length
==
1
)
{
}
else
if
(
solder_paste_info
.
length
==
1
)
{
res
=
/top/ig
.
test
(
solder_paste_info
[
0
])
?
"FRONT1"
:
"BACK1"
res
=
/top/ig
.
test
(
solder_paste_info
[
0
])
?
"FRONT1"
:
"BACK1"
}
else
{
}
else
{
res
=
"FRONT1
_
BACK1"
res
=
"FRONT1
;
BACK1"
}
}
return
res
return
res
}
}
...
@@ -2322,3 +2376,12 @@ function saveMeans(props){
...
@@ -2322,3 +2376,12 @@ function saveMeans(props){
fs
.
writeFile
(
respath
+
"/meas"
,
meas
.
join
(
"
\n
"
))
fs
.
writeFile
(
respath
+
"/meas"
,
meas
.
join
(
"
\n
"
))
fs
.
chmod
(
respath
+
"/meas"
,
777
)
fs
.
chmod
(
respath
+
"/meas"
,
777
)
}
}
// 算弧长
function
arcLength
(
x1
,
y1
,
x2
,
y2
,
x3
,
y3
){
var
cos0
=
+
((
x3
-
x1
)
*
(
x2
-
x3
)
+
(
y3
-
y1
)
*
(
y2
-
y3
))
/
(
Math
.
pow
((
Math
.
pow
(
x2
-
x3
,
2
)
+
Math
.
pow
(
y2
-
y3
,
2
)),
0.5
)
*
Math
.
pow
((
Math
.
pow
(
x3
-
x1
,
2
)
+
Math
.
pow
(
y3
-
y1
,
2
)),
0.5
))
var
tmp
=
Math
.
acos
(
cos0
)
var
sin0
=
Math
.
sin
(
tmp
)
var
length
=
+
Math
.
sqrt
(
Math
.
pow
(
x2
-
x1
,
2
)
+
Math
.
pow
(
y2
-
y1
,
2
))
/
sin0
*
tmp
return
length
}
\ No newline at end of file
ats/scott_test/format_test.js
View file @
431f8581
...
@@ -255,7 +255,6 @@ try {
...
@@ -255,7 +255,6 @@ try {
var
now_profile
=
GEN
.
getProfile
({
job
:
job
,
step
:
tmp_step
})
var
now_profile
=
GEN
.
getProfile
({
job
:
job
,
step
:
tmp_step
})
if
(
now_profile
.
match
(
/
\n
/ig
).
length
==
1
){
// 如果没有profile
if
(
now_profile
.
match
(
/
\n
/ig
).
length
==
1
){
// 如果没有profile
createOutline
({
job
:
job
,
step
:
tmp_step
,
matrix
:
tmp_matrix
,
profileRule
:
profileRule
})
createOutline
({
job
:
job
,
step
:
tmp_step
,
matrix
:
tmp_matrix
,
profileRule
:
profileRule
})
throw
"tmp"
var
hasProfile
=
GEN
.
getProfile
({
job
:
job
,
step
:
tmp_step
})
var
hasProfile
=
GEN
.
getProfile
({
job
:
job
,
step
:
tmp_step
})
if
(
hasProfile
.
match
(
/
\n
/ig
).
length
==
1
){
if
(
hasProfile
.
match
(
/
\n
/ig
).
length
==
1
){
throw
"创建profile失败"
throw
"创建profile失败"
...
@@ -636,6 +635,7 @@ function createOutline(props){
...
@@ -636,6 +635,7 @@ function createOutline(props){
if(GEN.getSelectCount()>0){GEN.selDelete()}
if(GEN.getSelectCount()>0){GEN.selDelete()}
GEN.selClearFeature()
GEN.selClearFeature()
GEN.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
")
GEN.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
")
GEN.selContourize()
GEN.selectByFilter({feat_types:"
surface
"})
GEN.selectByFilter({feat_types:"
surface
"})
GEN.selReverse()
GEN.selReverse()
if(GEN.getSelectCount()>0){GEN.selDelete()}
if(GEN.getSelectCount()>0){GEN.selDelete()}
...
@@ -648,6 +648,7 @@ function createOutline(props){
...
@@ -648,6 +648,7 @@ function createOutline(props){
GEN.selAllFeat()
GEN.selAllFeat()
GEN.selDelete()
GEN.selDelete()
GEN.workLayer({name:tmp_outline2,display_number:2,clear_before:"
yes
"})
GEN.workLayer({name:tmp_outline2,display_number:2,clear_before:"
yes
"})
GEN.COM("
sel_clean_holes
,
max_size
=
200
,
clean_mode
=
x_and_y
")
GEN.COM("
sel_surf2outline
,
width
=
1
")
GEN.COM("
sel_surf2outline
,
width
=
1
")
GEN.selAllFeat()
GEN.selAllFeat()
selCopyLayer({job:job,layer:l})
selCopyLayer({job:job,layer:l})
...
...
config_ats.js
View file @
431f8581
...
@@ -1008,6 +1008,7 @@
...
@@ -1008,6 +1008,7 @@
],
],
"mergerule"
:
{
"mergerule"
:
{
drill
:[
"(
\\
d+)-(
\\
d+)
\\
.drl$"
],
drill
:[
"(
\\
d+)-(
\\
d+)
\\
.drl$"
],
profile
:[
"sm_top"
],
laser
:
{
laser
:
{
tl_name
:
"drill($1)-($2)"
,
tl_name
:
"drill($1)-($2)"
,
regs
:
[
"(
\\
d+)-(
\\
d+)
\\
.drl$"
]
regs
:
[
"(
\\
d+)-(
\\
d+)
\\
.drl$"
]
...
...
test/ATS_AIM_input_data.js
View file @
431f8581
/*
/*
NAME:
NAME:
DESCRIPTION: ;
DESCRIPTION: ;
PARAMETER:
PARAMETER:
[
[
{
{
name : 'path',
name : 'auto_save',
title : '资料路径',
title : '自动保存',
type : 'LineEdit',
type : 'RadioBox',
property : {tool_tip : '存放所有料号的文件夹路径,不需要进入到料号文件夹内'},
property : {
},
item_list:[
{
{name:'yes',text:'YES'},
name : 'customer',
{name:'no',text:'NO'},
title : '客户配置',
],
type : 'LineEdit',
tool_tip:'是否自动保存料号开关'
property : {tool_tip : '客户配置'},
}
},
{
name : 'config_path',
title : '配置地址',
type : 'LineEdit',
property : {tool_tip : '配置的路径'},
}
}
]
]
VERSION_HISTORY:
VERSION_HISTORY:
V1.00 2020-0
4-16
Scott Sun
V1.00 2020-0
6-10
Scott Sun
1.新版本
1.新版本
HELP:
HELP:
<html><body bgcolor="#DDECFE">
<html><body bgcolor="#DDECFE">
<font size="3" color="#003DB2"><p>功能简介</p></font>
<font size="3" color="#003DB2"><p>功能简介</p></font>
<p>
客户数据导入
</p>
<p>
立碑效应
</p>
<br>
<br>
<font size="3" color="#003DB2"><p>参数配置</p></font>
<font size="3" color="#003DB2"><p>参数配置</p></font>
<p>
料号 和 客户
配置 </p>
<p> 配置 </p>
<br>
<br>
<font size="3" color="#003DB2"><p>注意事项</p></font>
<font size="3" color="#003DB2"><p>注意事项</p></font>
<p> 无 </p>
<p> 无 </p>
...
@@ -44,18 +36,36 @@ PARAMETER:
...
@@ -44,18 +36,36 @@ PARAMETER:
*/
*/
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////
console
.
log
(
"==============================>li bei xiao yin start"
);
// 引入模块 包
// 引入模块 包
console
.
log
(
"=============================================>input_start"
);
console
.
log
(
"=============================================>input_start"
);
console
.
log
(
"=============================================>input_start"
);
console
.
log
(
"=============================================>input_start"
);
var
$
=
require
(
'topcam.scriptfunc'
).
argv
();
var
$
=
require
(
'topcam.scriptfunc'
).
argv
();
var
fs
=
require
(
'fs'
);
var
fs
=
require
(
'fs'
);
var
genmath
=
require
(
'topcam.genmath'
)
var
_
=
require
(
'lodash'
);
var
_
=
require
(
'lodash'
);
var
database
=
require
(
"topsin.database"
);
var
mode
=
$
.
ikm
?
"topcam"
:
"aimdfm"
;
database
.
addConnection
(
$
.
conf
.
database_conf
,
"DFM"
);
var
IKM
=
$
.
ikm
;
var
QDfm
=
database
.
query
(
"DFM"
);
if
(
IKM
==
undefined
)
{
IKM
=
require
(
'topcam.ikm6'
)(
$
)
}
if
(
$
.
conf
.
product_type
==
"aimdfm"
)
{
var
GEN
=
$
.
gen
;
var
GUI
=
$
.
gui
||
{};
var
Job
=
$
.
job
||
$
.
job_name
;
Job
=
Job
.
toLowerCase
()
var
job
=
Job
var
JobId
=
$
.
job_id
;
var
db
=
$
.
db
||
{}
var
PAR
=
{}
if
(
$
.
par
)
{
PAR
=
$
.
par
}
else
if
(
$
.
hasOwnProperty
(
'script_parameter'
)){
PAR
=
JSON
.
parse
(
$
.
script_parameter
);
}
var
par
=
PAR
;
if
(
mode
===
"aimdfm"
)
{
var
database
=
require
(
"topsin.database"
);
database
.
addConnection
(
$
.
conf
.
database_conf
,
"DFM"
);
var
QDfm
=
database
.
query
(
"DFM"
);
$
.
QDfm
=
QDfm
;
if
(
$
.
conf
.
product_type
==
"aimdfm"
)
{
QDfm
.
updateRow
({
QDfm
.
updateRow
({
table
:
"pdm_aimdfm_task"
,
table
:
"pdm_aimdfm_task"
,
data
:
{
data
:
{
...
@@ -63,133 +73,48 @@ if ($.conf.product_type == "aimdfm") {
...
@@ -63,133 +73,48 @@ if ($.conf.product_type == "aimdfm") {
},
},
where
:
{
id
:
$
.
task_id
}
where
:
{
id
:
$
.
task_id
}
});
});
}
}
}
var
GEN
=
$
.
gen
;
var
Job
=
$
.
job_name
;
var
db
=
$
.
db
;
var
Status
=
'ok'
;
var
Status
=
'ok'
;
var
resultData
=
[];
var
resultData
=
[];
var
PAR
=
{};
var
debug
=
true
;
if
(
$
.
hasOwnProperty
(
'script_parameter'
)){
var
Step
=
par
.
step_fliter
PAR
=
JSON
.
parse
(
$
.
script_parameter
);
}
if
(
!
$
.
hasOwnProperty
(
'config_path'
)){
PAR
.
config_path
=
"cam/input_data"
}
try
{
var
par
=
PAR
;
console
.
log
(
par
);
if
(
!
par
.
hasOwnProperty
(
"customer"
)){
throw
"未填写配置"
};
par
.
customer
=
par
.
customer
[
0
].
toUpperCase
()
+
par
.
customer
.
slice
(
1
).
toLowerCase
()
var
cfg
=
db
.
query
(
""
,
function
(
q
){
return
q
.
selectValue
({
table
:
'pub_conf'
,
field
:
'text_data'
,
where
:{
path
:
par
.
config_path
}
})
});
if
(
!
cfg
||
cfg
==
""
){
throw
"cfg can not find"
}
var
config
=
eval
(
cfg
);
if
(
!
config
.
hasOwnProperty
(
"customer"
)){
throw
"config error"
}
var
job
=
Job
;
if
(
_
.
isEmpty
(
job
))
throw
"没有传入料号名!"
;
job
=
job
.
toLowerCase
()
// 如果genesis已经存在这个料号
err
=
delSameJob
({
job
:
job
,
delSame
:
config
.
delSameJob
});
if
(
err
){
throw
err
};
var
custCfg
=
config
.
customer
[
par
.
customer
]
if
(
!
custCfg
){
throw
"config error"
}
var
step
=
custCfg
.
step
.
toLowerCase
()
// 获取路径下文件信息
var
path
=
par
.
path
||
custCfg
.
path
var
pathInfo
=
fs
.
listDir
(
path
,
1
)
// 判断存不存在料号文件
var
jobFile
=
pathInfo
.
filter
(
function
(
v
){
return
v
.
baseName
.
toLowerCase
()
==
job
})
if
(
jobFile
.
length
==
0
){
throw
"job file is not exist"
}
var
jobFiles
=
[]
// 记录要分析的文件
if
(
!
jobFile
[
0
].
isDir
)
{
jobFiles
.
push
(
jobFile
[
0
])
}
else
{
jobFiles
=
fs
.
listDir
(
jobFile
[
0
].
path
)
}
// 分析料号文件 得到料号导入信息 导入类型
var
jobInfo
=
analyJobFiles
({
jobFiles
:
jobFiles
.
filter
(
function
(
v
){
return
v
.
isFile
}),
custCfg
:
custCfg
,
config
:
config
,
job
:
job
})
if
(
jobInfo
.
data
.
length
==
0
){
throw
"file error"
}
var
importOk
=
false
;
// 是否成功导入
if
(
/odb/ig
.
test
(
jobInfo
.
type
)){
// odb导入
if
(
jobInfo
.
data
.
length
==
1
){
// 只分析到一个tgz文件 直接导入
var
err
=
importJob
({
name
:
job
,
db
:
custCfg
.
db
,
path
:
jobInfo
.
data
[
0
].
file
.
path
},
config
.
delSameJob
)
if
(
err
){
throw
err
}
}
else
{
// 多个tgz文件 说明需要合并
var
mergeFiles
=
jobInfo
.
data
.
filter
(
function
(
item
){
var
err
=
importJob
({
name
:
item
.
file
.
baseName
,
db
:
custCfg
.
db
,
path
:
item
.
file
.
path
},
config
.
delSameJob
)
if
(
err
){
throw
err
}
return
/yes/ig
.
test
(
item
.
format
.
isMerge
)
})
var
arr_job
=
mergeFiles
[
0
]
var
arr_step
;
var
steplist
=
GEN
.
getStepList
({
job
:
arr_job
.
file
.
baseName
})
if
(
steplist
.
indexOf
(
arr_job
.
format
.
arrStep
)
<
0
){
arr_step
=
steplist
[
0
]
}
else
{
arr_step
=
arr_job
.
format
.
arrStep
}
GEN
.
openJob
({
job
:
job
});
GEN
.
openJob
({
job
:
arr_job
.
file
.
baseName
});
GEN
.
copyStep
({
// 合并
source_job
:
arr_job
.
file
.
baseName
,
source_name
:
arr_step
,
dest_job
:
job
,
dest_name
:
arr_step
,
});
GEN
.
closeJob
({
job
:
arr_job
.
file
.
baseName
});
GEN
.
deleteJob
({
job
:
arr_job
.
file
.
baseName
});
// 合并后 删除array的料号
}
importOk
=
true
}
if
(
/gerber/ig
.
test
(
jobInfo
.
type
)){
// gerber导入
GEN
.
createJob
({
name
:
job
,
db
:
custCfg
.
db
})
GEN
.
createStep
({
job
:
job
,
name
:
step
})
var
gerberInfo
=
jobInfo
.
data
.
map
(
function
(
item
){
var
gerberCfg
=
JSON
.
parse
(
JSON
.
stringify
(
item
.
format
));
var
file
=
item
.
file
gerberCfg
.
layer
=
file
.
name
.
toLowerCase
()
gerberCfg
.
path
=
file
.
path
gerberCfg
.
format
=
item
.
type
gerberCfg
.
job
=
job
gerberCfg
.
step
=
step
return
gerberCfg
})
GEN
.
COM
(
"input_manual_reset"
)
gerberInfo
.
forEach
(
function
(
v
){
GEN
.
COM
(
"input_manual_set"
,
v
)
})
GEN
.
COM
(
"input_manual"
)
importOk
=
true
}
if
(
!
importOk
){
throw
"import error"
}
var
default_par
=
{
// par默认参数?
auto_save
:
"no"
}
// 导入结束
for
(
var
key
in
default_par
){
// 设置默认属性
var
matrix
=
GEN
.
getMatrix
({
job
:
job
});
if
(
!
par
.
hasOwnProperty
(
key
)
||
par
[
key
]
==
""
){
comp
=
Object
.
keys
(
matrix
).
filter
(
function
(
v
){
// 如果有comp层 删除
par
[
key
]
=
default_par
[
key
]
return
/^comp_
\+
_/ig
.
test
(
v
)
})
if
(
comp
.
length
>
0
){
var
tmp
=
GEN
.
getStepList
({
job
:
job
})
GEN
.
openStep
({
job
:
job
,
name
:
tmp
[
0
]})
GEN
.
COM
(
"delete_comp"
)
GEN
.
closeStep
()
}
}
}
GEN
.
checkInout
({
job
:
job
,
mode
:
"out"
})
// 结束保存料号 关闭料号
try
{
GEN
.
saveJob
({
job
:
job
});
GEN
.
checkInout
({
job
:
job
,
mode
:
"in"
})
GEN
.
closeJob
({
job
:
job
})
QDfm
.
updateRow
({
var
layer
=
"000"
var
step
=
"cad"
var
layer
=
"000"
// GEN.workLayer({name:layer,display_number:2,clear_before:'yes'})
// var feautres = GEN.getFeatures({job:job,step:step,layer:layer,units:"mm"})
var
data
=
{
"type"
:
"arc"
,
"xs"
:
"-5.1252"
,
"ys"
:
"7.685785"
,
"xe"
:
"-6.5392"
,
"ye"
:
"7.1001"
,
"xc"
:
"-5.1250975"
,
"yc"
:
"5.685835"
,
"symbol"
:
"r25.4"
,
"polarity"
:
"positive"
,
"direction"
:
"ccw"
,
"attributes"
:[]}
// -5.1252 7.685785 -6.5392 7.1001 -5.1250975 5.685835
IKM
.
msg
(
genmath
.
arcLength
(
data
))
// // 根据feautres 算出周长
// var milling = Object.keys(feautres).reduce(function(a,b){
// var value = feautres[b]
// if (value.type=="line"){
// length = Math.sqrt((value.xe-value.xs)*(value.xe-value.xs) + (value.ye-value.ys)*(value.ye-value.ys))
// a += length
// } else if (value.type=="arc") {
// a += arcLength(Number(value.xs),Number(value.ys),Number(value.xe),Number(value.ye),Number(value.xc),Number(value.yc))
// }
// return a
// }, 0)
// IKM.msg(milling)
if
(
mode
===
"aimdfm"
)
{
$
.
QDfm
.
updateRow
({
table
:
"pdm_aimdfm_task"
,
table
:
"pdm_aimdfm_task"
,
data
:
{
data
:
{
progress
:
33.33
progress
:
33.33
...
@@ -210,94 +135,20 @@ try {
...
@@ -210,94 +135,20 @@ try {
result_data
:
resultData
result_data
:
resultData
};
};
}
}
}
else
{
}
return
"Done"
catch
(
e
)
{
}
}
catch
(
e
)
{
IKM
.
msg
(
e
)
Status
=
'error'
;
Status
=
'error'
;
console
.
log
(
"====================================>error"
);
console
.
log
(
_
.
toString
(
e
));
resultData
.
push
({
type
:
"error"
,
title
:
"脚本执行出错!"
,
detail
:
[{
desc
:
_
.
toString
(
e
)}]});
resultData
.
push
({
type
:
"error"
,
title
:
"脚本执行出错!"
,
detail
:
[{
desc
:
_
.
toString
(
e
)}]});
return
{
status
:
Status
,
result_data
:
resultData
}
;
return
(
mode
===
"aimdfm"
)
?
{
status
:
Status
,
result_data
:
resultData
}
:
"Error"
;
}
}
function
delSameJob
(
props
){
function
arcLength
(
x1
,
y1
,
x2
,
y2
,
x3
,
y3
){
var
job
=
props
.
job
var
cos0
=
+
((
x3
-
x1
)
*
(
x2
-
x3
)
+
(
y3
-
y1
)
*
(
y2
-
y3
))
/
Math
.
pow
((
Math
.
pow
(
x2
-
x3
,
2
)
+
Math
.
pow
(
y2
-
y3
,
2
)),
0.5
)
*
Math
.
pow
((
Math
.
pow
(
x3
-
x1
,
2
)
+
Math
.
pow
(
y3
-
y1
,
2
)),
0.5
)
var
delSame
=
props
.
delSame
var
tmp
=
Math
.
acos
(
cos0
)
if
(
GEN
.
isJobExists
({
job
:
job
})){
var
sin0
=
Math
.
sin
(
tmp
)
if
(
/^yes$/ig
.
test
(
delSame
)){
var
length
=
+
Math
.
sqrt
(
Math
.
pow
(
x2
-
x1
,
2
)
+
Math
.
pow
(
y2
-
y1
,
2
))
/
sin0
*
tmp
if
(
GEN
.
isJobOpen
({
job
:
job
})){
GEN
.
closeJob
({
job
:
job
})
}
return
length
GEN
.
deleteJob
({
job
:
job
})
}
else
{
return
"job "
+
job
+
" exist"
}
}
}
function
analyJobFiles
(
props
){
var
files
=
props
.
jobFiles
;
var
config
=
props
.
config
;
var
job
=
props
.
job
;
var
custCfg
=
props
.
custCfg
;
var
rules
=
custCfg
.
rules
;
var
paramsFile
=
files
.
filter
(
function
(
file
){
return
/param/ig
.
test
(
file
.
baseName
)})
var
tmp_hash
=
{}
paramsFile
.
forEach
(
function
(
file
){
tmp_hash
[
file
.
baseName
]
=
(
function
(){
var
tmparr
=
fs
.
readFile
(
file
.
path
).
split
(
"
\n
"
)
var
tmp
=
{}
tmparr
.
map
(
function
(
v
){
var
arr
=
v
.
split
(
/
\b\s
+
\b
/
)
tmp
[
arr
[
0
].
replace
(
/-/ig
,
"_"
)]
=
arr
[
1
]
})
return
tmp
})()
})
var
fileInfo
=
files
.
reduce
(
function
(
a
,
file
){
try
{
rules
.
forEach
(
function
(
item
){
if
(
item
.
valid
({
file
:
file
,
job
:
job
})){
var
format
=
config
.
formats
[
item
.
format
]
var
format1
;
if
(
item
.
format_params
){
format1
=
item
.
format_params
({
params
:
tmp_hash
})
}
if
(
format1
){
throw
{
file
:
file
,
type
:
item
.
type
,
format
:
format1
}
}
else
{
throw
{
file
:
file
,
type
:
item
.
type
,
format
:
format
}
}
}
})
}
catch
(
info
)
{
a
.
push
(
info
)
}
return
a
},[])
var
odbfiles
=
fileInfo
.
filter
(
function
(
item
){
return
/odb/ig
.
test
(
item
.
type
)})
if
(
odbfiles
.
length
==
0
){
return
{
type
:
"Gerber"
,
data
:
fileInfo
}
}
else
{
return
{
type
:
"ODB"
,
data
:
odbfiles
}
}
}
}
function
importJob
(
props
,
delSameJob
){
var
name
=
props
.
name
if
(
GEN
.
isJobExists
({
job
:
name
}))
{
if
(
/^yes$/ig
.
test
(
delSameJob
))
{
if
(
GEN
.
isJobOpen
({
job
:
name
})){
GEN
.
closeJob
({
job
:
name
});
}
GEN
.
deleteJob
({
job
:
name
});
}
else
{
return
"job "
+
name
+
" exist"
;
}
}
GEN
.
importJob
(
props
);
}
test/mytest.js
View file @
431f8581
...
@@ -11,14 +11,6 @@ var JobId = $.job_id;
...
@@ -11,14 +11,6 @@ var JobId = $.job_id;
try
{
try
{
return
"Done"
return
"Done"
}
catch
(
e
)
{
}
catch
(
e
)
{
return
"Error"
return
"Error"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment