SlideShare ist ein Scribd-Unternehmen logo
1 von 21
Sample & Assay Technologies
Use of Lua in Lab Devices
Claus Kühnel, Daniel Zwirner, QIAGEN Instruments AGJanuary 2015
Lua is a powerful,
light-weight programming
language designed for
extending applications.
The language engine is
accessible as a library,
having a C API which
allows the application to
exchange data with Lua
programs and also to
extend Lua with C
functions.
Lua is also used as a
general-purpose,
stand-alone language
through the simple
command line interpreter
provided.
Sample & Assay Technologies
2
Initial Situation
2
Origin of Lua
Lua is designed, implemented, and maintained by
a team at PUC-Rio, the Pontifical Catholic
University of Rio de Janeiro in Brazil.
Lua was born in 1993 and raised in Tecgraf,
formerly the Computer Graphics Technology
Group of PUC-Rio.
LabLua was founded on May 2004 by Prof.
Roberto Ierusalimschy.
Lua is now housed at LabLua, a laboratory of
the Department of Computer Science of PUC-
Rio.
"Lua" (pronounced LOO-ah) means "Moon" in
Portuguese.
Sample & Assay Technologies
3
Initial Situation
3
Initial Situation
Robotic Hardware (HAL)
movexy(x,y) ….
Biological
Protocol
Protocol
Interpreter ….
Robotic Platform
Sample & Assay Technologies
4
• To execute “biological protocols” we need an
protocol interpreter as a layer over the HAL
• Should we develop the 1001. proprietary
interpreter now?
• Searching for a suitable solution leads us to Lua
• A Friday afternoon was enough for installation
and first tests
• Culture shock for the proprietary fraction
Initial Situation
Sample & Assay Technologies
5
• Lua is a powerful, fast, lightweight, embeddable
scripting language.
• Lua combines simple procedural syntax with
powerful data description constructs based on
associative arrays and extensible semantics.
• Lua is dynamically typed, runs by interpreting
byte code for a register-based virtual machine,
and has automatic memory management with
incremental garbage collection, making it ideal
for configuration, scripting, and rapid
prototyping.
What is Lua?
Sample & Assay Technologies
6
• Lua is a proven, robust language used in
applications like Adobe's Photoshop Lightroom,
World of Warcraft & Angry Birds.
• Lua is fast, portable, embeddable
• Lua is powerful (but simple)
• Lua is small. Under Linux, the Lua interpreter
built with all standard Lua libraries takes 182 KB
and the Lua library takes 244 KB.
• Lua is well documented
• Lua is free open-source software, distributed
under the well-known MIT license
• Runs on all common operating systems
Why choose Lua?
Sample & Assay Technologies
7
Lua Documentation
Sample & Assay Technologies
8
Installing Lua (to get a playground)
Lua for Windows
Lua for Windows (LfW) combines Lua binaries, Lua libraries with a
Lua-capable editor in a single install package for the MS Windows
operating system.
LfW contains everything you need to write, run and debug Lua scripts
on Windows. A wide variety of libraries and examples are included
that are ready to use with MS Windows.
https://code.google.com/p/luaforwindows/
Lua for Linux (Debian)
apt-get install lua5.1
apt-get install lua5.1-0-dev
http://ckuehnel.ch/dokuwiki/doku.php?id=lua_on_bananapi
Sample & Assay Technologies
10
Some Lua code
function p(a)
io.write(a .. ", type is " .. type(a) .. "n")
end
a = 123.45
p(a)
-> 123.45, type is number
a = "hello"
p(a)
-> hello, type is string
a = 123+ "12"
p(a)
-> 135, type is number
Sample & Assay Technologies
12
Returning multiple variables
function f(a,b)
return a, a*b, 5
end
print(f(1,2))
-> 1 2 5
a,b,c = f(3,4)
print(a,b,c)
-> 3 12 5
t = {1,2}
print(f(unpack(t)))
-> 1 2 5
Sample & Assay Technologies
14
Variable number of arguments
function f(a,b, ...)
print(a,b, unpack(arg))
end
print(f(1,2))
-> 1 2
print(f(1,2,3))
-> 1 2 3
print(f(1,2, "Hi", " there"))
-> 1 2 Hi there
Sample & Assay Technologies
15
Set of functions that allow C to interact with Lua
• Functions to read and write Lua global variables
• Functions to call Lua functions
• Functions to register C functions within Lua
Stack-based parameter passing
C Interface API
Sample & Assay Technologies
16
Embedding Lua:
• Lua is packed as a library.
• The application calls lua_open to create and
initializes a Lua state.
• When the application is finished running Lua script it
calls lua_close to finalize and destroy Lua state.
Extending Lua:
• The Lua API supports the extension of Lua state by
the possibility to call C functions from Lua scripts.
Embedding Lua vs. Extending Lua
Sample & Assay Technologies
17
Lua Stack – LIFO principle
C-> Lua Lua -> C
void lua_pushnil() lua_isnil()
void lua_pushboolean() int lua_toboolean
void lua_pushnumber() double lua_tonumber
void lua_pushstring() const char* lua_tostring
void lua_pushlstring() size_t lua_strlen
void lua_gettable
void lua_settable
Sample & Assay Technologies
18
Lua Stack – Pushing elements
void lua_pushnil (lua_State *L)
void lua_pushboolean (lua_State *L, int bool);
void lua_pushnumber (lua_State *L, double n);
void lua_pushlstring (lua_State *L, const char *s, size_t length);
void lua_pushstring (lua_State *L, const char *s);
Sample & Assay Technologies
19
Lua Stack – Query elements
int lua_toboolean (lua_State *L, int index)
double lua_tonumber (lua_State *L, int index)
const char * lua_tostring (lua_State *L, int index)
size_t lua_strlen (lua_State *L, int index);
Sample & Assay Technologies
20
Lua Stack – other stack operations
void lua_pop (lua_State *L, int number)
int lua_gettop (lua_State *L)
void lua_settop (lua_State *L, int index)
void lua_pushvalue (lua_State *L, int index)
void lua_remove (lua_State *L, int index)
void lua_insert (lua_State *L, int index)
void lua_replace (lua_State *L, int index);
Sample & Assay Technologies
21
Enhancing Lua by C functions
http://ckuehnel.ch/dokuwiki/doku.php?id=lua_erweiterung
Embedding Lua in a C application
http://ckuehnel.ch/dokuwiki/doku.php?id=lua_embedding
Sample & Assay Technologies
22
Wrapper
SWIG is a software development tool that connects
programs written in C and C++ with a variety of high-level
programming languages.
http://www.swig.org/
tolua is a tool that greatly simplifies the integration of
C/C++ code with Lua. Based on a cleaned header
file, tolua automatically generates the binding code to
access C/C++ features from Lua
http://webserver2.tecgraf.puc-rio.br/~celes/tolua/
Look for examples to both wrappers in our book.
Sample & Assay Technologies
23
Lua in a Lab Device
HAL
movexy(x,y) ….
GUI
movexy(x,y) ….
Lua VM
….
Robotic Platform
Lua enhanced
by C/C++
functions (HAL)
Lua embedded
in C/C++
application (GUI)
Sample & Assay Technologies
INSTRUMENT
init()…
24
Lua in a Lab Device – some code
HAL
init()
GUI
pushButtonInitPressed() ….
LuaVM
run()… luaopen_cube() …
Robotic Platform
Lua embedded
in C/C++
application (GUI)
Lua enhanced
by C/C++
functions (HAL)
Code sample:http://ckuehnel.ch/dokuwiki/doku.php?id=lua_lab_device

