Code Monkey home page Code Monkey logo

vif-sim's Introduction

Vif-sim

This is the rust program that parses & runs a virtual simulation using the typescript front-end data.

// Notes:

Still WIP and very experimental.

Due to the recent release of WIT components, a lot of js glue code present in this package is now obsolete.

This project was built to solve problems first and be refactored later, some parts are not "idiomatic" rust and a lot of things can be simplified.

If you have any questions about certain parts (for example on how all possible operations on plc primitives are declared at compile time despite orphan rule), feel free to ask me.

The generative macro used by the parser to quickly get JSON values can be found as a gist here:

enum_dispatch is not IDE friendly but necessary to avoid dynamic dispatch as much as possible, which is also of why warnings about unused imports are disabled.

Architecture

graph TD
    classDef sub opacity:0
    classDef Blue stroke:#00f
    classDef Green stroke:#0f0

    A("container"):::Blue --> B
    B("kernel"):::Blue
    C("broadcast"):::Blue
    
    D("parser"):::Green
    E("simulation"):::Green
    
    A & B --> C
    A .-> D & E
    E --"async loop with kernel data"--> E
    
    subgraph subA [" "]
        A 
        noteA[
        This is the main module exported to js that boots the whole program.
        It intercepts all commands from the user.
        ]
    end
    
    subgraph subB [" "]
        B
        noteB[
        Stores the simulation data & virtual runtime on the heap.
        ]
    end

    subgraph subC [" "]
        C
        noteC[
            Communication between runtime and outside.
        ]
        end
        
class subA,subB,subC sub
class noteA,noteB,noteC note
Loading

Debug

Run & Debug should work fine on x86_64-pc-windows-msvc target.

Untested on Linux & Mac but since this project was primarily built for the wasm32-unknown-unknown target most of the code is no-std.

Build

Use Powershell -File build.ps1 to compile wasm packages.

Output:

  • pkg_web: browser
  • pkg_node: node

wasm_opt might slow down compilation time when optimizing wasm binaries, you can disable it by adding a --dev flag next to wasm-pack build in build.ps1

vif-sim's People

Contributors

adclz avatar

Watchers

 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.