17/03/2016 – Tolerance Checker Development Log– 极限偏差查询器开发日志

前期规划日志 Previous Development Plan :

>10/02/2016<

>08/03/2016<


后续开发日志 Development Update:

>10/04/2016<


>前往查询器 Use the checker<

以下为主要开发内容 The following is the main content:

近几日完成了查询器的主要开发工作并上线测试。

Main development work has been finished on these days, and the tolerance checker has been launched into beta test.

首先是确认了需要使用的php excel reader工具,资源来自SourceForge上的一个项目:<PHP-ExcelReader> ;调用方法参考了搜索到的这篇日志:<PHP ExcelReader用法>

First, excel reader tool has been selected. It is a SourceForge project:<PHP-ExcelReader>, and I find a Chinese user manual by this link:<PHP ExcelReader用法>

其调用方法是:

How to invoke the PHP-ExcelReader:

[php]
require_once ‘Excel/reader.php’;
$data = new Spreadsheet_Excel_Reader(); /*invoking reader*/
$data->setOutputEncoding(‘UTF-8’); /*text output encoding*/
$data->read(‘db.xls’); /*read the excel sheet*/

echo $data->sheets[0][‘cells’][i][j]; /*read the (i,j)cell
and output data*/
[/php]

这个基本结构是针对查固定路径的单个excel表格的,我先编写了一个3行3列excel表格进行测试,表单通过post形式将需要的单元格位置(i,j)将表单信息告知excel_reader,reader返回查询数据:

The basic code structure of this tool is used to read a single work sheet in one .xls file by solid path. So I created a 3*3 excel sheet for test. Html form choices with (i,j) cell position are sent to excel_reader by ‘post’ method, which would return and print out the checking result by code below.

[php]

echo $data->sheets[0][‘cells’][$_POST["row"]][$_POST["column"]];

[/php]

测试结果如图1, 成功!进入下一步开发。

Test was successful as fig.1! Next step.

20160317-checker_devlop_log-1

图.1(Fig.1)

根据日志>2<中图2的逻辑与文件结构,需要查询不同路径下不同xls的文件,路径由表单输出的数据决定,所以excel_reader读取路径处不能再填写定值,故在这之前定义了一个变量$path, 同样采取post的形式获取表单数据并编写路径,然后让reader读取$path路径:

According to logic and files structure posted on fig.2 of log >2< , the checker must visit different folders and pick out the exact .xls database file from dozens of them. In other words, the file path and the name of file should be variables. So I define a $path variable which get message from the form by post method as well. And the reader will read the $path instead of solid path.

[php]

$path="db/".$_POST["type"]."/".$_POST["zone"].".xls";

……

$data->read($path);

[/php]

由于我只在一个文件夹里存放了一个db.xls文件,当我在表单选择了一个空路径的时候或者我没有填写完所有表单项却提交了表单,reader返回了”The filename …….xls is not readable”的错误信息,我意识到整个单选表单必须填写完成才能提交。搜索了许多方法,一开始发现需要通过js等工具进行表单验证,弹出提醒框等等等。踏破铁鞋无觅处得来全不费工夫,html5直接提供了表单必填的验证,在input里添上短短一句便可:

I uploaded only one db.xls file to the database folder, then I found a problem when I select a wrong path or leave some form blank —— reader told me that ‘The filename …….xls is not readable’. And I realized I must set something for form correction. So many methods told me to use js code or else when the exactly excellent answer is so simple that you should write only 2 word in the <input>, thanks to html5 :

[html]

required="required"

[/html]

剩下的就让浏览器来做就好了,如图2

The rest of the work? Browsers will do for you as fig.2!

20160317-checker_devlop_log-2

图.2(Fig.2)

显然,如上图,我用div把表单框起来并稍微美化了一下。

Obviously, I beautified the page by <div> tag.

主要的问题都解决了,就把表单修改为正式的极限偏差查询器项目,然后上传了一个完整数据的.xls数据表,极限偏差查询器正式进入线上beta测试!

Works done and problems solved. The html form was changed into real tolerance checker type. And I uploaded the first database .xls file with useful tolerance data. It is beta test now!

20160317-checker_devlop_log-3

下一阶段的工作目标:

Plan for next version:

  1. 由于我获得的极限偏差表是纸质的,所以所有数据必须手动创建.xls文件,需要实现公差查询的基本功能,这个是主要任务也是工作量最大的任务。
  2. 学会一些CSS的内容,将查询器美化一下。
  3. 学会一些Jquery、ajax的内容,将跳转显示查询结果改为在主页刷新显示查询结果,即客户端只需要显示index,同时包含表单和查询结果显示框,表单不断复用。
  1. Tolerance data I own is on papers. If the tolerance can function as a real one, I must type the data into computer by hand and edit .xls files manually. Hard work but necessary.
  2. Learn something about CSS and use it to beatify the checker’s page.
  3. Learn something about Jquery, ajax or else. The codes can refresh the checker index page without jumping into others. Which means, the index contain the html form and the result display on same page, visitor can reuse the form and read the result on same page, without clicking “Back to index and check again”.

13/03/2016 – Haircut myself – 自理头发

(English version follows Chinese Part)

大概从几岁的幼年开始一直到高中再从大三开始至今(大一大二时因为中二年纪留的较长头发略去不表),我都一直是比较方正的短发头型,但是要保证风格统一的发型还真是件难事,小学期间因为都仰赖家附近理发店里三四个比较熟悉的理发师,一直都能维持稳定。但初中开始,高中,大学期间,给我理发的理发师除了经常变换,就算是连续给他剪头发,也都还是不能记住我的风格,又要重新解释“这个怎么剪怎么剪……”。

My hair style has not been changed for dozen years (special situation during first two years in university with long hair because of idiot me) , my short haircut is some kind of difficult staff to maintain. Thanks to hairdressers near to my home, it was still easy to take good care of my hair style. However, things will not always go as your wish. Since junior high school years, not only changing of my hairdressers but also forgetfulness of them were bothering me. I had to discuss how to make the exact style I want every time those years.

终于我忍不住了,在大四的时候网购了一个电推子,附送了点工具,打算自己剪!

My patience is limited. I bought a electric hair clipper with some tools in forth uni-year. Do it myself!

第一次自己剪头发是悲剧学到了一点技巧。悲剧的原因不太成功是因为:一是不了解电推子的威力,一下手发鬓就剪得太薄了;二是不会用梳子,所以剪得坑坑洼洼。还好只是自己剪了发鬓,没有剪头顶,所以最后赶紧去理发店给修了回来;三是没办法看到后脑勺,自己剪不了。

The first try was tragedy taught me with experience. It was not success for these reasons: I cut to much hair when I handle the clipper first time, muscle control needs practice; There will be potholes  without comb; Nothing can be cut from back of your head until you have second mirror. Luckily I stop my haircut before out of control – I only cut the hair on the temples. And I sought for rescue in barbershop at last.

之后因为有点心灰意冷,便没有再给自己理发的打算。但偶尔还是拿理发剪刀给自己修修刘海,修修发脚。修着修着意识到其实就是缺镜子缺梳子嘛,再试一次好了。

Honestly, I was upset and decided to give up. But it was OK with my skill in trimming  my fringe with scissors. After I realized the core factors are comb and mirrors, Plan B was on the way.

第二次剪已是几个月后的前些天。这次充分吸取了上次的教训:老老实实用限位梳确保不会剪得太多;认真用梳子比划了发型,提前练习了另一只手操作梳子;找了另一块小镜子配合屋里的穿衣镜,能够看见后脑勺。

Few months later, the well trained guy gave a second try days ago. Limit comb was used to prevent over cutting, previewed the hairstyle with comb on my left hand and the second mirror for back-head-haircut.

