10/04/2016 – Plus-minus Notation Display Failure – 正负号显示问题

>Tolerance Checker Development Log – 极限偏差查询器开发日志<

最近的主要工作室录入极限偏差数据库,一直都进展的比较顺利,但是今天录入到JS/js公差带的时候遇到了一点问题,JS/js带的极限偏差是±值,一般比较便捷的记法就是±x,但是我以此格式录入的数据库最后查询出来发生了错误,显示如图1。

What I am doing recently is recording data, there was no problem until plus-minus notation display failure came out. When I met the JS/js tolerance zone, numbers are displayed  with ‘±’ ahead, which is like ±x. But the plus-minus notation became ‘?’ as Fig.1.

20160410-Plus-minus Notation Display Failure

图.1(Fig.1)

目前我猜测的可能是在查询的某个环节出了问题:

I think it must be an error at following stage:

  1. php excel reader工具不支持正负号;
  2. 字符集对正负号的支持问题;
  3. 查询器默认字体或者字体库的支持问题。
  1. php excel reader does not support plus-minus notation;
  2. character set does not support plus-minus notation;
  3. fonts of the checker/page do not support plus-minus notation.

由于这个问题无伤大雅,我暂时用比较简单的办法略过这个问题:用+/-来代替±。

Nevertheless, it is not a serious error and I decide to replace the ‘±’ with ‘+/-‘ temporarily.

 

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”.

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

 

10/02/2016 – Some ideas about lab – 实验室的一点想法

(English version follows Chinese Part)

实验室板块主要的作用打算是发布一些关于专业和业余爱好方面的想法以及一些可以在web上实现的功能。

‘Laboratory’ block is aiming at posting ideas on professional fields and hobbies. Also, some experiments will be done in lab on special Web functions.

目前的打算是分专业板块,已经想好的板块是机械和天文。

First two fields have been chosen. Mechanical and astronomy.

机械方面有个打算是做一个web版的机械公差与配合查询器(基于国标GB1800~79),这个想法是得到了一个应用程序版机械公差与配合查询器的启发,这个查询器曾经给我的专业课、课程设计还有毕业设计提供了极大帮助,非常实用,所以我考虑在web上实现它。关于公差与配合查询器,你可以在这个链接(华军软件园)找到并下载它。

The idea on mechanical is setting up a web retriever of tolerances and fits. I was inspired by a retriever app (base on national standard GB1800~79) on PC, which support me in my specialized courses, course exercises and graduate design. So I chose to make a web version of it. About the app, you can find and download it on this page (link)

天文方面是最近发现的一个实用工具——晴天钟,一个web气象预告,期初是在星明天文台的官方网站(链接)发现了它,后来根据声明链接找到了晴天钟的官方网站(链接),我打算在我的实验室里利用它的API。

About astronomy, I was attracted by a tool that provides web weather forecast, named 7Timer!. The first time I found it was on official website of  Xingming Observatory (Link) , and I visit 7Timer! official website later. You can visit 7Timer! by this link. I plan to use its API in my lab here.