Weitere ähnliche Inhalte

Was ist angesagt?

Sour Pickles
Sour PicklesSour Pickles
Sour PicklesSensePost
 
Ekon bestof rtl_delphi
Ekon bestof rtl_delphiEkon bestof rtl_delphi
Ekon bestof rtl_delphiMax Kleiner
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchAndrew Lowe
 
LeFlowを調べてみました
LeFlowを調べてみましたLeFlowを調べてみました
LeFlowを調べてみましたMr. Vengineer
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationEelco Visser
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python ProgrammersVsevolod Dyomkin
 
A peek on numerical programming in perl and python e christopher dyken 2005
A peek on numerical programming in perl and python  e christopher dyken  2005A peek on numerical programming in perl and python  e christopher dyken  2005
A peek on numerical programming in perl and python e christopher dyken 2005Jules Krdenas
 
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?MobileFest2018
 
Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020Yung-Yu Chen
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...PROIDEA
 
Take advantage of C++ from Python
Take advantage of C++ from PythonTake advantage of C++ from Python
Take advantage of C++ from PythonYung-Yu Chen
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Max Kleiner
 
Garbage Collection
Garbage CollectionGarbage Collection
Garbage CollectionEelco Visser
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersAlessandro Sanino
 

Was ist angesagt? (20)

ROP
ROPROP
ROP
 
Sour Pickles
Sour PicklesSour Pickles
Sour Pickles
 
Go. why it goes v2
Go. why it goes v2Go. why it goes v2
Go. why it goes v2
 
Using Parallel Computing Platform - NHDNUG
Using Parallel Computing Platform - NHDNUGUsing Parallel Computing Platform - NHDNUG
Using Parallel Computing Platform - NHDNUG
 
Ekon bestof rtl_delphi
Ekon bestof rtl_delphiEkon bestof rtl_delphi
Ekon bestof rtl_delphi
 
Language-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible researchLanguage-agnostic data analysis workflows and reproducible research
Language-agnostic data analysis workflows and reproducible research
 
Tapp 13-talk
Tapp 13-talkTapp 13-talk
Tapp 13-talk
 
LeFlowを調べてみました
LeFlowを調べてみましたLeFlowを調べてみました
LeFlowを調べてみました
 
Declare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code GenerationDeclare Your Language: Virtual Machines & Code Generation
Declare Your Language: Virtual Machines & Code Generation
 
Functional programming in C++
Functional programming in C++Functional programming in C++
Functional programming in C++
 
Lisp for Python Programmers
Lisp for Python ProgrammersLisp for Python Programmers
Lisp for Python Programmers
 
A peek on numerical programming in perl and python e christopher dyken 2005
A peek on numerical programming in perl and python  e christopher dyken  2005A peek on numerical programming in perl and python  e christopher dyken  2005
A peek on numerical programming in perl and python e christopher dyken 2005
 
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
Mobile Fest 2018. Александр Сергиенко. Flutter - что за зверь такой?
 
Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020Notes about moving from python to c++ py contw 2020
Notes about moving from python to c++ py contw 2020
 
More on Lex
More on LexMore on Lex
More on Lex
 
4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...4Developers 2018: The turbulent road to byte-addressable storage support at t...
4Developers 2018: The turbulent road to byte-addressable storage support at t...
 
Take advantage of C++ from Python
Take advantage of C++ from PythonTake advantage of C++ from Python
Take advantage of C++ from Python
 
Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2Pascal script maxbox_ekon_14_2
Pascal script maxbox_ekon_14_2
 
Garbage Collection
Garbage CollectionGarbage Collection
Garbage Collection
 
The GO Language : From Beginners to Gophers
The GO Language : From Beginners to GophersThe GO Language : From Beginners to Gophers
The GO Language : From Beginners to Gophers
 

Andere mochten auch

My Action Comic
My Action ComicMy Action Comic
My Action Comicgiap_vn
 
Música clásica
Música clásicaMúsica clásica
Música clásicaElena19965
 
Virtual Medical Worlds for Team Training (please see updated version)
Virtual Medical Worlds for Team Training (please see updated version)Virtual Medical Worlds for Team Training (please see updated version)
Virtual Medical Worlds for Team Training (please see updated version)Parvati Dev
 
Pantallaso del computador
Pantallaso del computadorPantallaso del computador
Pantallaso del computadorMafe Velez
 
Альтернатива Климат - инженерно-строительная компания
Альтернатива Климат - инженерно-строительная компанияАльтернатива Климат - инженерно-строительная компания
Альтернатива Климат - инженерно-строительная компанияalternativa1234
 
Tony dochev resume 2015
Tony dochev resume 2015 Tony dochev resume 2015
Tony dochev resume 2015 Tony Dochev
 
Digital Trends - July 2016
Digital Trends - July 2016Digital Trends - July 2016
Digital Trends - July 2016Schbang
 
Bluff your way into visueel management
Bluff your way into visueel managementBluff your way into visueel management
Bluff your way into visueel managementBart Steenbergen
 
Saint Gobain November 2013
Saint Gobain November 2013Saint Gobain November 2013
Saint Gobain November 2013Paul Copcutt
 
D1 M4 U10 P7d EX POSSESSIVI
D1 M4 U10 P7d EX POSSESSIVID1 M4 U10 P7d EX POSSESSIVI
D1 M4 U10 P7d EX POSSESSIVIM. Magrini Kunze
 

Andere mochten auch (15)

My Action Comic
My Action ComicMy Action Comic
My Action Comic
 
Ddd
DddDdd
Ddd
 
Música clásica
Música clásicaMúsica clásica
Música clásica
 
Tecnologia
TecnologiaTecnologia
Tecnologia
 
