开源 物联网平台管理系统

If you have no idea about the development architecture and mechanical/electrical design behind IoT solutions, they could seem like "having seemingly supernatural qualities or powers". For example, if you show a working IoT system to 18th century people, they'd think it's magic.This article is sort of busting such myth. Or, to put it more technically, about hints for fine-tuning the IoT development for an awesome project in solar energy management area.

Spoiler: no spells, only analytical ideas for developing fast and easy service.

剧透 :没有咒语,只有分析性的想法可以发展快速便捷的服务。

Disclaimer: We offer no one-fits-all solution (it simply doesn't exist), just share the stuff that we find serious. These points may be killer features while on the contrary their neglection may kill it. Pun intended ;)

免责声明 :我们没有提供万能的解决方案(它根本不存在),只分享我们认为很认真的内容。 这些要点可能是杀手级功能,相反,忽略它们可能会杀了它。 双关语意;)

(Introducing IoT system for visualizing and optimizing solar energy consumption)

We had the pleasure to work on a project of improving self-generated energy usage. The core lies in visualizing and optimizing the use of photovoltaic (PV) systems for both installer companies and end customers. So, when Solar Manager is installed as a central hub for distributing the produced solar energy between household devices, you use maximum of self-produced energy.

我们很高兴从事改善自生能源使用的项目。 核心在于为安装公司和最终客户可视化和优化光伏(PV)系统的使用。 因此,将Solar Manager安装为用于在家用设备之间分配产生的太阳能的中央集线器时,您将使用最大的自行产生的能量。

国内物联网平台开源框架 物联网管理系统 开源_国内物联网平台开源框架

We've already written about business perspective of using solar energy, and now let's dive into tech challenges and hints of the development.

我们已经写过关于使用太阳能的商业观点,现在让我们深入探讨技术挑战和发展提示。

(Absolute prerequisite)

Before we start, let's get clear. There is one thing that does apply for each and every project, regardless if it's an IoT system or simple landing.

在开始之前,让我们弄清楚。 还有, 它适用于每一个项目,无论如果它是一个一两件事物联网系统或着陆简单。

Never start implementation before you have a complete understanding of what you want to achieve (and everyone involved does).

在您完全了解要实现的目标之前(所有相关人员都知道),切勿开始实施。

There is no such a thing as evident. No, there are no telepaths, and nobody reads your thoughts. Clarify, discuss, make sure you're on the same page.

没有明显的事情。 不,没有心灵感应,没有人阅读您的想法。 澄清,讨论并确保您在同一页面上。

国内物联网平台开源框架 物联网管理系统 开源_python_02

Of course, if you don't want to spend twice as much time and money.

当然,如果您不想花费两倍的时间和金钱。

(The mission)

So, what we have as inputs? Flexible connectivity and centralised remote firmware, 5 user roles with different UX and permission sets, converting and analyzing data, huge amount of requests, and, as an icing on the cake, plotting lots of time-value data on charts.

那么,我们有什么投入呢? 灵活的连接性和集中的远程固件,具有不同UX和权限集的5个用户角色,转换和分析数据,大量请求,以及为锦上添花,在图表上绘制了大量时间值数据。

(Challenges and specifics of implementing IoT system for energy consumption)

When it comes to development, 3 things matter the most: stability, relevance, and speed. Especially when the project requires a monolithic architecture. That's why the overall logic, all user flows, and database design should be as simple and optimized as possible. Let's be honest, in 2019 nobody wants to wait 40 seconds because 'your data is being processed'. So, here's the question/answer list for IoT platforms we refer to:

在开发方面,最重要的三件事是:稳定性,相关性和速度。 特别是当项目需要整体架构时。 这就是为什么总体逻辑,所有用户流和数据库设计应尽可能简单和优化的原因。 坦白地说,在2019年,没人愿意等待40秒,因为“您的数据正在处理中”。 因此,这是我们所指的物联网平台的问题/答案列表:

  • Does the architecture fit in the requirements and specifications?
  • How will you convert, process, and analyse collected data?
  • What are the most optimal relations between parent-child MVC/MVP layers? Can they then be scaled without being interrupted?
  • Are there any modules that perform similar/adjoining functions? Can they be united into a single multipurpose module? Will that introduce or reduce complexity?
  • Is the communication between stages optimal?
  • How to cache data before visualizing it?
  • Is the user experience (UX) simple and self-evident for each user role?

