1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Furkat [3]
3 years ago
5

2. From the listing code, please give the block of line numbers for code which are concerned with the following: A) Main functio

n initialization of values B) Main function idle loop C) Main function schedule loop has already been moved to the ISR, but give those numbers too.
Computers and Technology
1 answer:
arsen [322]3 years ago
7 0

Answer:

Complete question is:

When the C-language code is generated, -1 is used to create the initialization state for each of the Tick

functions.

The challenge is if this code is used with C++ compiler, there is an incorrect mix between integer and

the enum data types.

1. Take the generated C code, edit it, and

replace the -1 state with an enum data type state

so it will

compile properly.

2. Replace the integer notation for the call and return arguments for Tick functions where they should

also be the enum data types.

2. From the listing lines of code, please give the line numbers for code which are concerned with the

following:

A)

Main function initialization of values

B)

Main function idle loop

C)

Main function schedule loop has already been moved to the ISR, but give those numbers too.

This action is required when moving this state machine model to a C++ GUI system.

Submit the C code with the corrections made

and this is my code

/*

This code was automatically generated using the Riverside-Irvine State machine Builder tool

Version 2.8 --- 6/23/2015 16:19:15 PST

*/

#include "rims.h"

/*This code will be shared between state machines.*/

unsigned char TimerFlag = 0;

void TimerISR() {

TimerFlag = 1;

}

enum BL_States { BL_LedOff, BL_LedOn } BL_State;

TickFct_BlinkLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(BL_State) { // Transitions

case -1:

BL_State = BL_LedOff;

break;

case BL_LedOff:

if (1) {

BL_State = BL_LedOn;

}

break;

case BL_LedOn:

if (1) {

BL_State = BL_LedOff;

}

break;

default:

BL_State = BL_LedOff;

} // Transitions