Comprof
ComprofComprof
Comprof
 
Virtual Medical Worlds for Team Training (please see updated version)
Virtual Medical Worlds for Team Training (please see updated version)Virtual Medical Worlds for Team Training (please see updated version)
Virtual Medical Worlds for Team Training (please see updated version)
 
Pantallaso del computador
Pantallaso del computadorPantallaso del computador
Pantallaso del computador
 
Альтернатива Климат - инженерно-строительная компания
Альтернатива Климат - инженерно-строительная компанияАльтернатива Климат - инженерно-строительная компания
Альтернатива Климат - инженерно-строительная компания
 
Tony dochev resume 2015
Tony dochev resume 2015 Tony dochev resume 2015
Tony dochev resume 2015
 
Key
KeyKey
Key
 
Digital Trends - July 2016
Digital Trends - July 2016Digital Trends - July 2016
Digital Trends - July 2016
 
Bluff your way into visueel management
Bluff your way into visueel managementBluff your way into visueel management
Bluff your way into visueel management
 
Saint Gobain November 2013
Saint Gobain November 2013Saint Gobain November 2013
Saint Gobain November 2013
 
D1 M4 U10 P7d EX POSSESSIVI
D1 M4 U10 P7d EX POSSESSIVID1 M4 U10 P7d EX POSSESSIVI
D1 M4 U10 P7d EX POSSESSIVI
 
D2 M4 U9 P8F CONDIZIONALE
D2 M4 U9 P8F CONDIZIONALED2 M4 U9 P8F CONDIZIONALE
D2 M4 U9 P8F CONDIZIONALE
 

Ähnlich wie Use of Lua in Lab Devices

A brief history of Lua - Roberto Ierusalimschy (PUC Rio)
A brief history of Lua - Roberto  Ierusalimschy (PUC Rio)A brief history of Lua - Roberto  Ierusalimschy (PUC Rio)
A brief history of Lua - Roberto Ierusalimschy (PUC Rio)Kore VM
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()daewon jeong
 
Lua and fable jonathan shaw (lionhead)
Lua and fable   jonathan shaw (lionhead)Lua and fable   jonathan shaw (lionhead)
Lua and fable jonathan shaw (lionhead)Kore VM
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthingtonoscon2007
 
Lua by Ong Hean Kuan
Lua by Ong Hean KuanLua by Ong Hean Kuan
Lua by Ong Hean Kuanfossmy
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsMiles Sabin
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAdam Getchell
 
Julia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, StrongerJulia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, StrongerKenta Sato
 
The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...PVS-Studio
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on pythonShubham Yadav
 
A visual DSL toolkit in Lua: Past, present and future
A visual DSL toolkit in Lua: Past, present and futureA visual DSL toolkit in Lua: Past, present and future
A visual DSL toolkit in Lua: Past, present and futureAlexander Gladysh
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptanshikagoel52
 

Ähnlich wie Use of Lua in Lab Devices (20)

A brief history of Lua - Roberto Ierusalimschy (PUC Rio)
A brief history of Lua - Roberto  Ierusalimschy (PUC Rio)A brief history of Lua - Roberto  Ierusalimschy (PUC Rio)
A brief history of Lua - Roberto Ierusalimschy (PUC Rio)
 
20120710 - Lua_C
20120710 - Lua_C20120710 - Lua_C
20120710 - Lua_C
 
Scala is java8.next()
Scala is java8.next()Scala is java8.next()
Scala is java8.next()
 
Lua and fable jonathan shaw (lionhead)
Lua and fable   jonathan shaw (lionhead)Lua and fable   jonathan shaw (lionhead)
Lua and fable jonathan shaw (lionhead)
 
Os Worthington
Os WorthingtonOs Worthington
Os Worthington
 
Lua by Ong Hean Kuan
Lua by Ong Hean KuanLua by Ong Hean Kuan
Lua by Ong Hean Kuan
 
What`s New in Java 8
What`s New in Java 8What`s New in Java 8
What`s New in Java 8
 
An Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional ParadigmsAn Introduction to Scala - Blending OO and Functional Paradigms
An Introduction to Scala - Blending OO and Functional Paradigms
 
Introduction of Python
Introduction of PythonIntroduction of Python
Introduction of Python
 
An Overview Of Python With Functional Programming
An Overview Of Python With Functional ProgrammingAn Overview Of Python With Functional Programming
An Overview Of Python With Functional Programming
 
Julia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, StrongerJulia - Easier, Better, Faster, Stronger
Julia - Easier, Better, Faster, Stronger
 
