Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
O
optical-design-viewer
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
optical-design-viewer
Commits
6c3e2860
Commit
6c3e2860
authored
Jun 28, 2014
by
Oleg Dzhimiev
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+len converter (not perfect)
parent
daa0a3eb
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
269 additions
and
2 deletions
+269
-2
convert_len.php
convert_len.php
+107
-0
files.php
files.php
+4
-2
get_remote_designs_list.php
get_remote_designs_list.php
+6
-0
test.len
local/test.len
+152
-0
No files found.
convert_len.php
0 → 100644
View file @
6c3e2860
<?php
/*
FILE NAME : convert_len.php
DESCRIPTION: optical design
REVISION: 1.00
AUTHOR: Oleg Dzhimiev <oleg@elphel.com>
LICENSE: AGPL, see http://www.gnu.org/licenses/agpl.txt
Copyright (C) 2014 Elphel, Inc.
*/
function
convert_len
(
$path
){
$contents
=
file_get_contents
(
$path
);
$lines
=
explode
(
"
\n
"
,
$contents
);
$surface_enable
=
false
;
$index
=
0
;
$surfaces
=
Array
();
for
(
$i
=
0
;
$i
<
count
(
$lines
);
$i
++
){
//$str = mb_convert_encoding ($lines[$i], 'UTF-8', 'UTF-16');
$str
=
$lines
[
$i
];
if
(
$surface_enable
){
$s
=
explode
(
' '
,
$str
);
foreach
(
$s
as
$a
=>
$b
){
$tmp
=
trim
(
$b
);
if
(
$tmp
==
"RD"
)
{
$surfaces
[
$index
][
"RD"
]
=
$s
[
$a
+
3
];
break
;}
if
(
$tmp
==
"TH"
)
{
$surfaces
[
$index
][
"TH"
]
=
$s
[
$a
+
3
];
break
;}
if
(
$tmp
==
"GLA"
)
{
$surfaces
[
$index
][
"GLA"
]
=
$s
[
$a
+
1
];
break
;}
if
(
$tmp
==
"AP"
)
{
$surfaces
[
$index
][
"AP"
]
=
$s
[
$a
+
2
];
break
;}
if
(
$tmp
==
"AST"
)
{
$surfaces
[
$index
][
"AST"
]
=
true
;
break
;}
}
}
//considering POPS line as the end
if
(
strpos
(
$str
,
"NXT"
)
!==
false
)
{
$surface_enable
=
false
;
$index
++
;
}
if
(
strpos
(
$str
,
"NXT"
)
!==
false
)
{
$surface_enable
=
true
;
}
if
(
strpos
(
$str
,
"FNO"
)
!==
false
){
$s
=
explode
(
' '
,
$str
);
$fn
=
$s
[
2
];
}
if
(
strpos
(
$str
,
"LEN"
)
!==
false
){
$s
=
explode
(
' '
,
$str
);
$f
=
$s
[
3
];
}
}
//surfaces array is ready
$found_1st_glass
=
false
;
$xml
=
""
;
$distance
=
0
;
for
(
$i
=
0
;
$i
<
count
(
$surfaces
);
$i
++
){
$elem
=
$surfaces
[
$i
];
if
(
isset
(
$elem
[
"GLA"
])
||
isset
(
$elem
[
"AST"
]))
{
$xml
.=
"
\t
<element>
\n
"
;
$xml
.=
"
\t\t
<distance>"
.
$distance
.
"</distance>
\n
"
;
$xml
.=
"
\t\t
<thickness>"
.
$elem
[
"TH"
]
.
"</thickness>
\n
"
;
$xml
.=
"
\t\t
<material>"
.
$elem
[
"GLA"
]
.
"</material>
\n
"
;
if
(
isset
(
$elem
[
"AST"
]))
$xml
.=
"
\t\t
<name>aperture stop</name>
\n
"
;
else
$xml
.=
"
\t\t
<name></name>
\n
"
;
$xml
.=
"
\t\t
<front>
\n
"
;
if
(
isset
(
$elem
[
"AST"
]))
$xml
.=
"
\t\t\t
<height>"
.
(
-
$f
/
$fn
)
.
"</height>
\n
"
;
else
$xml
.=
"
\t\t\t
<height>"
.
(
+
2
*
$elem
[
"AP"
])
.
"</height>
\n
"
;
if
(
$elem
[
"RD"
]
==
0
)
$elem
[
"RD"
]
=
100000
;
if
(
!
isset
(
$elem
[
"AST"
]))
$xml
.=
"
\t\t\t
<rcurve>"
.
(
$elem
[
"RD"
])
.
"</rcurve>
\n
"
;
else
$xml
.=
"
\t\t\t
<rcurve>0</rcurve>
\n
"
;
$xml
.=
"
\t\t\t
<k>0</k>
\n
"
;
$xml
.=
"
\t\t\t
<a1>0</a1>
\n
"
;
$xml
.=
"
\t\t\t
<a2>0</a2>
\n
"
;
$xml
.=
"
\t\t\t
<a3>0</a3>
\n
"
;
$xml
.=
"
\t\t\t
<a4>0</a4>
\n
"
;
$xml
.=
"
\t\t
</front>
\n
"
;
$xml
.=
"
\t\t
<back>
\n
"
;
if
(
isset
(
$elem
[
"AST"
]))
$xml
.=
"
\t\t\t
<height>0</height>
\n
"
;
else
$xml
.=
"
\t\t\t
<height>"
.
(
2
*
$surfaces
[
$i
+
1
][
"AP"
])
.
"</height>
\n
"
;
if
(
$surfaces
[
$i
+
1
][
"RD"
]
==
0
)
$surfaces
[
$i
+
1
][
"RD"
]
=
100000
;
if
(
!
isset
(
$elem
[
"AST"
]))
$xml
.=
"
\t\t\t
<rcurve>"
.
(
$surfaces
[
$i
+
1
][
"RD"
])
.
"</rcurve>
\n
"
;
else
$xml
.=
"
\t\t\t
<rcurve>0</rcurve>
\n
"
;
$xml
.=
"
\t\t\t
<k>0</k>
\n
"
;
$xml
.=
"
\t\t\t
<a1>0</a1>
\n
"
;
$xml
.=
"
\t\t\t
<a2>0</a2>
\n
"
;
$xml
.=
"
\t\t\t
<a3>0</a3>
\n
"
;
$xml
.=
"
\t\t\t
<a4>0</a4>
\n
"
;
$xml
.=
"
\t\t
</back>
\n
"
;
$xml
.=
"
\t
</element>
\n
"
;
$found_1st_glass
=
true
;
}
if
(
$found_1st_glass
)
$distance
+=
$elem
[
"TH"
];
}
$final_xml
=
"<?xml version='1.0' encoding='UTF-8'?>
\n
<Document>
\n
"
.
$xml
.
"</Document>"
;
return
$final_xml
;
}
?>
\ No newline at end of file
files.php
View file @
6c3e2860
...
...
@@ -18,12 +18,14 @@ if (isset($_GET['path'])) $default_path = $_GET['path'];
else
die
(
"-3"
);
require
(
"convert_zmx.php"
);
require
(
"convert_len.php"
);
if
(
$cmd
==
"save"
)
{
file_put_contents
(
"
$default_path
/
$file
"
,
file_get_contents
(
"php://input"
));
}
elseif
(
$cmd
==
"read"
)
{
$ext
=
pathinfo
(
$file
,
PATHINFO_EXTENSION
);
if
(
$ext
==
"zmx"
)
$content
=
convert_zmx
(
"
$default_path
/
$file
"
);
else
if
(
$ext
==
"len"
)
$content
=
convert_len
(
"
$default_path
/
$file
"
);
else
$content
=
file_get_contents
(
"
$default_path
/
$file
"
);
header
(
"Content-Type: text/xml
\n
"
);
header
(
"Content-Length: "
.
strlen
(
$content
)
.
"
\n
"
);
...
...
get_remote_designs_list.php
View file @
6c3e2860
...
...
@@ -14,6 +14,7 @@ $path = "https://github.com/Elphel/elens";
$contents
=
file_get_contents
(
$path
);
$regexp_xml
=
'#<a[^>]*href="([^"]*)"[^>]*title=".*.xml"#'
;
$regexp_zmx
=
'#<a[^>]*href="([^"]*)"[^>]*title=".*.zmx"#'
;
$regexp_zmx
=
'#<a[^>]*href="([^"]*)"[^>]*title=".*.len"#'
;
$files
=
Array
();
if
(
preg_match_all
(
$regexp_xml
,
$contents
,
$matches
,
PREG_SET_ORDER
))
{
...
...
@@ -21,6 +22,11 @@ if(preg_match_all($regexp_xml, $contents, $matches, PREG_SET_ORDER)) {
$files
[]
=
basename
(
$match
[
1
]);
}
}
if
(
preg_match_all
(
$regexp_len
,
$contents
,
$matches
,
PREG_SET_ORDER
))
{
foreach
(
$matches
as
$match
)
{
$files
[]
=
basename
(
$match
[
1
]);
}
}
if
(
preg_match_all
(
$regexp_zmx
,
$contents
,
$matches
,
PREG_SET_ORDER
))
{
foreach
(
$matches
as
$match
)
{
$files
[]
=
basename
(
$match
[
1
]);
...
...
local/test.len
0 → 100644
View file @
6c3e2860
// OSLO 6.6 55487 0 50466
LEN NEW "" 4.5003 22
FNO 1.8
ANG 38.0
DES "OSLO"
UNI 1.0
// SRF 0
AIR
TH 1.0e+20
AP 7.8128562651e+19
NXT // SRF 1
AIR
TH 10.0
NXT // SRF 2
GLA LASF14A
RD 44.1995256671779
TH 2.0
AP CHK 9.5
NXT // SRF 3
AIR
RD 246.68766848992
TH 0.5000001103036
AP CHK 9.5
NXT // SRF 4
GLA SK16
RD 28.7407314472329
TH 0.9798916508493
AP CHK 6.6
NXT // SRF 5
AIR
RD 4.6429368607625
TH 2.043637125802
AP CHK 4.2
NXT // SRF 6
GLA BAF51
RD 10.1726461943981
TH 2.500074734125
AP CHK 4.6
NXT // SRF 7
AIR
RD 4.6194936713085
TH 2.0
AP CHK 3.2
NXT // SRF 8
GLA SF57
RD 14.5286371088468
TH 2.53446840913
AP CHK 4.5
NXT // SRF 9
AIR
RD -20.3628934582945
TH 0.4325974576629
AP CHK 4.5
NXT // SRF 10
AIR
TH 1.303905326818
AST
DRW ON
NXT // SRF 11
GLA SF58
RD -30.5356011642403
TH 1.5
AP CHK 3.7
NXT // SRF 12
GLA N-SK15
RD 8.9309914413009
TH 1.955799332857
AP CHK 3.7
NXT // SRF 13
AIR
RD -7.4851654524717
TH 0.5101658615876
AP CHK 3.7
NXT // SRF 14
GLA N-FK51A
RD 24.789133523564
TH 1.5
AP CHK 4.5
NXT // SRF 15
AIR
RD -12.6157169320602
TH 0.7118119056204
AP CHK 4.5
NXT // SRF 16
GLA N-FK51
RD 11.3993328018745
TH 2.052132855473
AP CHK 4.5
NXT // SRF 17
AIR
RD -31.829134195541
TH 5.7
AP CHK 4.5
NXT // SRF 18
GLA N-BK7
RD -8.0
TH 0.5
AP CHK 4.0
NXT // SRF 19
AIR
AP CHK 4.5
NXT // SRF 20
GLA N-BK7
TH 0.4
AP CHK 4.0
NXT // SRF 21
AIR
AP CHK 4.0
NXT // SRF 22
AIR
DRW ON
CBK 1
WV 0.58756 0.48613 0.65627
WW 1.0 0.35 0.7
END 22
DLRS 3
VAR NEW
V 1 2 0 CV 0.0 0.0 1.0 0.0000799939095
V 2 3 0 CV 0.0 0.0 1.0 0.0000799939095
V 3 4 0 CV 0.0 0.0 1.0 0.0000799939095
V 4 5 0 CV 0.0 0.0 1.0 0.0000799939095
V 5 6 0 CV 0.0 0.0 1.0 0.0000799939095
V 6 7 0 CV 0.0 0.0 1.0 0.0000799939095
V 7 8 0 CV 0.0 0.0 1.0 0.0000799939095
V 8 9 0 CV 0.0 0.0 1.0 0.0000799939095
V 9 11 0 CV 0.0 0.0 1.0 0.0000799939095
V 10 12 0 CV 0.0 0.0 1.0 0.0000799939095
V 11 13 0 CV 0.0 0.0 1.0 0.0000799939095
V 12 14 0 CV 0.0 0.0 1.0 0.0000799939095
V 13 15 0 CV 0.0 0.0 1.0 0.0000799939095
V 14 16 0 CV 0.0 0.0 1.0 0.0000799939095
V 15 17 0 CV 0.0 0.0 1.0 0.0000799939095
V 16 18 0 CV 0.0 0.0 1.0 0.0000799939095
V 17 1 0 TH 0.1 10000.0 1.0 0.0001250095171
V 18 2 0 TH 0.5 100.0 1.0 0.0001250095171
V 19 3 0 TH 0.1 10000.0 1.0 0.0001250095171
V 20 4 0 TH 0.5 100.0 1.0 0.0001250095171
V 21 5 0 TH 0.1 10000.0 1.0 0.0001250095171
V 22 6 0 TH 0.5 100.0 1.0 0.0001250095171
V 23 7 0 TH 0.1 10000.0 1.0 0.0001250095171
V 24 8 0 TH 0.5 100.0 1.0 0.0001250095171
V 25 9 0 TH 0.1 10000.0 1.0 0.0001250095171
V 26 10 0 TH 0.1 10000.0 1.0 0.0001250095171
V 27 11 0 TH 0.5 100.0 1.0 0.0001250095171
V 28 12 0 TH 0.5 100.0 1.0 0.0001250095171
V 29 13 0 TH 0.1 10000.0 1.0 0.0001250095171
V 30 14 0 TH 0.5 100.0 1.0 0.0001250095171
V 31 15 0 TH 0.1 10000.0 1.0 0.0001250095171
V 32 16 0 TH 0.5 100.0 1.0 0.0001250095171
V 33 17 0 TH 0.1 10000.0 1.0 0.0001250095171
V 34 18 0 TH 0.5 100.0 1.0 0.0001250095171
END
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