Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A class CMotor shall be designed, to control a Motor. There is a given POSIX device Motor, that can be opened, read, written and closed.

image text in transcribed

A class CMotor shall be designed, to control a Motor. There is a given POSIX device "Motor", that can be opened, read, written and closed. By writing an integer, the RPM (number of revolutions) is controlled, by reading an integer, you can read the temperature of the Motor. The class CMotor has a ctor and a setget function with 2 parameters, a requested rpm and the cur- rent temperature. The Motor must not overheat, so whenever the setget function is called, first the temperature is read and checked. If it exceeds a maximum (const double Attribute), then the function switches off the Motor and returns false and the actual temperature value. If a change of rpm is written, the Motor is set in rpm steps of 100. For example, if the Motor Spins with 1000 rpm and shall change to-200 rpm, the function sets steps 900, 800...0.-100,-200 and re- turns only then with true. After each step, the function should sleep for 50 msecs. 1. Declare the class CMotor with all methods and attributes. 2. Implement the ctor of the class and initialize all attributes and open the Motor device. 3. Implement the dtor of the class. 4. Implement the setget method. A class CMotor shall be designed, to control a Motor. There is a given POSIX device "Motor", that can be opened, read, written and closed. By writing an integer, the RPM (number of revolutions) is controlled, by reading an integer, you can read the temperature of the Motor. The class CMotor has a ctor and a setget function with 2 parameters, a requested rpm and the cur- rent temperature. The Motor must not overheat, so whenever the setget function is called, first the temperature is read and checked. If it exceeds a maximum (const double Attribute), then the function switches off the Motor and returns false and the actual temperature value. If a change of rpm is written, the Motor is set in rpm steps of 100. For example, if the Motor Spins with 1000 rpm and shall change to-200 rpm, the function sets steps 900, 800...0.-100,-200 and re- turns only then with true. After each step, the function should sleep for 50 msecs. 1. Declare the class CMotor with all methods and attributes. 2. Implement the ctor of the class and initialize all attributes and open the Motor device. 3. Implement the dtor of the class. 4. Implement the setget method

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Employee Relations Audits

Authors: C. Jennings, W. E. J. McCarthy, R. Undy

1st Edition

0415786614, 978-0415786614

More Books

Students also viewed these Accounting questions