Top Banner
CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno System Integrator: Daron Lin System Tester: Minghai (Ocean) Huang
41

CoZy: A very cool language for temperature control Project Manager: Hannah Keiler Language and Tools Guru: Nate Booth System Architect: Giovanni Ortuno.

Dec 31, 2015

Download

Documents

Melissa Nichols
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

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.

Check us out on Github!

https://github.com/oceanhuang/CoZy