switch(BL_State) { // State actions

case BL_LedOff:

B0= 0;

break;

case BL_LedOn:

B0 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

enum TL_States { TL_T0, TL_T1, TL_T2 } TL_State;

TickFct_ThreeLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(TL_State) { // Transitions

case -1:

TL_State = TL_T0;

break;

case TL_T0:

if (1) {

TL_State = TL_T1;

}

break;

case TL_T1:

if (1) {

TL_State = TL_T2;

}

break;

case TL_T2:

if (1) {

TL_State = TL_T0;

}

break;

default:

TL_State = TL_T0;

} // Transitions

switch(TL_State) { // State actions

case TL_T0:

B5 = 1;

B6 = 0;

B7 = 0;

break;

case TL_T1:

B5 = 0;

B6 = 1;

B7 = 0;

break;

case TL_T2:

B5 = 0;

B5 = 0;

B5 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

int main() {

B = 0; //Init outputs

TimerSet(1000);

TimerOn();

BL_State = -1;

TL_State = -1;

while(1) {

TickFct_BlinkLeds();

TickFct_ThreeLeds();

while (!TimerFlag);

TimerFlag = 0;

}

}

Answer is:

#include "rims.h"

/*This code will be shared between state machines.*/

unsigned char TimerFlag = 0;

void TimerISR() {

TimerFlag = 1;

}

enum BL_States { BL_LedOff, BL_LedOn, BL_LedOnOff } BL_State;

TickFct_BlinkLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(BL_State) { // Transitions

case BL_LedOnOff:

BL_State = BL_LedOff;

break;

case BL_LedOff:

if (BL_LedOn) {

BL_State = BL_LedOn;

}

break;

case BL_LedOn:

if (true) {

BL_State = BL_LedOff;

}

break;

default:

BL_State = BL_LedOff;

} // Transitions

switch(BL_State) { // State actions

case BL_LedOff:

B0= 0;

break;

case BL_LedOn:

B0 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

enum TL_States { TL_T0, TL_T1, TL_T2 } TL_State;

TickFct_ThreeLeds() {

/*VARIABLES MUST BE DECLARED STATIC*/

/*e.g., static int x = 0;*/

/*Define user variables for this state machine here. No functions; make them global.*/

switch(TL_State) { // Transitions

case BL_LedOnOff:

TL_State = TL_T0;

break;

case TL_T0:

if (1) {

TL_State = TL_T1;

}

break;

case TL_T1:

if (true) {

TL_State = TL_T2;

}

break;

case TL_T2:

if (true) {

TL_State = TL_T0;

}

break;

default:

TL_State = TL_T0;

} // Transitions

switch(TL_State) { // State actions

case TL_T0:

B5 = 1;

B6 = 0;

B7 = 0;

break;

case TL_T1:

B5 = 0;

B6 = 1;

B7 = 0;

break;

case TL_T2:

B5 = 0;

B5 = 0;

B5 = 1;

break;

default: // ADD default behaviour below

break;

} // State actions

}

int main() {

B = 0; //Init outputs

TimerSet(1000);

TimerOn();

BL_State = -1;

TL_State = -1;

while(1) {

TickFct_BlinkLeds();

TickFct_ThreeLeds();

while (!TimerFlag);

TimerFlag = 0;

}

}

Explanation:

You might be interested in
What can a user modify on a business card using the Edit Business Card dialog box? Check all that apply.
vredina [299]

Answer:

layout,image,font,background color,

Explanation: i just did it on edge

7 0
2 years ago
Subscribe to epic beast brothers thank you
nikdorinn [45]
No ono moñón Ik Jkjkjk
5 0
3 years ago
Write the definition of a function that takes as input the three numbers. The function returns true if the first number to the p
sattari [20]

Answer:

I am writing a C++ program.

Here is the function CheckPower() which is a bool return type function which means it will return either true of false. This function has three double type parameters. This function returns true if the first number to the power of the second number equals the third number; otherwise, it returns false.

bool CheckPower(double number1, double number2, double number3)

{

   double power; // stores value of number1 to the power number2

   power = pow(number1,number2); // pow() function to computer power

   if (power==number3) // if the value of power is equal to third no number3

       return true; // returns true

   else // if above condition evaluate to false then returns false

       return false;

}

Explanation:

Lets take the values of number1 = 3, number2 = 2 and number3 = 9 to understand the above function.

The pow() function is a power function to calculate the result of number1 raised to the power of number2. Here number1 is the base number and number2 is exponent number. As number1 = 3 and number2 = 2 so this is equivalent to 3² . So 3 raise to the power 2 is 9. The value stored in power is 9.

power = 9

Next, the if condition checks if the value in power is equal to the value of number3. The value of number3 is 9 and the value in power variable is also 9 so the If condition evaluates to true. So the if part is executed which returns true.

If the value of number3 is, lets say, 10 then the If condition evaluates false as the value of power is not equal to value of number3. So the else part is executed which returns false.

If you want to see the output of this function you can write a main() function as following:

int main()

{   double num1, num2, num3;

   cout << "enter first number: ";

   cin >> num1;

   cout << "enter second number: ";

   cin >> num2;

   cout << "enter third number: ";

   cin >> num3;

   if(CheckPower(num1, num2, num3))

   { cout<<"True";    }

   else

   { cout<<"False";  }    }

This is a main() function which asks the user to enter the values of three numbers num1, num2 and num3. The if condition calls CheckPower() function to check if the first number to the power of the second number equals the third number. If this condition evaluates to true, the message True is displayed on the screen otherwise message False is displayed on output screen.

The screen shot of program along with its output is attached.

3 0
3 years ago
Which statement best describes the difference between a spreadsheet and a database?
Dmitrij [34]

Answer:

Databases store data in tables that interact; spreadsheets store data in cells that interact.

Explanation:

3 0
2 years ago
Read 2 more answers
Convert infix to postfix
kvv77 [185]

Answer:

static int checkSymbol(char ch)

{

switch (ch)

{

case '+':

case '-':

return 1;

case '*':

case '/':

return 2;

case '^':

return 3;

}

return -1;

}

static String convertInfixToPostfix(String expression)

{

String calculation = new String("");

Stack<Character> operands = new Stack<>();

Stack<Character> operators = new Stack<>();

 

for (int i = 0; i<expression.length(); ++i)

{

char c = expression.charAt(i);

if (Character.isLetterOrDigit(c))

operands.push(c);

else if (c == '(')

operators.push(c);

 

else if (c == ')')

{

while (!operators.isEmpty() && operators.peek() != '(')

operands.push(operators.pop());

 

if (!operators.isEmpty() && operators.peek() != '(')

return NULL;    

else

operators.pop();

}

else

{

while (!operators.isEmpty() && checkSymbol(c) <= checkSymbol(operators.peek()))

operands.push(operators.pop());

operators.push(c);

}

}

while (!operators.isEmpty())

operands.push(operators.pop());

while (!operands.isEmpty())

calculation+=operands.pop();

calculation=calculation.reverse();

return calculation;

}

Explanation:

  • Create the checkSymbol function to see what symbol is being passed to the stack.
  • Create the convertInfixToPostfix function that keeps track of the operands and the operators stack.
  • Use conditional statements to check whether the character being passed is a letter, digit, symbol or a bracket.
  • While the operators is  not empty, keep pushing the character to the operators stack.
  • At last reverse and return the calculation which has all the results.
4 0
2 years ago
Other questions:
  • In what ways are Outlook notes useful for personal or professional use? Check all that apply.
    13·2 answers
  • What do these terms have in common? google, yahoo!, bing they are important books. they are internet search engines. they are wo
    10·1 answer
  • Which of these is a Microsoft certification for system engineers?
    9·1 answer
  • ______ is a type of computer software that is installed into devices such as printers, print servers, and various types of commu
    5·1 answer
  • Three common risk factors for young drivers and how you plan to minimize these factors.
    13·1 answer
  • ---------------------- use of the Internet to access programs and data on computers that are not owned and managed by the user o
    9·1 answer
  • Enthusiasm codehs 7.6.4 Write a function called add_enthusiasm that takes a string and returns that string in all uppercase with
    15·1 answer
  • 9. Themes can be modified using variants. *<br><br>True<br>False​
    7·2 answers
  • GIVING OUT BRAINLIEST AND I AM ALSO WARNING EVERYONE TO NOT ANSWER A BUNCH OF rubbish just to get the points!
    7·2 answers
  • a(n) is an object that defines a screen element used to display information or allow the user to interact with a program in a ce
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!