简体   繁体   English

Node.js + Node-Webkit +基于Node-SerialPort的应用程序 - 这可能吗?

[英]Node.js + Node-Webkit + Node-SerialPort Based Application - Is this Possible?

I am new to Node.js and before I go head first into taking on a new technology and migrating my c# based application, I wanted to make sure what I had in mind is possible with Node.js and if it is recommended. 我是Node.js的新手,在我首先开始使用新技术并迁移基于c#的应用程序之前,我想确保Node.js可以实现的目标是什么,以及是否建议使用。

So please let me know your opinion! 所以请让我知道你的意见!

My application has the following requirements:- 我的申请有以下要求: -

  1. TCP server (to receive packets from TCP clients such as smart phones, computers etc.) TCP服务器(从智能手机,计算机等TCP客户端接收数据包)
  2. Serial port access (To control a hardware device) 串口访问(控制硬件设备)
  3. Web server facilities (to serve HTML5 pages or provide web services intefaces) Web服务器设施(提供HTML5页面或提供Web服务接口)
  4. Simple native app like GUI for configuration. 简单的原生应用程序,如GUI配置。
  5. All of this needs to be packaged nicely for end users to install simply. 所有这些都需要很好地打包,以便最终用户安装简单。

Why I would want to do this you may ask?? 为什么我想这样做你可能会问? The reason I am most interested in using Node.js is due to the cross platform nature, including the ability to install on cheap single board/embedded computers. 我最感兴趣的是使用Node.js的原因是由于跨平台性质,包括在廉价的单板/嵌入式计算机上安装的能力。

This is my thinking:- 这是我的想法: -

Node.js - to provide the TCP server, serve HTML5 pages and provide web services interfaces. Node.js - 提供TCP服务器,提供HTML5页面并提供Web服务接口。

Node-Webkit - to provide the simple native app like configuration interface. Node-Webkit - 提供简单的本机应用程序,如配置界面。 I also believe that it provides the ability to package my application for simple distribution, but I am not sure? 我也相信它提供了打包我的应用程序以进行简单分发的能力,但我不确定? (I could leave out Node-Webkit if there was another way to package my app for simple distribution. Although it is preferred as even having to find the IP Address of the computer so as to access a web browser interface would be tricky for some of my users.) (如果有其他方法来打包我的应用程序以便进行简单分发,我可以省略Node-Webkit。虽然它是首选,因为即使必须找到计算机的IP地址以便访问网络浏览器界面对某些人来说也是棘手的。我的用户。)

Node-SerialPort - to provide the ability to communicate with the hardware device. Node-SerialPort - 提供与硬件设备通信的能力。 The instructions will come from 1 of three sources. 说明将来自三个来源中的一个。 1) TCP connection 2) HTML5 Webpage Initiated 3) Web Services Initiated. 1)TCP连接2)HTML5网页启动3)Web服务启动。

  1. That's what most people use Node.js for 这就是大多数人使用Node.js的原因
  2. https://npmjs.org/search?q=serial+port https://npmjs.org/search?q=serial+port
  3. Again, that's what most people use Node.js for 同样,这是大多数人使用Node.js的原因
  4. Because of 1 and 3, the most obvious UI for node.js apps is the browser. 由于1和3,node.js应用程序最明显的UI是浏览器。 Write a config page to control your app. 编写配置页面来控制您的应用。 Using node-webkit is overkill, just use whatever browser is already available. 使用node-webkit是过度的,只需使用已有的任何浏览器。 Node can run multiple listeners on multiple ports, serving the same app. Node可以在多个端口上运行多个侦听器,为同一个应用程序提供服务。
  5. npm install is pretty simple. npm install非常简单。

Go learn how to write simple Node.js apps (with express for easy http servering, and jade or nunjucks for easy html templating) and then move up from there. 去学习如何编写简单的Node.js应用程序(使用表达式轻松进行http服务,使用jade或nunjucks进行简单的html模板),然后从那里向上移动。

Point 5 . 第5点 I understand the fact of having an installer. 我理解安装程序的事实。 I would suggest that the .msi or .exe will create a Windows Service for NodeJs. 我建议.msi或.exe将为NodeJ创建一个Windows服务。 Then the node js server will launch at Windows startup and the end user will access the browser with 然后节点js服务器将在Windows启动时启动,最终用户将访问浏览器

http://localhost:< a port number>/. 

Packaging NodeJS : To package nodejs, you can copy the nodejs.exe from the installation directory of nodejs into the directory where you developp the node application. 打包 NodeJS:要打包nodejs,可以将nodejs.exe从nodejs的安装目录复制到开发节点应用程序的目录中。 Then zip everything. 拉下一切。 You unzip it on another computer and it will execute. 您将其解压缩到另一台计算机上,它将执行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM