Git Product home page Git Product logo

rulex's Introduction

RULEX Framework

希望大家第一眼就看到这个说明 更多文档参考(国内可能需要科学上网): https://hootrhino.github.io

如果您阅读过 RULEX 的源码,你会发现里面有很多很愚蠢的设计(比如对资源的状态管理、类型硬编码设计等),因为特殊历史原因导致了其设计上有一些很糟粕的地方,如有建议请不吝赐教,一起让这个框架更加优秀!同时未来随着版本的迭代,很多低级问题会逐步被重构完善。

RULEX 是一个轻量级工业类边缘网关开发框架

架构设计

预览

image image image image image image image

快速开始

HelloWorld

下面展示一个最简单的设备数据转发案例:

AppNAME = 'UdpServerTest'
AppVERSION = '0.0.1'

function Main(arg)
    for i = 1, 10, 1 do
        local data = { temp = 20.15 , humi = 34}
        local err = applib:DataToUdp('UdpServer', applib:T2J(data))
        time:Sleep(100)
    end
    return 0
end

这个 DEMO 展示了如何把一个简单的数据推到 UDP 服务器端

支持的平台

架构 操作系统 测试
X86-64 X86-64-Linux\Windows 通过
ARM64 ARM-64-Linux 通过
ARM32 ARM-32-Linux 通过
Mips Arm-Mips-Linux 通过

除此之外,还可以在 Armbian、OpenWrt 等小众平台上编译成功。

!!!注意:现阶段只针对Ubuntu16.04和Ubuntu18.04做了大量支持,其他的系统也许能编译成功但是没测试功能是否可用

规则引擎

规则定义

function Success()
    -- do some things
end

function Failed(error)
    -- do some things
end

Actions = {
    function(args)
        return true, args
    end
}

数据筛选

Actions = {
    function(args)
        print("return => ", rulexlib:JqSelect(".[] | select(.hum < 20)", data))
        return true, args
    end
}

数据中转

Actions = {
    function(args)
        -- 持久化到 MongoDb:
        data:ToMongo("45dd0c90f56d", data)
        -- 持久化到 Mysql:
        data:ToMysql("45dd0c90f56d", data)
        -- 推送化到 Kafka:
        data:ToKafka("45dd0c90f56d", data)
        return true, args
    end
}

云端计算

function Main(Arg)
    -- {1,2,3,4,5,6,7,8,9,10}
    local cutterData, err = applib:ReadDevice('Dev1', 'D1', "count=10")
    if err ~= nil then
        error(err)
        return
    end
    -- 交给 ID为'AI-001'的AI模型去计算结果
    -- 输出结果是一个数组,维度取决于模型输出参数
    -- Result: {1}
    local Result, err = aibase:Infer('AI-001', cutterData)
    if err ~= nil then
        error(err)
        return
    end
    print('Result =>', Result)
    applib:save(Result)
    return 0
end

社区

贡献者

鸣谢各位给RULEX贡献代码的社区开发者。

Star

rulex's People

Contributors

wwhai avatar lion-brave avatar qubbei avatar wan9bo7 avatar dropliu avatar beattime avatar gmnoah avatar suixinio avatar goldeagle avatar ijuvenile avatar mingyuewanchonglou avatar sanshengshui avatar tianyingkeji avatar yuanliang-ma avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.