The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...The use of the code analysis library OpenC++: modifications, improvements, er...
The use of the code analysis library OpenC++: modifications, improvements, er...
 
Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga Introduction to R software, by Leire ibaibarriaga
Introduction to R software, by Leire ibaibarriaga
 
Python Course.docx
Python Course.docxPython Course.docx
Python Course.docx
 
summer training report on python
summer training report on pythonsummer training report on python
summer training report on python
 
A visual DSL toolkit in Lua: Past, present and future
A visual DSL toolkit in Lua: Past, present and futureA visual DSL toolkit in Lua: Past, present and future
A visual DSL toolkit in Lua: Past, present and future
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1_R.ppt
Lecture1_R.pptLecture1_R.ppt
Lecture1_R.ppt
 
Lecture1 r
Lecture1 rLecture1 r
Lecture1 r
 
Modeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.pptModeling in R Programming Language for Beginers.ppt
Modeling in R Programming Language for Beginers.ppt
 

Kürzlich hochgeladen

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comFatema Valibhai
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Modelsaagamshah0812
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providermohitmore19
 

Kürzlich hochgeladen (20)

Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
HR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.comHR Software Buyers Guide in 2024 - HRSoftware.com
HR Software Buyers Guide in 2024 - HRSoftware.com
 
Unlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language ModelsUnlocking the Future of AI Agents with Large Language Models
Unlocking the Future of AI Agents with Large Language Models
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 

