Giter VIP home page Giter VIP logo

labviewcgen's Introduction

LabVIEWCGen

Elementry C code Generator For LabVIEW

Pros

Supports the following constucts:

  • I32
  • SubVI Calls
  • Add
  • multiply
  • Case Structures (kinda)

Cons

  • Supports nothing else
  • Requires all wires to be named (it names them)

How to Use

  1. Open the C_Converter project
  2. Open the Converter vi
  3. Select a Test vi in the "vi path" control
  4. Run the Converter vi to view the converter c code.

method/theory

Given that LabVIEW is a flow based notation the convertion to c code seems obvious but there are some tricky bits. I have handled the converion in terms of wires meaning that each wire is a c variable, I do recongnize that this is not the most effecient route but there is a long road ahead if I want this thing to work on general code.

Data structure

I presently handle each call as a preallocated rentrant vi. This means that each vi has its own memory for its inputs and outputs, which is what is stored in the memory. Each subVI gets its own typedef, the c function does not return anything and has a single parameter the context which i named _C_ because it looks contexty and is an unlikely name to be reused.

Test5 vi block diagram

Test5 vi block diagram

Test5 vi block diagram

The code above is converted into the following c code along with the data recommended for the header file:

Header:

typedef struct Test5_tag
{
  Test1_t Test1_1;
  int32_t OutVal;
  int32_t TrxVal;
  int32_t CSelect;
} Test5_t , * Test5_ptr_t;

void Test5(Test5_ptr_t _C_);

C code:

void Test5(Test5_ptr_t _C_){
  int32_t Val_174;
  int32_t Val_127;
  int32_t Val_432;
  int32_t Val_160;
  int32_t Val_168;
  int32_t Val_205;
  int32_t Val_183 = _C_->CSelect;
  int32_t Val_179 = _C_->TrxVal;
  const int32_t Val_164 = 55;
  
  switch(Val_183){
      
      case  1 :
        Val_168 = Val_179;
        Val_160 = Val_164 * Val_168;
        
        /*Call To Test1*/
        _C_->Test1_1.B = Val_164;
        _C_->Test1_1.A = Val_160;
        Test1(&_C_->Test1_1);
        Val_432 =_C_->Test1_1.C;
        
        Val_174 = Val_432;
      break;
      
      case  2 :
        Val_205 = Val_183;
        Val_174 = Val_205;
      break;
      
      default:
        Val_127 = Val_179;
        Val_174 = Val_127;
      break;
  }
  _C_->OutVal = Val_174;
}

labviewcgen's People

Contributors

taylorh140 avatar

Watchers

James Cloos avatar  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.