最后的结果是图就不放了:总体上比较成功,理出了需要的发型,没有坑洼,厚薄均匀。仍需改进的地方就是:发脚发鬓因为用了限位梳所以太厚,下一次再练习练习直接剃。

Well, happy ending no picture :approached my hair style, no potholes, average thickness. Need to promote: too thick at the hair on the temples.

总结下来,就是:一定要会用梳子,一定要有第二块镜子

Conclusion, there must be comb and two mirrors.

我所用到的工具如图1,分别是:①充电理发器(加限位梳)②美工剪刀,修发脚③理发剪,剪头顶长发的长度④梳子⑤架在相机三脚架上的小镜子,配合穿衣镜看后脑勺。

My equipment shown on fig.1,

①electric hair clipper (with limit comb) ②art scissors, trimming hair foot ③haircut scissors, trimming long hair ④comb ⑤second mirror attached to the camera tripod.

20160313-haircut

图.1(Fig.1)

08/03/2016 – Tips of Tolerance Checker– 公差查询器备忘

(English version follows Chinese Part)

之前就有说过实验室板块一共打算同时进行两个项目,天文部分是晴天钟,机械部分是公差查询器。这篇文章打算记录一下公差查询器的思考内容以作备忘。

I was talking about plans of the lab before, Web Forecast for astronomy block and Tolerance Checker for mechanical block. This is the memorandum of what I have thought about building the tolerance checker.

一开始先检索了一下“检索器+数据库”结构的实现方式,包括asp+excel, php+myaql, php+excel等等等等。我根据我的客观条件,打算采用php+excel的方式来实现网页查表式的公差查询器。

The basic structure of online checker is “checker+database”, which have kinds of  method including asp+excel, php+myaql, php+excel and etc. Considering of objective conditions I have, I will go by php+excel solution.

选择php+html作为前端和服务器端的检索器是因为我已经有了一个支持php的虚拟主机,直接提供了在线调试环境,而且流量够、速度够,就不打算再倒腾一番搭建本地测试环境了。所以没有采用asp。

It is no necessary that set up another local testing environment when I have already got virtual host with php supporting. That’s why I chose php instead asp for my checker and I can test it online.

至于数据库,使用excel,是因为我完全不打算再学mysql,另一个原因是极限偏差表的数据量有点大,而且目前取得的数据必须要依靠我手工输入,所以选择excel在创建数据库的时候会比较便捷。另外,php有开源的excel读取工具可以直接调用,这对我这样一个php小白来说,实在是方便不过。

As for database, learn to use mysql may take too much time. But the core problem is that entering data of tolerance would be a huge project when I have to type it myself by hand. So, excel will be easier for me to setup database files. Luckily, php has open source of excel reader that I can use for my checker directly.

目前,参考网络上已有的php+excel查询器例子,思考了几天,打算按照如图1的结构创建查询器,不过也有可能需要更多的php文件在服务器端进行检索、查表操作。

After searching examples of php+excel checkers online, I make the structure graph as Fig.1. It is a prophase plan and there might be more php files for the checking function at server side.

20160308-tolerance_checker (2)

图1(Fig.1)

主页客户端的表单和服务器端检索的逻辑如图2,我目前最好的打算是表单和结果显示能够在同一页面展现且不断复用,这样才是“查询器”,而不是“查询页”。

The form on front page has its appearance as Fig.2 and the checking logic of server-side files have been shown as well. My better plan of the front page is that exhibiting the radio buttons and the return result on the same page which can be reused without refreshing the page.

20160308-tolerance_checker-1

图2(Fig.2)

27/02/2016 – Tips of Using Web-Based Meteorological Forecast API– 晴天钟API使用备忘

(English version follows Chinese Part)

最近比较忙,又有挺久没更新日志了,趁稍稍有空赶紧写一篇。

Lots of works recently and less update of the log. One post must be done today when I had a break.

