Example #1
0
def build_module(template_file):
    # This is how the program will be called if BuildPCB.py was just executed.
    global logger
    logger = setup_logger("BuildModule.log", "module_log")
    logger.info("Replacing stock Ara template components...")
    ara_data = parse_partfile(template_file)
    replace(ara_data)
Example #2
0
def interference_check(objects, modelname):
    """
        Checks for any interferences between list of objects.
        Formulates report whether interferences or not.
        Coincidence is not interference.
    """

    interfere_log = setup_logger("interference_report.log", 'interfere_log')
    start_checking = time.clock()
    interfere_log.info("INTERFERENCE CHECK REPORT FOR {0}".format(modelname))
    interfere_log.info("")

    interferences = 0
    checked_components = []
    for obj in objects:
        # Check interferences between this part and any other in the list
        for checkobj in [o for o in objects if o != obj]:

            # Don't want to check interference of identical components multiple times...
            if sorted([obj, checkobj]) in checked_components:
                continue

            objmesh = obj.isDerivedFrom("Mesh::Feature")
            checkobjmesh = checkobj.isDerivedFrom("Mesh::Feature")
            if objmesh and checkobjmesh:
                common = obj.Mesh.intersect(checkobj.Mesh)
            elif objmesh != checkobjmesh:
                logger.warning("Parts {0} and {1} are of different type. Cannot check, skipping.")
                continue;
            else:
                common = obj.Shape.common(checkobj.Shape)

            if common.Volume != 0.0:
                interferences += 1
                interfere_log.info("Interference detected!")
                interfere_log.info("Component 1: {0}".format(obj.Label))
                interfere_log.info("Component 2: {0}".format(checkobj.Label))
                interfere_log.info("Overlapping volume: {0}".format(common.Volume))
                interfere_log.info("")

            checked_components.append([obj, checkobj])

    interfere_log.info("Interference check complete.")
    interfere_log.info("Execution time: {0}".format(time.clock() - start_checking))
    if interferences == 0:
        interfere_log.info("No interferences detected!")
    else:
        interfere_log.info("Total number of interferences: {0}".format(interferences))
def main():
    from optparse import OptionParser
    parser = OptionParser()
    options = add_options(parser)
    
    debug_log_path = './log/CAD_update_testbench_manifest.log'
    if not os.path.exists('./log'):
        os.makedirs('./log')
    else:
        if os.path.exists(debug_log_path):
            os.remove(debug_log_path)
            
    logger = utility_functions.setup_logger(debug_log_path)

    result_json = {}

    resultmanifest_file = 'testbench_manifest.json'
    if os.path.exists(resultmanifest_file):
        # read current summary report, which contains the metrics
        with open(resultmanifest_file,'r') as file_in:
            result_json = json.load(file_in)

        # update analysis status
        if 'Status' in result_json:
            if os.path.exists('_FAILED.txt'):
                result_json['Status'] = 'FAILED'
            else:
                    result_json['Status'] = 'OK'
        else:
            logger.debug('%s does not contain Status' %(resultmanifest_file))
        
        metrics_file = options.metricfile

        if os.path.exists(metrics_file):
            Parsed_ComputedValueList = dict()
            Parsed_ComputedValueList = ComputedMetricsSummary.ParseXMLFile(metrics_file)
            #print (ComputedMetricsSummary.gMetricSummary)

            if 'Metrics' in result_json:
                for metric in result_json['Metrics']:
                    if 'Name' in metric and 'Value' in metric and 'GMEID' in metric:
                        key = metric['GMEID']
                        if ComputedMetricsSummary.gMetricSummary.has_key(key):
                            # update metric's value to the last value in
                            # time series
                            metric['Value'] = ComputedMetricsSummary.gMetricSummary[key][1]
                            metric['Unit'] = ComputedMetricsSummary.gMetricSummary[key][0]
                            logger.debug('Metric: {0} {1} {2} was updated.'.format(metric['Name'],
                                                                                   metric['Value'],
                                                                                   metric['Unit']))

                        else:
                            # metric was not found in results
                            logger.debug('ComputedMetrics.xml key error: {0}'.format(key))
            else:
                # create warning message
                logger.debug('% does not contain Metrics' %(resultmanifest_file))
        else:
            logger.debug('Given result file does not exist: {0}'.format(metrics_file))

        # update json file with the new values
        with open(resultmanifest_file,'wb') as file_out:
            json.dump(result_json, file_out, indent=4)
        logger.debug('Finished updating %s file.' %(resultmanifest_file))
        
    else:
        logger.debug('%s does not exist!' %(resultmanifest_file))                   
# Global Variables 
# ===================================================================================================
#gVersion = '1.0.0.0'
#gConfigurationID = ''
#gComponentList = list()
#gFile = open('DebugLog.txt', 'w')
#gFile.write('#script:       ABQ_CompletePostProcess.py')
#gFile.write('#version:      ' + gVersion)
#gFile.write('#author:       Di Yao')
#gStructuralMetricTypes = ['FactorOfSafety', 'MaximumDisplacement', 'Mises', 'Bearing', 'Shear']