Use of Lua in Lab Devices

  • 1. Sample & Assay Technologies Use of Lua in Lab Devices Claus Kühnel, Daniel Zwirner, QIAGEN Instruments AGJanuary 2015 Lua is a powerful, light-weight programming language designed for extending applications. The language engine is accessible as a library, having a C API which allows the application to exchange data with Lua programs and also to extend Lua with C functions. Lua is also used as a general-purpose, stand-alone language through the simple command line interpreter provided.
  • 2. Sample & Assay Technologies 2 Initial Situation 2 Origin of Lua Lua is designed, implemented, and maintained by a team at PUC-Rio, the Pontifical Catholic University of Rio de Janeiro in Brazil. Lua was born in 1993 and raised in Tecgraf, formerly the Computer Graphics Technology Group of PUC-Rio. LabLua was founded on May 2004 by Prof. Roberto Ierusalimschy. Lua is now housed at LabLua, a laboratory of the Department of Computer Science of PUC- Rio. "Lua" (pronounced LOO-ah) means "Moon" in Portuguese.
  • 3. Sample & Assay Technologies 3 Initial Situation 3 Initial Situation Robotic Hardware (HAL) movexy(x,y) …. Biological Protocol Protocol Interpreter …. Robotic Platform
  • 4. Sample & Assay Technologies 4 • To execute “biological protocols” we need an protocol interpreter as a layer over the HAL • Should we develop the 1001. proprietary interpreter now? • Searching for a suitable solution leads us to Lua • A Friday afternoon was enough for installation and first tests • Culture shock for the proprietary fraction Initial Situation
  • 5. Sample & Assay Technologies 5 • Lua is a powerful, fast, lightweight, embeddable scripting language. • Lua combines simple procedural syntax with powerful data description constructs based on associative arrays and extensible semantics. • Lua is dynamically typed, runs by interpreting byte code for a register-based virtual machine, and has automatic memory management with incremental garbage collection, making it ideal for configuration, scripting, and rapid prototyping. What is Lua?
  • 6. Sample & Assay Technologies 6 • Lua is a proven, robust language used in applications like Adobe's Photoshop Lightroom, World of Warcraft & Angry Birds. • Lua is fast, portable, embeddable • Lua is powerful (but simple) • Lua is small. Under Linux, the Lua interpreter built with all standard Lua libraries takes 182 KB and the Lua library takes 244 KB. • Lua is well documented • Lua is free open-source software, distributed under the well-known MIT license • Runs on all common operating systems Why choose Lua?
  • 7. Sample & Assay Technologies 7 Lua Documentation
  • 8. Sample & Assay Technologies 8 Installing Lua (to get a playground) Lua for Windows Lua for Windows (LfW) combines Lua binaries, Lua libraries with a Lua-capable editor in a single install package for the MS Windows operating system. LfW contains everything you need to write, run and debug Lua scripts on Windows. A wide variety of libraries and examples are included that are ready to use with MS Windows. https://code.google.com/p/luaforwindows/ Lua for Linux (Debian) apt-get install lua5.1 apt-get install lua5.1-0-dev http://ckuehnel.ch/dokuwiki/doku.php?id=lua_on_bananapi
  • 9. Sample & Assay Technologies 10 Some Lua code function p(a) io.write(a .. ", type is " .. type(a) .. "n") end a = 123.45 p(a) -> 123.45, type is number a = "hello" p(a) -> hello, type is string a = 123+ "12" p(a) -> 135, type is number
  • 10. Sample & Assay Technologies 12 Returning multiple variables function f(a,b) return a, a*b, 5 end print(f(1,2)) -> 1 2 5 a,b,c = f(3,4) print(a,b,c) -> 3 12 5 t = {1,2} print(f(unpack(t))) -> 1 2 5
  • 11. Sample & Assay Technologies 14 Variable number of arguments function f(a,b, ...) print(a,b, unpack(arg)) end print(f(1,2)) -> 1 2 print(f(1,2,3)) -> 1 2 3 print(f(1,2, "Hi", " there")) -> 1 2 Hi there
  • 12. Sample & Assay Technologies 15 Set of functions that allow C to interact with Lua • Functions to read and write Lua global variables • Functions to call Lua functions • Functions to register C functions within Lua Stack-based parameter passing C Interface API
  • 13. Sample & Assay Technologies 16 Embedding Lua: • Lua is packed as a library. • The application calls lua_open to create and initializes a Lua state. • When the application is finished running Lua script it calls lua_close to finalize and destroy Lua state. Extending Lua: • The Lua API supports the extension of Lua state by the possibility to call C functions from Lua scripts. Embedding Lua vs. Extending Lua
  • 14. Sample & Assay Technologies 17 Lua Stack – LIFO principle C-> Lua Lua -> C void lua_pushnil() lua_isnil() void lua_pushboolean() int lua_toboolean void lua_pushnumber() double lua_tonumber void lua_pushstring() const char* lua_tostring void lua_pushlstring() size_t lua_strlen void lua_gettable void lua_settable
  • 15. Sample & Assay Technologies 18 Lua Stack – Pushing elements void lua_pushnil (lua_State *L) void lua_pushboolean (lua_State *L, int bool); void lua_pushnumber (lua_State *L, double n); void lua_pushlstring (lua_State *L, const char *s, size_t length); void lua_pushstring (lua_State *L, const char *s);
  • 16. Sample & Assay Technologies 19 Lua Stack – Query elements int lua_toboolean (lua_State *L, int index) double lua_tonumber (lua_State *L, int index) const char * lua_tostring (lua_State *L, int index) size_t lua_strlen (lua_State *L, int index);
  • 17. Sample & Assay Technologies 20 Lua Stack – other stack operations void lua_pop (lua_State *L, int number) int lua_gettop (lua_State *L) void lua_settop (lua_State *L, int index) void lua_pushvalue (lua_State *L, int index) void lua_remove (lua_State *L, int index) void lua_insert (lua_State *L, int index) void lua_replace (lua_State *L, int index);
  • 18. Sample & Assay Technologies 21 Enhancing Lua by C functions http://ckuehnel.ch/dokuwiki/doku.php?id=lua_erweiterung Embedding Lua in a C application http://ckuehnel.ch/dokuwiki/doku.php?id=lua_embedding
  • 19. Sample & Assay Technologies 22 Wrapper SWIG is a software development tool that connects programs written in C and C++ with a variety of high-level programming languages. http://www.swig.org/ tolua is a tool that greatly simplifies the integration of C/C++ code with Lua. Based on a cleaned header file, tolua automatically generates the binding code to access C/C++ features from Lua http://webserver2.tecgraf.puc-rio.br/~celes/tolua/ Look for examples to both wrappers in our book.
  • 20. Sample & Assay Technologies 23 Lua in a Lab Device HAL movexy(x,y) …. GUI movexy(x,y) …. Lua VM …. Robotic Platform Lua enhanced by C/C++ functions (HAL) Lua embedded in C/C++ application (GUI)
  • 21. Sample & Assay Technologies INSTRUMENT init()… 24 Lua in a Lab Device – some code HAL init() GUI pushButtonInitPressed() …. LuaVM run()… luaopen_cube() … Robotic Platform Lua embedded in C/C++ application (GUI) Lua enhanced by C/C++ functions (HAL) Code sample:http://ckuehnel.ch/dokuwiki/doku.php?id=lua_lab_device