我在之前的Lab建设日志里提到过天文板块第一个工程是引用晴天钟的API,所以我研究了一下基本的搭建步骤。

I have mention about the 1st Project of Astronomy Part in my Lab in past lab log, which is a  web-based meteorological forecast. So I did some preview for building the page.

晴天钟的工作原理是通过检索或识别IP的方式,取得一个地理坐标,然后根据坐标点检索美国国家大气海洋局/气候环境预测局(NOAA/NCEP)“全球预测系统”(Global Forecast System, GFS)的天气数据,然后通过生成数据图表的形式,提供天气预报。

How 7Timer!  works? By searching a location or notifying IP add, coordinate is recognized and used to pick up weather data from the NOAA/NCEP-based numeric weather model, the Global Forecast System (GFS). A chart/graph would be generated and post on the web page, which is the meteorological forecast.

根据晴天钟API的介绍,通过提交:

According to the introduction of 7Timer!’s API, these data should be submited

lon, lat – 指定地点的经纬度,必须是浮点数,比如+23.090或-23.090,精确到0.001度即可。
ac – 高度改正,只对天文用途产品有效。可取0(默认)、2或7。
lang – 语言。对气象用途产品无效。
unit – 公制或英制。
output – 可设定为internal(图表输出)、xml或json。
tzshift – 时区微调,可取0、1或-1。

 

lon, lat – Geographic coordinates of the specified site, must be given as pure float numbers, such as +23.090 or -23.090. At this stage, the precision of any incoming coordinate float number is expected to be 0.001. Incoming float with higher precision will be rounded.
ac – Altitude Correction, only applicable in ASTRO forecast. Should be 0 (default), 2 or 7.
lang – Language. Not applicable in METEO product.
unit – Metric or British.
output – should be internal (for graphical output), xml or json.
tzshift – Adjustment of timezone, should be 0, 1 or -1.

的变量调用API,返回一个生成的数据图表,亦即天气预报。

to the API and the report graph will be processed.

如果要在GoYuWei的Lab里实现这一工作,就需要:

If I wish to run a graph forecast in my lab, things must be done:

  1. 申请一个Google或者百度的地理坐标API,编写一个函数,识别访问者的IP并转换成地理坐标,并输入经纬度变量。
  2. 将变量提交至晴天钟的API接口,返回一个或多个天气预报图标。
  3. 显示在一个尽可能美观的网页上。

 

  1. Apply for geography API of Google.com or Baidu.com, write down a function to recognize IP add of visitors and transform into coordinates.
  2. submit  those data to the 7Timer!’s API, then return the graphs.
  3. Build a well look web page with the forecast graphs.

关于晴天钟,请访问http://202.127.24.18/about.php?lang=zh-CN

About 7Timer! Web-Based Meteorological Forecast , visit http://202.127.24.18/about.php?lang=en

 

13/02/2016 – Cheers For Gravitational Waves Spotting – 祝贺发现引力波

(English version follows Chinese Part)

20160213-Gravitational Waves

工程学出身的我也必须为科学界的巨大成就——人类首次直接探测到引力波而庆贺。这是对爱因斯坦理论的又一次证明,更是人类在挑战自我认知和宇宙认知上的一大进步。至少,证明人类有足够的能力去制造自己需要的实验设备,比如此次发现的功臣——激光干涉引力波天文台 (LIGO),也是工程学界和实验物理学的骄傲!

更多关于此项研究的新闻,可以参考阅读<科学>杂志网站的新闻:链接

Although I am a student majoring in engineering, I must show my congratulation and respect to the huge success in field of science, gravitational waves have been spotted by human being for first time. It is a solid evidence for Einstein’s theory, and a big step of  self-cognition and universe-cognition for people on earth. At least, Laser Interferometer Gravitational-Wave Observatory (LIGO) proves that mankind has its power to build up what is needed for experiment. The academic circles of engineering and experimental physics are proud of it.

You may discover more information and news about this research on website of Science magazine by this Link.