#gQualityLookup = {1:'LOW', 2:'MEDIUM', 3:'HIGH'}

# ===================================================================================================

gLogger = utility_functions.setup_logger('ABQ_CompletePostProcess.log')

# ===================================================================================================
# Helper Functions
# 

# ===================================================================================================


# ===================================================================================================
# Functions
#

def CalculateMetrics(fileName, componentList):
    gLogger.info('\n\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    gLogger.info('FUNCTION: CalculateMetrics\n')
Example #5
0
import os
import os.path
import sys
import glob
import shutil
import _winreg
import argparse
import posixpath
import subprocess
import urllib
import zipfile
import shutil
from win32com.shell import shell, shellcon
from utility_functions import setup_logger, exitwitherror

setup_logger("CADVisualizer.log")


def get_args():
    parser = argparse.ArgumentParser()
    parser.add_argument('outfile',
                        nargs='?',
                        type=str,
                        default='CyPhyAssembly',
                        help='Name for assembly CAD file.')
    parser.add_argument('format',
                        nargs='?',
                        type=str,
                        default='step',
                        help='Type of CAD files the assembler will work with.')
    parser.add_argument('-a',
Example #6
0
def main():
    from optparse import OptionParser

    parser = OptionParser()
    options = add_options(parser)

    debug_log_path = "./log/CAD_update_testbench_manifest.log"
    if not os.path.exists("./log"):
        os.makedirs("./log")
    else:
        if os.path.exists(debug_log_path):
            os.remove(debug_log_path)

    logger = utility_functions.setup_logger(debug_log_path)

    result_json = {}

    resultmanifest_file = "testbench_manifest.json"
    if os.path.exists(resultmanifest_file):
        # read current summary report, which contains the metrics
        with open(resultmanifest_file, "r") as file_in:
            result_json = json.load(file_in)

        # update analysis status
        if "Status" in result_json:
            if os.path.exists("_FAILED.txt"):
                result_json["Status"] = "FAILED"
            else:
                result_json["Status"] = "OK"
        else:
            logger.debug("%s does not contain Status" % (resultmanifest_file))

        metrics_file = options.metricfile

        if os.path.exists(metrics_file):
            Parsed_ComputedValueList = dict()
            Parsed_ComputedValueList = ComputedMetricsSummary.ParseXMLFile(metrics_file)
            # print (ComputedMetricsSummary.gMetricSummary)

            if "Metrics" in result_json:
                for metric in result_json["Metrics"]:
                    if "Name" in metric and "Value" in metric and "GMEID" in metric:
                        key = metric["GMEID"]
                        if ComputedMetricsSummary.gMetricSummary.has_key(key):
                            # update metric's value to the last value in
                            # time series
                            metric["Value"] = ComputedMetricsSummary.gMetricSummary[key][1]
                            metric["Unit"] = ComputedMetricsSummary.gMetricSummary[key][0]
                            logger.debug(
                                "Metric: {0} {1} {2} was updated.".format(
                                    metric["Name"], metric["Value"], metric["Unit"]
                                )
                            )

                        else:
                            # metric was not found in results
                            logger.debug("ComputedMetrics.xml key error: {0}".format(key))
            else:
                # create warning message
                logger.debug("% does not contain Metrics" % (resultmanifest_file))
        else:
            logger.debug("Given result file does not exist: {0}".format(metrics_file))

        # update json file with the new values
        with open(resultmanifest_file, "wb") as file_out:
            json.dump(result_json, file_out, indent=4)
        logger.debug("Finished updating %s file." % (resultmanifest_file))

    else:
        logger.debug("%s does not exist!" % (resultmanifest_file))
Example #7
0
            str(p.width), str(p.height)))
        logger.debug('Global <X,Y,Z>: <{0},{1},{2}>'.format(
            str(X), str(Y), str(Z)))
        logger.debug('Translate: ' + str(translation))
        logger.debug('EDARotation: ' + str(rotation))
        logger.debug('Rotation: ' + str(rotate))
        logger.debug('CAD2EDATranslate: ' + str(trans))
        logger.info('Adding FreeCAD object {0} for component {1}.'.format(
            solid.name, component))

    return topchips, bottomchips, placeholders


if __name__ == '__main__':
    global logger
    logger = setup_logger("CADAssembler.log", "main_log")
    try:
        if len(sys.argv) == 1:  # For debugging/testing in FreeCAD console
            doc = 'Test'
            ext = 'step'
        elif len(sys.argv) < 6:
            exitwitherror('Missing command-line arguments.')
        elif len(sys.argv) > 6:
            for i in range(0, len(sys.argv)):
                logger.debug(sys.argv[i])
            exitwitherror('Too many command-line arguments.')
        else:
            doc = sys.argv[2].replace('(', '_').replace(')', '_')
            ext = sys.argv[3]
            replace = sys.argv[4]
            interference_check = sys.argv[5].lower()