Split what needs to be distributed, unite what is similar. Do not confuse this, however, with creating huge classes that (should) solve several tasks. Instead, create small ones for a single task. For complex task, create several classes that each solve a subtask and another one that will use those ones.

拆分需要分发的内容,合并相似的内容。 但是,不要将其与创建(应该)解决多个任务的大型类混淆。 而是为单个任务创建小型任务。 对于复杂的任务,创建几个类,每个类解决一个子任务,另一个类将使用那些子任务。

(Architect IoT solutions smart)

Smart here refers to creating fast, scalable, optimized and sustainable project architecture that fits into project requirements. The basic questions that arose at this point:

此处的“智能”是指创建适合项目要求的快速,可扩展,优化和可持续的项目架构。 此时出现的基本问题:

  1. What is the easiest and most direct architecture flow?
  2. How to make the user experience for each role the simplest?
  3. Can we revise initial architecture for better scalability and performance optimization?

For web apps, this involves the hierarchical model view controller (HMVC) design. For example, to allocate resources better and provide faster response, work through the connections between API, back end, front end, and edge. Configure cloud-local communication, storing and transferring data so that you get right response fast (hello, Captain Obvious!).

对于Web应用程序,这涉及分层模型视图控制器(HMVC)设计。 例如,要更好地分配资源并提供更快的响应,请通过API,后端,前端和边缘之间的连接进行工作。 配置云本地通信,存储和传输数据,以便您快速获得正确的响应(您好,上尉船长!)。

国内物联网平台开源框架 物联网管理系统 开源_python_03

(Design database with performance in mind)

Never underestimate the importance of thinking through the database (DB) design. This also applies to the relations between collections in the database. You have a lot of entities, which interact in various ways, so it is crucial to keep all related logical connections in one place.

永远不要低估通过数据库(DB)设计进行思考的重要性。 这也适用于数据库中集合之间的关系。 您有很多实体,它们以各种方式交互,因此将所有相关的逻辑连接保持在一个位置至关重要。

So, when you have initial structure at hand, determine:

因此,当您拥有初始结构时,请确定:

  1. Is this (one-to-one, one-to-many, many-to-many) the optimal relationship type for this collection? Does it solve the task most efficiently?
  2. How well does it correspond to the task at specific screen?
  3. Does it fit well in the general architecture of the project?

Optimize the logic behind each module and ensure that the general architecture is preserved. Think through the permission set. Then think again and optimize. Remember to set connection types so that for each task you have all needed info in one place and handle requests right.

优化每个模块背后的逻辑,并确保保留常规体系结构。 考虑一下权限集。 然后再考虑并优化。 记住要设置连接类型,以便对每个任务都将所有需要的信息放在一个地方并正确处理请求。

For example, imagine that your database is a fast food restaurant. You have a lot of clients, you need to serve food fast and precisely what they've ordered. Or else your business is done for. That's exactly the same for DBs. Yes, there are dozens of collections and you need data from 7-8 of them simultaneously. So design the relations so that they're logically connected and return the response quick.

例如,假设您的数据库是一家快餐店。 您有很多客户,您需要快速准确地提供他们所订购的食物。 否则您的业务就完成了。 对于数据库来说,这是完全相同的。 是的,有几十个集合,您需要同时从其中的7个到8个数据。 因此,设计关系,使它们在逻辑上相连并快速返回响应。

IoT system is like a restaurant. Don't make the customers wait.

物联网系统就像一家餐馆。 不要让客户等待。

(How to plot [gazillion] of data)

Remember the times, when sites loaded for a couple of minutes? We've seen apps where dashboards load even slower. And that's a no-no.

还记得网站加载几分钟的时间吗? 我们已经看到了仪表板加载速度更慢的应用程序。 那是不可以的。

Charts are a new normal. Data visualization is commonly used in SCADA, IoT, and any analytical projects and for a reason. Seeing spikes in energy consumption, market trends, CO2 in the air, and any other stuff you can measure (typically, over time) gives a vivid impression. You see, you understand, you act. With textual presentation of massive data arrays your eye will blur in no time.

图表是新常态。 出于某种原因,数据可视化通常用于SCADA,IoT和任何分析项目中。 看到能耗高峰,市场趋势,空气中的二氧化碳以及您可以测量的其他任何东西(通常随时间推移)会给人以生动的印象。 你看,你理解,你行动。 通过海量数据阵列的文本显示,您的眼睛将立即模糊。

So, the challenge lies if fast plotting of charts with huge number of value-time pairs. Before users see the data on the chart, system has to determine all the points for plotting it. We had quite a lot of brainstorming to determine how cache the data so that plotting a chart with 50K+ data-value pairs takes less than 2 seconds.

因此,挑战在于快速绘制具有大量价值时间对的图表。 在用户看到图表上的数据之前,系统必须确定所有点以进行绘制。 我们进行了大量的头脑风暴来确定如何缓存数据,以便绘制具有50K +数据值对的图表所需的时间不到2秒。

国内物联网平台开源框架 物联网管理系统 开源_java_04

(From scratch to production, and beyond)

Apart from web app, we also develop iOS and Android app for on-the-go installation, monitoring, and access.

除网络应用程序外,我们还开发了iOS和Android应用程序,可进行实时安装,监视和访问。

The important thing to remember when working on IoT systems is maintaining simplicity and scalability. The typical 5-stage IoT architecture should be well-thought to not bring any redundant complexity.

在物联网系统上工作时要记住的重要事情是保持简单性和可伸缩性。 典型的五阶段物联网架构应经过深思熟虑,以免带来任何冗余的复杂性。

As each product evolves, you have to think through the means of layering new functionality while not interrupting the existing features. And, of course, never forget about unit testing.

随着每种产品的发展,您必须考虑分层新功能的方式,同时又不要中断现有功能。 而且,当然,不要忘记单元测试。

(Less than a year from launching)

Since its launch in October 2018, the Solar Manager is adopted and used by the leading photovoltaic wholesaler and installer companies in Switzerland.

自2018年10月推出以来,Solar Manager已被瑞士领先的光伏批发商和安装公司采用并使用。

By reviewing and optimizing energy-use habits, the consumers get the best out of their PVs and so they save costs. On a more global scale and according to Deloitte, such a solution makes solar energy competitive with traditional power sources. This, in its turn, makes it appealing for other residential consumers and businesses. And, finally, doesn't it sound as a basis of a smart city we all wait for?

通过审查和优化能源使用习惯,消费者可以充分利用其PV,从而节省成本。 根据德勤公司的说法,这种解决方案在全球范围内具有与传统电源竞争的太阳能优势。 反过来,这使其对其他住宅消费者和企业具有吸引力。 最后,这听起来不是我们都在等待的智慧城市的基础吗?

(Behind success any IoT project)

There is no 'ultimate guide' to creating successful product. First, each project is unique and brings its own challenges. Second, even if you've done a bunch of projects in the area, the tech and the market demands evolve. So the experience you have from 2 or even half a year ago might not be relevant now.

没有创建成功产品的“最终指南”。 首先,每个项目都是独特的,并带来自己的挑战。 其次,即使您已经在该地区完成了许多项目,技术和市场需求也在不断发展。 因此,您在2年甚至半年前的经验可能与现在无关。

You can also check our GitHub for lots of free open-source instruments for IoT development.

您也可以在我们的GitHub上查看许多用于IoT开发的免费开源工具。

翻译自: https://habr.com/en/post/466473/

开源 物联网平台管理系统