Question

Shapes Cube, Cuboid, Sphere, Cylinder, Cone Colors Red, Green, Blue, Black This controller shall have the follow modules: 3-D object printing: This printer reads 3-D object data (including shape, color, and dimensions) from user and print one object 3-D objects statistics: All 3-D objects data shall be stored properly to allow user to retrieve their statistics. For example, the following are some typical statistics user would be interested in o What is the percentage of each color of printed objects? o What is the most popular 3-D shape being printed? o What is the most common object size (small, medium, large, and huge by volume)? . Material inventory control: Since raw materials in the four colors would be consumed during the 3-D object printing process, this controller shall be able to track, display, and restock the raw materials. For example, if the user wants to print one red cube and the remaining red material is less than the computed cubes volume, controller shall either cancel this printing task or prompt user to restock Project Submission Interim Project Report o Brief description on: a) the functionalities that will be provided in the 3-D object statistics and material inventory control modules; and b) the data structure and organization needed to support these functionalities. Final Project Report o Complete report with full 3-D printer controller design, working source codes, adequate test cases, discussion and/or conclusion. Actually, the controller just prints message of object is being printed. But, the raw material consumed shall be deducted from the corresponding colors inventory E245

media%2F03d%2F03d4cd48-5cda-47b9-b974-06

media%2Fa6e%2Fa6ea1a72-ede8-4cd5-8882-5e

media%2F9d1%2F9d1f939e-9e68-4473-8be1-47

0 0
Add a comment Improve this question Transcribed image text
Answer #1

As per the given details the program should be as follows:

# Redistribution and use in source and binary forms, with or without

# modification, are permitted provided that the following conditions are met:

# 1. Redistributions of source code must retain the above copyright

# notice, this list of conditions and the following disclaimer.

# 2. Redistributions in binary form must reproduce the above copyright

# notice, this list of conditions and the following disclaimer in the

# documentation and/or other materials provided with the distribution.

#

# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND

# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED

# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE

# DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY

# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES

# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;

# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND

# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT

# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS

# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

from _future_ import print_function

from _future_ import with_statement

import struct

class GcodeSyntaxError(Exception):

pass

EncodeLineErrors = GcodeSyntaxError

def encode_line(line):

comment_index = line.find(';')

if comment_index >= 0:

line = line[:comment_index]

line = line.strip()

if len(line) == 0:

return ''

parts = line.split()

cmd_letter = parts[0][0]

if cmd_letter == 'E':

return chr(0xE0)

if not _letter_ok(cmd_letter):

raise GcodeSyntaxError('invalid command letter')

try:

cmd_number = int(parts[0][1:])

except ValueError:

raise GcodeSyntaxError('invalid command number')

if not (cmd_number >= 0 and cmd_number < 2048):

raise GcodeSyntaxError('invalid command number')

packet_index = ''

packet_payload = ''

num_params = len(parts) - 1

if num_params > 14:

raise GcodeSyntaxError('too many parameters')

for part in parts[1:]:

param_letter = part[0]

if not _letter_ok(param_letter):

raise GcodeSyntaxError('invalid parameter letter')

param_value = part[1:]

if param_value == '':

encode_as = 'void'

else:

encode_as = 'integer'

try:

integer_value = int(param_value)

if not (integer_value >= 0 and integer_value < 2**64):

raise ValueError()

except ValueError:

encode_as = 'real'

try:

real_value = float(param_value)

except ValueError:

raise GcodeSyntaxError('invalid command argument')

if encode_as == 'void':

type_code = 5

param_payload = ''

elif encode_as == 'integer':

if integer_value < 2**32:

type_code = 3

param_payload = struct.pack('<I', integer_value)

else:

type_code = 4

param_payload = struct.pack('<Q', integer_value)

elif encode_as == 'real':

type_code = 1

param_payload = struct.pack('<f', real_value)

packet_index += chr((type_code << 5) + (ord(param_letter) - ord('A')))

packet_payload += param_payload

if (cmd_letter, cmd_number) in _SmallCommands:

command_type_code = _SmallCommands[(cmd_letter, cmd_number)]

packet_header_large = ''

else:

command_type_code = 15

packet_header_large = struct.pack('BB', ((ord(cmd_letter) - ord('A')) << 3) + (cmd_number >> 8), (cmd_number & 0xFF))

packet_header = struct.pack('B', (command_type_code << 4) + num_params) + packet_header_large

packet = packet_header + packet_index + packet_payload

return packet

EncodeFileErrors = (IOError, GcodeSyntaxError)

def encode_file(input_file_name, output_file_name):

line_num = 0

with open(input_file_name, "r") as input_file:

with open(output_file_name, "w") as output_file:

for line in input_file:

line_num += 1

try:

encoded_data = encode_line(line)

except GcodeSyntaxError as e:

e.args = ('line {}: {}'.format(line_num, e.args[0]),)

raise

output_file.write(encoded_data)

output_file.write(chr(0xE0))

_SmallCommands = {

('G', 0) : 1,

('G', 1) : 2,

('G', 92) : 3

}

def _letter_ok(ch):

return (ord(ch) >= ord('A') and ord(ch) <= ord('Z'))

def main():

import argparse

parser = argparse.ArgumentParser(description='G-code packet for APrinter firmware.')

parser.add_argument('--input', required=True)

parser.add_argument('--output', required=True)

args = parser.parse_args()

encode_file(args.input, args.output)

if _name_ == '_main_':

main()

Hope you understand the program and let me know the doubts in the comments below. HAVE A NICE DAY!

Add a comment
Know the answer?
Add Answer to:
Shapes Cube, Cuboid, Sphere, Cylinder, Cone Colors Red, Green, Blue, Black This controller shall have the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT