cozy: a very cool language for temperature control project manager: hannah keiler language and tools...
TRANSCRIPT
![Page 1: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/1.jpg)
CoZy: A very cool language for temperature
control Project Manager: Hannah Keiler
Language and Tools Guru: Nate BoothSystem Architect: Giovanni Ortuno
System Integrator: Daron LinSystem Tester: Minghai (Ocean) Huang
![Page 2: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/2.jpg)
CoZy schedules thermostats!
“I’ll be away and want to turn my AC down”
www.classroomclipart.com, home.howstuffworks.com
![Page 3: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/3.jpg)
But so do programmable thermostats...
![Page 4: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/4.jpg)
Why is CoZy a better solution?
- Cost: 26% of the cost of Nest
- Freedom!
vs
![Page 5: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/5.jpg)
Buzzwords
● User Oriented!● Simple ● Intuitive ● Readable ● Specific
every(Sunday):SET_TEMP(27
C)
![Page 6: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/6.jpg)
Buzzwords
● User Oriented!● Simple ● Intuitive ● Readable ● Specific
● Statically typed ● Architecture neutral ● Portable - Compiles to Python to run on
raspberry pi● Robust
every(Sunday):SET_TEMP(27
C)
![Page 7: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/7.jpg)
Language Features
![Page 8: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/8.jpg)
Normal features
● Functions● Lists● Type checking● Lexical scoping● Arithmetic● Logic● Control flow● print● log to file
Borrrrrrrrrrrring...
![Page 9: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/9.jpg)
Special features!
● “every” statements● “once every”
statements● time ranges are
primitive types● temperature is
primitive type● interacts nicely with
temperature sensor● interacts nicely with
“heater”
Now this is cool!
![Page 10: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/10.jpg)
every statements
● Run consistently every time their date/time condition is met
● If you want it to run at two different sets of times, separate them by semicolon
● If you want it to run when two date/time conditions are both met, separate by “during”
![Page 11: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/11.jpg)
every statement example
● Prints “hello” from 2:45 PM to 6:50 PM and from ___ to ___ every day
● On Mondays, also prints “goodbye” from 2:00 PM to 6:52 PM
![Page 12: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/12.jpg)
every statement example
helloText = “hello”goodbyeText = “goodbye”every (2:45 PM to 6:50 PM; 6:53 PM to 11:00 PM): print(helloText)every (2:00 PM to 6:52 PM during Tuesday): print(goodbyeText)
![Page 13: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/13.jpg)
once every statements
● Run once each time their date/time condition is met
● If you want it to run at two different sets of times, separate them by semicolon
● If you want it to run when two date/time conditions are both met, separate by “during”
![Page 14: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/14.jpg)
once every statement example
helloText = “hello”goodbyeText = “goodbye”once every (2:45 PM to 6:50 PM; 6:53 PM to 11:00 PM): print(helloText)once every (2:00 PM to 6:52 PM during Tuesday): print(goodbyeText)
![Page 15: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/15.jpg)
How did this all come together?
Lexical Analyzer, Parser, Code Generator
Added features
Semantic Analyzer
![Page 16: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/16.jpg)
How did this all come together?
- Communication
- Meeting Minutes - Tasks - Deliverables
- Version Control- Reporting Bugs
![Page 17: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/17.jpg)
Architecture
![Page 18: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/18.jpg)
Architecture Overview
➔ Cozy File◆ file.cz
➔ Lexer◆ cozyLex.py
➔ Parser◆ cozyYacc.py
➔ Code Gen◆ codeGenerator.py
➔ Execute Code◆ runCozy.py
Semantic Analyzer + Code
Generator
Lexical Analyzer
Token Stream
Syntax Analyzer
Syntax Tree
CoZy Source Code
Python Code
![Page 19: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/19.jpg)
Cozy Code to Token StreamLexToken(DEF,'def',2,1)LexToken(ID,'myFunction',2,5)LexToken(LPAREN,'(',2,15)LexToken(RPAREN,')',2,16)LexToken(COLON,':',2,17)LexToken(NEWLINE,'\n',2,18)INDENTLexToken(IF,'if',3,23)LexToken(LPAREN,'(',3,25)LexToken(MONDAY,'Monday',3,26)……..
def myFunction(): if(Monday): print(“It's MONDAY!!”) else: print("It's not Monday YAAY")once every(January): every(10:00 AM to 11:00 PM): myFunction()
cozyLex.py
![Page 20: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/20.jpg)
Token Stream to Abstract Syntax Tree
LexToken(DEF,'def',2,1)LexToken(ID,'myFunction',2,5)LexToken(LPAREN,'(',2,15)LexToken(RPAREN,')',2,16)LexToken(COLON,':',2,17)LexToken(NEWLINE,'\n',2,18)INDENTLexToken(IF,'if',3,23)LexToken(LPAREN,'(',3,25)LexToken(MONDAY,'Monday',3,26)……..
program>program->external_declaration-->function_definition: 'myFunction'--->statement_list---->statement----->selection_statement------>or_expression------->and_expression-------->equality_expression……..
cozyYacc.py
![Page 21: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/21.jpg)
AST to Code
program>program->external_declaration-->function_definition: 'myFunction'--->statement_list---->statement----->selection_statement------>or_expression------->and_expression-------->equality_expression……..
….if(datetime.datetime.now().weekday() == 0):print "OH NO IT"S MONDAY!!"else: print "It's not monday yaay"….def condition1(): if ((datetime.datetime.now().weekday() == 1) and (datetime.datetime(100,1,1,10, 0))): return True…...
codeGenerator.py
![Page 22: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/22.jpg)
Dev Environment
![Page 23: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/23.jpg)
Development Environment
Unfortunately, diversity isn’t always great.
+ + = :(
![Page 24: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/24.jpg)
Development Environment
It was difficult, but we made it work.
![Page 25: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/25.jpg)
Development Environment
,
![Page 26: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/26.jpg)
Development Environment
,
![Page 27: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/27.jpg)
Other Tools
![Page 28: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/28.jpg)
Version Control - Philosophy
1. Thou shalt not dirty the master branch.2. Thou shalt pull, and pull often.
![Page 29: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/29.jpg)
Runtime Environment
CoZy src TargetProgram Python
Raspbian OSpython-rpi.gpio
CoZy CompilerPython Interpreeter
![Page 30: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/30.jpg)
Runtime Environment
CoZy comes with:cozyLex.pycozyYacc.pycodeGenerator.pyrunCozy.pyTemperature.pyruntimeError.pyr_pi/Fake_Thermostat.pyr_pi/Thermostat.pyr_pi/fake_temp
![Page 31: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/31.jpg)
Compiler Tools
PLY (Python Lex-Yacc)
Ultimately helped create an AST for us
![Page 32: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/32.jpg)
Running CoZy
Download CoZy.tar.gz$ tar xvzf CoZy.tar.gz$ cd CoZy$ ./setup$ create super awesome CoZy program$ ./CoZy myAwesomeCoZy.czOR$ ./CoZy my AwesomeCoZy.cz -o
![Page 33: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/33.jpg)
Testing Plan
![Page 34: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/34.jpg)
Testing Plan
General Testing Plan
Evolution of the Testing Suite
![Page 35: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/35.jpg)
General Testing Plan
Production Branch
Feature Branch
Feature Branch
Feature Branch
Feature Branch
Feature Branch
...
Individual-testing / Pull Request / Peer-testing
![Page 36: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/36.jpg)
Testing Suite - Early
inline testing in yacc.py and lex.pypro: fast / easy to implementcon: difficult to add multiple test cases
![Page 37: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/37.jpg)
Testing Suite: Intermediate
One script to run all test casespro: easy to add test casescon: lost track of test cases
if one test case failed, others don’t execute
implemented continuous loop
simply append new test case to end
![Page 38: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/38.jpg)
Testing Suite: Final
Wrapped the previous python script inside a shell script- one directory, each test case in separate file- pro: easy to keep track of test cases now
![Page 39: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/39.jpg)
DEMO
![Page 40: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/40.jpg)
Take-Aways
What we wish we did:●Became comfortable with git/ Github early
●Developed more tests
What we’re glad we did:●Regular meetings ●Developing base and building features on top
![Page 41: CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno](https://reader035.vdocuments.mx/reader035/viewer/2022062517/56649eb55503460f94bbec7d/html5/thumbnails/41.jpg)
Check us out on Github!
https://github.com/oceanhuang/CoZy