Coder Social home page Coder Social logo

hotelelectricityautomation's Introduction

HotelElectricityAutomation

Problem Statement:

A very prestigious chain of hotels is facing a problem of huge consumption of electricity bills for its electronic equipments. The common equipments, like lights, ACs, etc are currently controlled manually, by the hotel staff, using manual switches. Hotel Management wants to optimise the usage of electricity consumption and also ensure that there is no inconvenience caused to the guests and staff. So, it has installed Motion Sensors at appropriate places and have approached you to program a Controller which takes inputs from these sensors and controls various equipments. The way the hotel equipments are organised and the requirements for the Controller are listed below:

● A Hotel can have multiple floors

● Each floor can have multiple main corridors and sub corridors

● Both main corridor and sub corridor have one light each

● Both main and sub corridor lights consume 5 units of power when ON

● Both main and sub corridor have independently controllable ACs

● Both main and sub corridor ACs consume 10 units of power when ON

● All the lights in all the main corridors need to be switched ON between 6PM to 6AM, which is the Night Time slot

● By default, all ACs are switched ON, all the time

● When a motion is detected in one of the sub corridors the corresponding lights need to be switched ON between 6PM to 6AM (Night Time slot)

● The total power consumption of all the ACs and lights combined should not exceed (Number of Main corridors * 15) + (Number of sub corridors * 10) units of per floor. Sub corridor AC could be switched OFF to ensure that the power consumption is not more than the specified maximum value

● When there is no motion for more than a minute the sub corridor lights should be switched OFF and AC needs to be switched ON Motion in sub-corridors is input to the controller, which needs to keep track and optimise the power consumption.

This program takes input values for Floors, Main corridors, Sub corridors and takes different external inputs for motion in sub corridors. For each input, the program prints out the state of all the lights and ACs in the hotel. For simplicity, assume that the controller is operating at the Night Time

Sample input and output below -

● Number of floors: 2

● Main corridors per floor: 1

● Sub corridors per floor: 2

Subsequent Inputs from Sensors Output from controller for corresponding sensor input Default state (when the program is first run) Floor 1

Main corridor 1 Light 1 : ON AC : ON

Sub corridor 1 Light 1 : OFF AC : ON

Sub corridor 2 Light 2 : OFF AC : ON

Floor 2

Main corridor 1 Light 1 : ON AC : ON

Sub corridor 1 Light 1 : OFF AC : ON

Sub corridor 2 Light 2 : OFF AC : ON

Movement in Floor 1, Subcorridor 2

Floor 1

Main corridor 1 Light 1 : ON AC : ON

Sub corridor 1 Light 1 : OFF AC : OFF

Sub corridor 2 Light 2 : ON​ AC : ON

Floor 2

Main corridor 1 Light 1 : ON AC : ON

Sub corridor 1 Light 1 : OFF AC : ON

Sub corridor 2 Light 2 : OFF AC : ON

No movement in Floor 1,

Sub corridor 2 for a minute

Floor 1

Main corridor 1 Light 1 : ON AC : ON

Sub corridor 1 Light 1 : OFF AC : ON

Sub corridor 2 Light 2 : OFF​ AC : ON

Floor 2

Main corridor 1 Light 1 : ON AC : ON

Sub corridor 1 Light 1 : OFF AC : ON

Sub corridor 2 Light 2 : OFF AC : ON

How to run Test Case (RSpec) reference link

gem install rspec

$ rspec specs_hotel_automation.rb

hotelelectricityautomation's People

Contributors

nikhilthombare 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.