Commit a395d6ce authored by Rafael Monnerat's avatar Rafael Monnerat

Update from upstream/master

parents 75b31033 8b7e104d
...@@ -26,9 +26,9 @@ informations = { 'processing': processing, ...@@ -26,9 +26,9 @@ informations = { 'processing': processing,
if informations['processing'] in ['converted', 'conversion_failed','empty']: if informations['processing'] in ['converted', 'conversion_failed','empty']:
informations['permanent_url'] = document.Document_getPermanentUrl() informations['permanent_url'] = document.Document_getPermanentUrl()
print dumps(informations) #print info before del object print(dumps(informations)) #print info before del object
portal.portal_sessions.manage_delObjects(reference) portal.portal_sessions.manage_delObjects(reference)
else: else:
print dumps(informations) print(dumps(informations))
return printed return printed
...@@ -35,7 +35,7 @@ search_params = dict( ...@@ -35,7 +35,7 @@ search_params = dict(
for brain in portal.portal_simulation.getInventoryList(**search_params): for brain in portal.portal_simulation.getInventoryList(**search_params):
if round(brain.total_price, precision) == 0: if round(brain.total_price, precision) == 0:
print '%s has a 0 balance but some not grouped transactions.' % brain.mirror_section_relative_url print('%s has a 0 balance but some not grouped transactions.' % brain.mirror_section_relative_url)
if fixit: if fixit:
tr = brain.getObject().getParentValue() tr = brain.getObject().getParentValue()
grouped_line_list = tr.AccountingTransaction_guessGroupedLines() grouped_line_list = tr.AccountingTransaction_guessGroupedLines()
...@@ -51,9 +51,9 @@ for brain in portal.portal_simulation.getInventoryList(**search_params): ...@@ -51,9 +51,9 @@ for brain in portal.portal_simulation.getInventoryList(**search_params):
portal_type=portal.getPortalAccountingMovementTypeList(), portal_type=portal.getPortalAccountingMovementTypeList(),
grouping_reference=None,) if not line.getObject().getGroupingReference()]) grouping_reference=None,) if not line.getObject().getGroupingReference()])
if grouped_line_list: if grouped_line_list:
print 'FIXED', grouped_line_list print('FIXED %s' % grouped_line_list)
else: else:
print 'NOT FIXED' print('NOT FIXED')
active_result = ActiveResult( active_result = ActiveResult(
summary=context.getTitle(), summary=context.getTitle(),
......
...@@ -78,7 +78,7 @@ for property_dict in object_list: ...@@ -78,7 +78,7 @@ for property_dict in object_list:
gap = str(gap) gap = str(gap)
if gap: if gap:
gap = gap.replace('CLASSE ', '') gap = gap.replace('CLASSE ', '')
print '+ %s - %s - %s' % (gap or '', title or '', description or '') print('+ %s - %s - %s' % (gap or '', title or '', description or ''))
path = root path = root
b = '' b = ''
for a in gap: for a in gap:
...@@ -96,7 +96,7 @@ for path in existing_path_list: ...@@ -96,7 +96,7 @@ for path in existing_path_list:
description = document.getDescription() or '' description = document.getDescription() or ''
gap = document.getId() or '' gap = document.getId() or ''
title = document.getTitle() or '' title = document.getTitle() or ''
print '- %s - %s - %s' % (gap or '', title or '', description or '') print('- %s - %s - %s' % (gap or '', title or '', description or ''))
document.getParentValue().deleteContent(document.getId()) document.getParentValue().deleteContent(document.getId())
return printed return printed
...@@ -7,7 +7,7 @@ for cat in category_list: ...@@ -7,7 +7,7 @@ for cat in category_list:
cat.getObject().setId(newid) cat.getObject().setId(newid)
except: except:
pass pass
print newid print(newid)
print 'Categories Renamed' print('Categories Renamed')
return printed return printed
...@@ -7,7 +7,7 @@ for cat in category_list: ...@@ -7,7 +7,7 @@ for cat in category_list:
cat.getObject().setId(newid) cat.getObject().setId(newid)
except: except:
pass pass
print newid print(newid)
print 'Categories Renamed' print('Categories Renamed')
return printed return printed
...@@ -48,7 +48,7 @@ dane.p59=dane.p55-dane.p56 ...@@ -48,7 +48,7 @@ dane.p59=dane.p55-dane.p56
if debug: if debug:
for f in range(20,60): for f in range(20,60):
n='p'+str(f) n='p'+str(f)
print n,getattr(dane,n) print(n,getattr(dane,n))
return printed return printed
return container[report].index_html(REQUEST=context.REQUEST, RESPONSE=context.REQUEST.RESPONSE,dane=dane) return container[report].index_html(REQUEST=context.REQUEST, RESPONSE=context.REQUEST.RESPONSE,dane=dane)
...@@ -5,7 +5,7 @@ Warning: Before using this script as zope, edit account_workflow and give Manage ...@@ -5,7 +5,7 @@ Warning: Before using this script as zope, edit account_workflow and give Manage
#This script will REMOVE any existing accounts!!! #This script will REMOVE any existing accounts!!!
#comment following if you are sure #comment following if you are sure
print 'Nothing done!' print('Nothing done!')
return printed return printed
...@@ -22,7 +22,7 @@ for category in gap_root.getCategoryMemberValueList(): ...@@ -22,7 +22,7 @@ for category in gap_root.getCategoryMemberValueList():
acc = account_module.newContent(title='%s %s' % (category.getId(),category.getTitle()),\ acc = account_module.newContent(title='%s %s' % (category.getId(),category.getTitle()),\
gap_value = category) gap_value = category)
acc.validate() acc.validate()
print 'acc created' print('acc created')
return printed return printed
...@@ -251,7 +251,7 @@ for line in gap_text.splitlines(): ...@@ -251,7 +251,7 @@ for line in gap_text.splitlines():
cpath += n cpath += n
path.append(cpath) path.append(cpath)
parent = gap.restrictedTraverse('/'.join(path)) parent = gap.restrictedTraverse('/'.join(path))
print 'Added to ',parent print('Added to ',parent)
parent.newContent(id=num, title=descr) parent.newContent(id=num, title=descr)
......
container.REQUEST.RESPONSE.setHeader('content-type', 'text/html') container.REQUEST.RESPONSE.setHeader('content-type', 'text/html')
print '<html><head><meta http-equiv="refresh" content="%s"></head><body>' % refresh_interval print('<html><head><meta http-equiv="refresh" content="%s"></head><body>' % refresh_interval)
for table in 'message', 'message_queue': for table in 'message', 'message_queue':
q = """SELECT count(*) AS %(table)s, method_id, processing_node AS node, min(priority) AS min_pri, max(priority) AS max_pri q = """SELECT count(*) AS %(table)s, method_id, processing_node AS node, min(priority) AS min_pri, max(priority) AS max_pri
FROM %(table)s GROUP BY method_id, processing_node ORDER BY node""" % dict(table=table) FROM %(table)s GROUP BY method_id, processing_node ORDER BY node""" % dict(table=table)
print "<table border=\"\" style=\"font-size:XX-small;\"><tbody> <tr><th>%s</th> <th>method_id</th> <th>node</th> <th>min_pri</th> <th>max_pri</th> </tr>" % table print("<table border=\"\" style=\"font-size:XX-small;\"><tbody> <tr><th>%s</th> <th>method_id</th> <th>node</th> <th>min_pri</th> <th>max_pri</th> </tr>" % table)
for row in context.cmf_activity_sql_connection.manage_test(q): for row in context.cmf_activity_sql_connection.manage_test(q):
print '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td</tr>' % (row[table], row['method_id'], row['node'], row['min_pri'], row['max_pri']) print('<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td</tr>' % (row[table], row['method_id'], row['node'], row['min_pri'], row['max_pri']))
print '</tbody> </table> <br/>' print('</tbody> </table> <br/>')
return printed return printed
...@@ -10,14 +10,14 @@ for security_uid_field in security_uid_field_list: ...@@ -10,14 +10,14 @@ for security_uid_field in security_uid_field_list:
print(">> useless uids in roles_and_users table <<\n") print(">> useless uids in roles_and_users table <<\n")
if len(referenced_uid_set) > 0: if len(referenced_uid_set) > 0:
for row in req("select * from roles_and_users where uid not in %s" + tuple(referenced_uid_set)): for row in req("select * from roles_and_users where uid not in %s" + tuple(referenced_uid_set)):
print row.uid, row.local_roles_group_id, row.allowedRolesAndUsers print(row.uid, row.local_roles_group_id, row.allowedRolesAndUsers)
print("\n>> uids that should be in roles_and_users table <<\n") print("\n>> uids that should be in roles_and_users table <<\n")
all_uid_set = {row.uid for row in req("select uid from roles_and_users")} all_uid_set = {row.uid for row in req("select uid from roles_and_users")}
for security_uid_field in security_uid_field_list: for security_uid_field in security_uid_field_list:
for row in req("select %s, relative_url from catalog where %s not in %s" % (security_uid_field, security_uid_field, tuple(all_uid_set))): for row in req("select %s, relative_url from catalog where %s not in %s" % (security_uid_field, security_uid_field, tuple(all_uid_set))):
print security_uid_field, getattr(row, security_uid_field, None), row.relative_url print(security_uid_field, getattr(row, security_uid_field, None), row.relative_url)
print("\n>> END <<") print("\n>> END <<")
return printed return printed
...@@ -6,18 +6,18 @@ u = getSecurityManager().getUser() ...@@ -6,18 +6,18 @@ u = getSecurityManager().getUser()
user_value = u.getUserValue() user_value = u.getUserValue()
if user_value is None: if user_value is None:
print 'User ID:', u.getId() print('User ID:', u.getId())
else: else:
print 'User ID:', u.getId(), user_value.getPath() print('User ID:', u.getId(), user_value.getPath())
login_value = u.getLoginValue() login_value = u.getLoginValue()
if login_value is None: if login_value is None:
print 'Login:', u.getUserName() print('Login:', u.getUserName())
else: else:
print 'Login:', u.getUserName(), login_value.getPath() print('Login:', u.getUserName(), login_value.getPath())
print 'Is owner:', u.allowed(context,('Owner',)) print('Is owner:', u.allowed(context,('Owner',)))
print 'User roles:', u.getRoles() print('User roles:', u.getRoles())
print 'User roles in context:', u.getRolesInContext(context) print('User roles in context:', u.getRolesInContext(context))
print 'Permissions:' print('Permissions:')
for permission in [ for permission in [
'Access contents information', 'Access contents information',
'Add portal content', 'Add portal content',
...@@ -26,25 +26,25 @@ for permission in [ ...@@ -26,25 +26,25 @@ for permission in [
'View', 'View',
'Manage portal', 'Manage portal',
]: ]:
print " ", permission, u.has_permission(permission, context) print(" ", permission, u.has_permission(permission, context))
print print()
try: try:
print "User groups:\n", pformat(sorted(u.getGroups())) print("User groups:\n", pformat(sorted(u.getGroups())))
except AttributeError: except AttributeError:
print 'no getGroups' print('no getGroups')
print print()
print 'Local roles on document:\n', pformat(context.get_local_roles()) print('Local roles on document:\n', pformat(context.get_local_roles()))
print ''' print('''
---------------- ----------------
Security mapping Security mapping
----------------''' ----------------''')
if u.getId() is not None: if u.getId() is not None:
try: try:
print context.Base_viewSecurityMappingAsUser(u.getId()) print(context.Base_viewSecurityMappingAsUser(u.getId()))
except Unauthorized: except Unauthorized:
print "user doesn't have permission to security mapping in this context" print("user doesn't have permission to security mapping in this context")
return printed return printed
...@@ -16,12 +16,12 @@ for method_id, base_category_list in getSecurityCategoryMapping(): ...@@ -16,12 +16,12 @@ for method_id, base_category_list in getSecurityCategoryMapping():
security_category_dict.setdefault(tuple(base_category_list), []).extend( security_category_dict.setdefault(tuple(base_category_list), []).extend(
getattr(context, method_id)(base_category_list, login, context, '')) getattr(context, method_id)(base_category_list, login, context, ''))
except Exception: # XXX: it is not possible to log message with traceback from python script except Exception: # XXX: it is not possible to log message with traceback from python script
print 'It was not possible to invoke method %s with base_category_list %s'%(method_id, base_category_list) print('It was not possible to invoke method %s with base_category_list %s'%(method_id, base_category_list))
for base_category_list, category_value_list in security_category_dict.items(): for base_category_list, category_value_list in security_category_dict.items():
print 'base_category_list:', base_category_list print('base_category_list: %s' % (base_category_list,))
for category_dict in category_value_list: for category_dict in category_value_list:
print '-> category_dict:', category_dict print('-> category_dict: %s' % category_dict)
print '-->', group_id_list_generator(category_order=base_category_list, print('--> %s' % group_id_list_generator(category_order=base_category_list,
**category_dict) **category_dict))
return printed return printed
...@@ -20,7 +20,7 @@ if context.getPortalType() == 'Alarm': ...@@ -20,7 +20,7 @@ if context.getPortalType() == 'Alarm':
else: else:
active_process = context.portal_activities.newActiveProcess().getPath() active_process = context.portal_activities.newActiveProcess().getPath()
ERP5Site_checkDataWithScript = context.portal_activities.ERP5Site_checkDataWithScript ERP5Site_checkDataWithScript = context.portal_activities.ERP5Site_checkDataWithScript
print 'Results will be saved to %s' % active_process print('Results will be saved to %s' % active_process)
checkTopLevel() checkTopLevel()
ERP5Site_checkDataWithScript( ERP5Site_checkDataWithScript(
......
for builder in sorted(context.getPortalObject().portal_deliveries.contentValues(), for builder in sorted(context.getPortalObject().portal_deliveries.contentValues(),
key=lambda x:x.getTitle()): key=lambda x:x.getTitle()):
print builder.getId() print(builder.getId())
print " Title: %s" % (builder.getTitle()) print(" Title: %s" % (builder.getTitle()))
print " Simulation Select Method: %s" % (builder.getSimulationSelectMethodId()) print(" Simulation Select Method: %s" % (builder.getSimulationSelectMethodId()))
print " Delivery Select Method: %s" % (builder.getDeliverySelectMethodId()) print(" Delivery Select Method: %s" % (builder.getDeliverySelectMethodId()))
print " After Generation Script: %s" % (builder.getDeliveryAfterGenerationScriptId()) print(" After Generation Script: %s" % (builder.getDeliveryAfterGenerationScriptId()))
print print()
for mg in sorted(builder.contentValues(), key=lambda x:x.getTitle()): for mg in sorted(builder.contentValues(), key=lambda x:x.getTitle()):
print builder.getId() print(builder.getId())
print " ", "\n ".join([x for x in ( print(" ", "\n ".join([x for x in (
"Id: %s" % mg.getId(), "Id: %s" % mg.getId(),
"Title: %s" % mg.getTitle(), "Title: %s" % mg.getTitle(),
"Type: %s" % mg.getPortalType(), "Type: %s" % mg.getPortalType(),
...@@ -17,7 +17,7 @@ for builder in sorted(context.getPortalObject().portal_deliveries.contentValues( ...@@ -17,7 +17,7 @@ for builder in sorted(context.getPortalObject().portal_deliveries.contentValues(
"Tested Properties: %r" % mg.getTestedPropertyList(), "Tested Properties: %r" % mg.getTestedPropertyList(),
"Update Always: %r" % mg.isUpdateAlways(), "Update Always: %r" % mg.isUpdateAlways(),
)]) )]))
print print()
return printed return printed
...@@ -4,6 +4,6 @@ for business_template in sorted(context.getPortalObject().portal_templates.conte ...@@ -4,6 +4,6 @@ for business_template in sorted(context.getPortalObject().portal_templates.conte
key=lambda x:x.getTitle()): key=lambda x:x.getTitle()):
if business_template.getInstallationState() == 'installed' and \ if business_template.getInstallationState() == 'installed' and \
business_template.getTitle() not in ignore_business_template_list: business_template.getTitle() not in ignore_business_template_list:
print business_template.getTitle() print(business_template.getTitle())
return printed return printed
for builder in sorted(context.getPortalObject().portal_orders.contentValues(), for builder in sorted(context.getPortalObject().portal_orders.contentValues(),
key=lambda x:x.getTitle()): key=lambda x:x.getTitle()):
print builder.getId() print(builder.getId())
print " Title: %s" % (builder.getTitle()) print(" Title: %s" % (builder.getTitle()))
print " Simulation Select Method: %s" % (builder.getSimulationSelectMethodId()) print(" Simulation Select Method: %s" % (builder.getSimulationSelectMethodId()))
print " Delivery Select Method: %s" % (builder.getDeliverySelectMethodId()) print(" Delivery Select Method: %s" % (builder.getDeliverySelectMethodId()))
print " After Generation Script: %s" % (builder.getDeliveryAfterGenerationScriptId()) print(" After Generation Script: %s" % (builder.getDeliveryAfterGenerationScriptId()))
print " Delivery Module Before Building Script: %s" % (builder.getDeliveryModuleBeforeBuildingScriptId()) print(" Delivery Module Before Building Script: %s" % (builder.getDeliveryModuleBeforeBuildingScriptId()))
print print()
for mg in sorted(builder.contentValues(), key=lambda x:x.getTitle()): for mg in sorted(builder.contentValues(), key=lambda x:x.getTitle()):
print builder.getId() print(builder.getId())
print " ", "\n ".join([x for x in ( print(" ", "\n ".join([x for x in (
"Id: %s" % mg.getId(), "Id: %s" % mg.getId(),
"Title: %s" % mg.getTitle(), "Title: %s" % mg.getTitle(),
"Type: %s" % mg.getPortalType(), "Type: %s" % mg.getPortalType(),
...@@ -18,7 +18,7 @@ for builder in sorted(context.getPortalObject().portal_orders.contentValues(), ...@@ -18,7 +18,7 @@ for builder in sorted(context.getPortalObject().portal_orders.contentValues(),
"Tested Properties: %r" % mg.getTestedPropertyList(), "Tested Properties: %r" % mg.getTestedPropertyList(),
"Update Always: %r" % mg.isUpdateAlways(), "Update Always: %r" % mg.isUpdateAlways(),
)]) )]))
print print()
return printed return printed
...@@ -37,12 +37,12 @@ for skin_folder in portal.portal_skins.objectValues('Folder'): ...@@ -37,12 +37,12 @@ for skin_folder in portal.portal_skins.objectValues('Folder'):
for skin in skin_folder.objectValues(): for skin in skin_folder.objectValues():
if skin.getId() in ignore_skin_list: if skin.getId() in ignore_skin_list:
continue continue
print getSkinHash(skin, skin_folder) print(getSkinHash(skin, skin_folder))
if include_workflow_scripts: if include_workflow_scripts:
for workflow in portal.portal_workflow.objectValues(): for workflow in portal.portal_workflow.objectValues():
for skin in workflow.scripts.objectValues(): for skin in workflow.scripts.objectValues():
print getSkinHash(skin, workflow) print(getSkinHash(skin, workflow))
container.REQUEST.RESPONSE.setHeader('content-type', 'text/plain') container.REQUEST.RESPONSE.setHeader('content-type', 'text/plain')
return '\n'.join(sorted(printed.splitlines())) return '\n'.join(sorted(printed.splitlines()))
for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lambda x:x.getId()): for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lambda x:x.getId()):
for ai in sorted(ti.contentValues(portal_type='Action Information'), key=lambda x:x.getReference()): for ai in sorted(ti.contentValues(portal_type='Action Information'), key=lambda x:x.getReference()):
print ti.getId() print(ti.getId())
print " ", "\n ".join([x for x in ( print(" ", "\n ".join([x for x in (
"Reference: %s" % ai.getReference(), "Reference: %s" % ai.getReference(),
"Title: %s" % ai.getTitle(), "Title: %s" % ai.getTitle(),
"Action: %s" % ai.getActionText(), "Action: %s" % ai.getActionText(),
...@@ -9,7 +9,7 @@ for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lam ...@@ -9,7 +9,7 @@ for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lam
"Permission: %s" % ai.getActionPermission(), "Permission: %s" % ai.getActionPermission(),
"Action Type: %s" % ai.getActionType(), "Action Type: %s" % ai.getActionType(),
"Visible: %s" % ai.getVisible(), "Visible: %s" % ai.getVisible(),
"Index: %s" % ai.getFloatIndex())]) "Index: %s" % ai.getFloatIndex())]))
print print()
return printed return printed
for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lambda x:x.getId()): for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lambda x:x.getId()):
print ti.getId() print(ti.getId())
print " ", "\n ".join([x for x in ( print(" ", "\n ".join([x for x in (
"Short Title: %s" % ti.getShortTitle(), "Short Title: %s" % ti.getShortTitle(),
"Class: %s" % ti.getTypeClass(), "Class: %s" % ti.getTypeClass(),
"Init Script: %s" % ti.getTypeInitScriptId(), "Init Script: %s" % ti.getTypeInitScriptId(),
...@@ -12,7 +12,7 @@ for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lam ...@@ -12,7 +12,7 @@ for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lam
"Hidden Content Types: %r" % sorted(ti.getTypeHiddenContentTypeList()), "Hidden Content Types: %r" % sorted(ti.getTypeHiddenContentTypeList()),
"Searchable Property: %r" % sorted(ti.getSearchableTextPropertyIdList()), "Searchable Property: %r" % sorted(ti.getSearchableTextPropertyIdList()),
"Searchable Method: %r" % sorted(ti.getSearchableTextMethodIdList()), "Searchable Method: %r" % sorted(ti.getSearchableTextMethodIdList()),
)]) )]))
print print()
return printed return printed
for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lambda x:x.getId()): for ti in sorted(context.getPortalObject().portal_types.contentValues(), key=lambda x:x.getId()):
for ri in sorted(ti.contentValues(portal_type='Role Information'), key=lambda x:(x.getTitle(), x.getLocalRoleGroupId(), x.getRoleBaseCategoryScriptId(), x.getRoleBaseCategoryList())): for ri in sorted(ti.contentValues(portal_type='Role Information'), key=lambda x:(x.getTitle(), x.getLocalRoleGroupId(), x.getRoleBaseCategoryScriptId(), x.getRoleBaseCategoryList())):
print ti.getId() print(ti.getId())
print " ", "\n ".join([x for x in ( print(" ", "\n ".join([x for x in (
"Title: %s" % ri.getTitle(), "Title: %s" % ri.getTitle(),
"Roles: %r" % ri.getRoleNameList(), "Roles: %r" % ri.getRoleNameList(),
"Condition: %s" % ri.getConditionText(), "Condition: %s" % ri.getConditionText(),
"Local Roles Group Id: %s" % ri.getLocalRoleGroupId(), "Local Roles Group Id: %s" % ri.getLocalRoleGroupId(),
"Base Categories: %r" % ri.getRoleBaseCategoryList(), "Base Categories: %r" % ri.getRoleBaseCategoryList(),
"Base Category Script: %s" % ri.getRoleBaseCategoryScriptId(), "Base Category Script: %s" % ri.getRoleBaseCategoryScriptId(),
"Categories: %r" % ri.getRoleCategoryList() )]) "Categories: %r" % ri.getRoleCategoryList() )]))
print print()
return printed return printed
...@@ -6,7 +6,7 @@ for ps in sorted(context.getPortalObject().portal_property_sheets.contentValues( ...@@ -6,7 +6,7 @@ for ps in sorted(context.getPortalObject().portal_property_sheets.contentValues(
ps_id = ps.getId() ps_id = ps.getId()
if ps_id in ignore_property_sheet_list: if ps_id in ignore_property_sheet_list:
continue continue
print ps.getId() print(ps.getId())
info_list = ['id', 'portal_type', 'reference'] info_list = ['id', 'portal_type', 'reference']
std_prop_list = ['elementary_type', 'property_default', 'storage_id', 'multivaluated', 'range', 'preference', 'read_permission', 'write_permission', 'translatable', 'translation_domain'] std_prop_list = ['elementary_type', 'property_default', 'storage_id', 'multivaluated', 'range', 'preference', 'read_permission', 'write_permission', 'translatable', 'translation_domain']
if pd.getPortalType() == 'Standard Property': if pd.getPortalType() == 'Standard Property':
...@@ -29,10 +29,10 @@ for ps in sorted(context.getPortalObject().portal_property_sheets.contentValues( ...@@ -29,10 +29,10 @@ for ps in sorted(context.getPortalObject().portal_property_sheets.contentValues(
elif pd.getPortalType().endswith('Constraint'): elif pd.getPortalType().endswith('Constraint'):
info_list += [] + [p for p in pd.propertyIds() if p.startswith('message')] info_list += [] + [p for p in pd.propertyIds() if p.startswith('message')]
else: else:
print "(not supported)",pd.getRelativeUrl(), pd.getPortalType() print("(not supported)",pd.getRelativeUrl(), pd.getPortalType())
print " ", "\n ".join(['%s: %s' % (prop, pd.getProperty(prop)) for prop in sorted(info_list)]) print(" ", "\n ".join(['%s: %s' % (prop, pd.getProperty(prop)) for prop in sorted(info_list)]))
print print()
return printed return printed
...@@ -2,17 +2,17 @@ for rule in sorted(context.getPortalObject().portal_rules.contentValues(), ...@@ -2,17 +2,17 @@ for rule in sorted(context.getPortalObject().portal_rules.contentValues(),
key=lambda x:x.getTitle()): key=lambda x:x.getTitle()):
if rule.getValidationState() != 'validated': if rule.getValidationState() != 'validated':
continue continue
print rule.getId() print(rule.getId())
print " Title: %s" % (rule.getTitle()) print(" Title: %s" % (rule.getTitle()))
print " Trade Phases: %r" % (rule.getTradePhaseList()) print(" Trade Phases: %r" % (rule.getTradePhaseList()))
print " Test Method Id: %s" % (rule.getTestMethodId()) print(" Test Method Id: %s" % (rule.getTestMethodId()))
print " Membership Criteria: %r" % (rule.getMembershipCriterionBaseCategoryList()) print(" Membership Criteria: %r" % (rule.getMembershipCriterionBaseCategoryList()))
print " Membership Criterion Category: %r" % (rule.getMembershipCriterionCategoryList()) print(" Membership Criterion Category: %r" % (rule.getMembershipCriterionCategoryList()))
print print()
for tester in sorted(rule.contentValues(), key=lambda x:x.getTitle()): for tester in sorted(rule.contentValues(), key=lambda x:x.getTitle()):
print rule.getId() print(rule.getId())
print " ", "\n ".join([x for x in ( print(" ", "\n ".join([x for x in (
"Id: %s" % tester.getId(), "Id: %s" % tester.getId(),
"Title: %s" % tester.getTitle(), "Title: %s" % tester.getTitle(),
"Type: %s" % tester.getPortalType(), "Type: %s" % tester.getPortalType(),
...@@ -25,7 +25,7 @@ for rule in sorted(context.getPortalObject().portal_rules.contentValues(), ...@@ -25,7 +25,7 @@ for rule in sorted(context.getPortalObject().portal_rules.contentValues(),
(tester.getMembershipCriterionBaseCategoryList()), (tester.getMembershipCriterionBaseCategoryList()),
"Membership Criterion Category: %r" % "Membership Criterion Category: %r" %
(tester.getMembershipCriterionCategoryList()), (tester.getMembershipCriterionCategoryList()),
)]) )]))
print print()
return printed return printed
...@@ -13,5 +13,5 @@ for name, layers in skin_tool.getSkinPaths(): ...@@ -13,5 +13,5 @@ for name, layers in skin_tool.getSkinPaths():
if ignore_skin_folder_list is not None and\ if ignore_skin_folder_list is not None and\
layer in ignore_skin_folder_list: layer in ignore_skin_folder_list:
continue continue
print '%s,%s' % (name, layer) print('%s,%s' % (name, layer))
return printed return printed
...@@ -13,6 +13,6 @@ for field_path, field in context.ZopeFind( ...@@ -13,6 +13,6 @@ for field_path, field in context.ZopeFind(
relation_setter_id = field.get_value('relation_setter_id') relation_setter_id = field.get_value('relation_setter_id')
if relation_setter_id: if relation_setter_id:
print field_path, relation_setter_id print(field_path, relation_setter_id)
return printed return printed
...@@ -16,6 +16,6 @@ for bt in bt_list: ...@@ -16,6 +16,6 @@ for bt in bt_list:
delete_list.append(bt_id) delete_list.append(bt_id)
break break
print 'Deleted id list:%r' % delete_list print('Deleted id list:%r' % delete_list)
portal_templates.manage_delObjects(delete_list) portal_templates.manage_delObjects(delete_list)
return printed return printed
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
</item> </item>
<item> <item>
<key> <string>acquisition_portal_type</string> </key> <key> <string>acquisition_portal_type</string> </key>
<value> <string>python: list(portal.getPortalAcquisitionMovementTypeList() + portal.getPortalItemTypeList())</string> </value> <value> <string>python: list(portal.getPortalAcquisitionMovementTypeList() + portal.getPortalSupplyPathTypeList() + portal.getPortalItemTypeList())</string> </value>
</item> </item>
<item> <item>
<key> <string>categories</string> </key> <key> <string>categories</string> </key>
......
...@@ -33,10 +33,6 @@ class SplitMovementGroup(MovementGroup): ...@@ -33,10 +33,6 @@ class SplitMovementGroup(MovementGroup):
This movement group is used to split all the movements that are aggregated This movement group is used to split all the movements that are aggregated
by the Simulation Select Method. by the Simulation Select Method.
XXX-Tatuya: However this test() method returns True, so the aggregated
movements can be inserted into existing Delivery/Line/Cell that are aggregated
by the Delivery Select Method. What use case this is applied for?
* Reference: * Reference:
http://www.erp5.org/HowToConfigureMovementGroup http://www.erp5.org/HowToConfigureMovementGroup
......
...@@ -8,5 +8,5 @@ context.ERP5Site_checkDataWithScript("Base_migrateToEmbeddedFile", ...@@ -8,5 +8,5 @@ context.ERP5Site_checkDataWithScript("Base_migrateToEmbeddedFile",
active_process=active_process.getPath(), active_process=active_process.getPath(),
method_kw=dict(force=1)) method_kw=dict(force=1))
print "Migration started with process id: %s" %active_process.getPath() print("Migration started with process id: %s" %active_process.getPath())
return printed return printed
...@@ -5,6 +5,7 @@ notification_message_list = portal.portal_catalog.getDocumentValueList( ...@@ -5,6 +5,7 @@ notification_message_list = portal.portal_catalog.getDocumentValueList(
reference=reference, reference=reference,
language=language, language=language,
strict_language=strict_language, strict_language=strict_language,
limit=limit,
**kw **kw
) )
if notification_message_list: if notification_message_list:
......
...@@ -50,7 +50,7 @@ ...@@ -50,7 +50,7 @@
</item> </item>
<item> <item>
<key> <string>_params</string> </key> <key> <string>_params</string> </key>
<value> <string>reference, language=None, strict_language=False, validation_state=None, **kw</string> </value> <value> <string>reference, language=None, strict_language=False, validation_state=None, limit=1, **kw</string> </value>
</item> </item>
<item> <item>
<key> <string>id</string> </key> <key> <string>id</string> </key>
......
from __future__ import print_function
from BTrees.LOBTree import LOBTree from BTrees.LOBTree import LOBTree
from persistent import Persistent from persistent import Persistent
import itertools import itertools
...@@ -314,7 +315,7 @@ class BTreeData(Persistent): ...@@ -314,7 +315,7 @@ class BTreeData(Persistent):
if __name__ == '__main__': if __name__ == '__main__':
def check(tree, length, read_offset, read_length, data_, keys=None): def check(tree, length, read_offset, read_length, data_, keys=None):
print list(tree._tree.items()) print(list(tree._tree.items()))
tree_length = len(tree) tree_length = len(tree)
tree_data = tree.read(read_offset, read_length) tree_data = tree.read(read_offset, read_length)
tree_iterator_data = ''.join(tree.iterate(read_offset, read_length)) tree_iterator_data = ''.join(tree.iterate(read_offset, read_length))
......
...@@ -68,11 +68,11 @@ for business_application_category_id, module_ids in module_business_application_ ...@@ -68,11 +68,11 @@ for business_application_category_id, module_ids in module_business_application_
if module is not None: if module is not None:
module.edit(business_application = business_application_category_id) module.edit(business_application = business_application_category_id)
print "Indexing translations" print("Indexing translations")
portal.ERP5Site_updateTranslationTable() portal.ERP5Site_updateTranslationTable()
# clear cache so user security is recalculated # clear cache so user security is recalculated
portal.portal_caches.clearAllCache() portal.portal_caches.clearAllCache()
print "Clear cache." print("Clear cache.")
log("%s" % printed) log("%s" % printed)
...@@ -12,7 +12,7 @@ if business_template is not None: ...@@ -12,7 +12,7 @@ if business_template is not None:
filter=dict(portal_type=portal_type)) filter=dict(portal_type=portal_type))
for module in module_list: for module in module_list:
module.updateLocalRolesOnSecurityGroups() module.updateLocalRolesOnSecurityGroups()
print "Updated Role Mappings for: %s(%s) " % (module.getTitle(), module.getPortalType()) print("Updated Role Mappings for: %s(%s) " % (module.getTitle(), module.getPortalType()))
# validate and open all objects # validate and open all objects
for path in business_template.getTemplatePathList(): for path in business_template.getTemplatePathList():
...@@ -22,16 +22,16 @@ if business_template is not None: ...@@ -22,16 +22,16 @@ if business_template is not None:
if obj.getPortalType() not in ('Category', 'Base Category',): if obj.getPortalType() not in ('Category', 'Base Category',):
obj.updateLocalRolesOnSecurityGroups() obj.updateLocalRolesOnSecurityGroups()
print "Updated Role Mappings for: ", path, obj.getPortalType() print("Updated Role Mappings for: ", path, obj.getPortalType())
if obj.getPortalType() in ('Person', 'Organisation'): if obj.getPortalType() in ('Person', 'Organisation'):
for period in obj.contentValues(filter={'portal_type':'Accounting Period'}): for period in obj.contentValues(filter={'portal_type':'Accounting Period'}):
period.updateLocalRolesOnSecurityGroups() period.updateLocalRolesOnSecurityGroups()
print "\tOpen (Accounting Period): ", period.getRelativeUrl() print("\tOpen (Accounting Period): ", period.getRelativeUrl())
for assignment in obj.contentValues(filter={'portal_type':'Assignment'}): for assignment in obj.contentValues(filter={'portal_type':'Assignment'}):
assignment.updateLocalRolesOnSecurityGroups() assignment.updateLocalRolesOnSecurityGroups()
print "\tOpen (assignment): ", assignment.getRelativeUrl() print("\tOpen (assignment): ", assignment.getRelativeUrl())
for solver_type in context.portal_solvers.objectValues(): for solver_type in context.portal_solvers.objectValues():
solver_type.updateLocalRolesOnSecurityGroups() solver_type.updateLocalRolesOnSecurityGroups()
...@@ -96,11 +96,11 @@ if osoe_runner_website is not None: ...@@ -96,11 +96,11 @@ if osoe_runner_website is not None:
available_language_list = list(portal.Localizer.get_supported_languages()) available_language_list = list(portal.Localizer.get_supported_languages())
osoe_runner_website.edit(available_language_set = available_language_list) osoe_runner_website.edit(available_language_set = available_language_list)
print "Indexing translations" print("Indexing translations")
portal.ERP5Site_updateTranslationTable() portal.ERP5Site_updateTranslationTable()
# clear cache so user security is recalculated # clear cache so user security is recalculated
portal.portal_caches.clearAllCache() portal.portal_caches.clearAllCache()
print "Clear cache." print("Clear cache.")
log("%s" % printed) log("%s" % printed)
...@@ -141,7 +141,7 @@ for message in message_list: ...@@ -141,7 +141,7 @@ for message in message_list:
comment_list = message_dict[message] comment_list = message_dict[message]
comment_list.sort() comment_list.sort()
comment = '\n'.join([('#: %s' % i) for i in comment_list]) comment = '\n'.join([('#: %s' % i) for i in comment_list])
print MESSAGE_TEMPLATE % (comment, formatText(message)) print(MESSAGE_TEMPLATE % (comment, formatText(message)))
context.REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain') context.REQUEST.RESPONSE.setHeader('Content-Type', 'text/plain')
......
...@@ -8,10 +8,10 @@ message_list = ["Configuration is over. Enjoy your new ERP5 system!", ...@@ -8,10 +8,10 @@ message_list = ["Configuration is over. Enjoy your new ERP5 system!",
portal.REQUEST.RESPONSE.setHeader('content-type', 'text/plain') portal.REQUEST.RESPONSE.setHeader('content-type', 'text/plain')
for message in message_list: for message in message_list:
if not message in html_status_report: if not message in html_status_report:
print "Error: {message} not found in status report".format(message=message) print("Error: {message} not found in status report".format(message=message))
for log in portal.error_log.getLogEntries(): for log in portal.error_log.getLogEntries():
print "Error: {type} {value} {tb_text}".format(**log) print("Error: {type} {value} {tb_text}".format(**log))
if str(printed): if str(printed):
return printed return printed
......
...@@ -201,7 +201,7 @@ for serie in series_list: ...@@ -201,7 +201,7 @@ for serie in series_list:
# the last element must be saved # the last element must be saved
data_groups.append(new_group) data_groups.append(new_group)
print data_groups print(data_groups)
# [ # [
...@@ -236,24 +236,24 @@ def aggregate(big_list, item_to_add): ...@@ -236,24 +236,24 @@ def aggregate(big_list, item_to_add):
if big_list == []: if big_list == []:
return [] return []
if getListLevel(big_list) == getListLevel(item_to_add): if getListLevel(big_list) == getListLevel(item_to_add):
print "big_list " + big_list print("big_list " + big_list)
print "item_to_add " + item_to_add print("item_to_add " + item_to_add)
big_list.append(item_to_add) big_list.append(item_to_add)
return big_list return big_list
else: else:
new_big_list_sub_level = aggregate(getLastSubList(big_list), item_to_add) new_big_list_sub_level = aggregate(getLastSubList(big_list), item_to_add)
print "new_big_list_sub_level " + new_big_list_sub_level print("new_big_list_sub_level " + new_big_list_sub_level)
print "big_list " + big_list print("big_list " + big_list)
return None #setLastSubList(big_list, new_big_list_sub_level) return None #setLastSubList(big_list, new_big_list_sub_level)
for group in data_groups: for group in data_groups:
collapsed_group = group[0] collapsed_group = group[0]
for serie_group in group[1:]: for serie_group in group[1:]:
print serie_group print(serie_group)
collapsed_group = aggregate(collapsed_group, serie_group) collapsed_group = aggregate(collapsed_group, serie_group)
print collapsed_group print(collapsed_group)
# if # if
......
...@@ -50,7 +50,7 @@ from OFS.Image import Pdata ...@@ -50,7 +50,7 @@ from OFS.Image import Pdata
WORKFLOW_TYPE = 'erp5_workflow' WORKFLOW_TYPE = 'erp5_workflow'
from Products.MimetypesRegistry.common import MimeTypeException from Products.MimetypesRegistry.interfaces import MimeTypeException
from Products.PortalTransforms.Transform import Transform from Products.PortalTransforms.Transform import Transform
Transform_tr_init = Transform._tr_init Transform_tr_init = Transform._tr_init
Transform_manage_beforeDelete = Transform.manage_beforeDelete Transform_manage_beforeDelete = Transform.manage_beforeDelete
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import random import random
import time import time
...@@ -69,7 +70,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -69,7 +70,7 @@ class TestRamCache(ERP5TypeTestCase):
for cache_plugin in filtered_cache_plugins: for cache_plugin in filtered_cache_plugins:
if not self.quiet: if not self.quiet:
print "TESTING (scope): ", cache_plugin print("TESTING (scope): ", cache_plugin)
## clear cache for this plugin ## clear cache for this plugin
cache_plugin.clearCache() cache_plugin.clearCache()
...@@ -85,7 +86,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -85,7 +86,7 @@ class TestRamCache(ERP5TypeTestCase):
## we set ONLY one value per scope -> check if we get the same cache_id ## we set ONLY one value per scope -> check if we get the same cache_id
self.assertEqual([cache_id], cache_plugin.getScopeKeyList(scope)) self.assertEqual([cache_id], cache_plugin.getScopeKeyList(scope))
if not self.quiet: if not self.quiet:
print "\t", cache_id, scope, "\t\tOK" print("\t", cache_id, scope, "\t\tOK")
## get list of scopes which must be the same as test_scopes since we clear cache initially ## get list of scopes which must be the same as test_scopes since we clear cache initially
scopes_from_cache = cache_plugin.getScopeList() scopes_from_cache = cache_plugin.getScopeList()
...@@ -118,7 +119,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -118,7 +119,7 @@ class TestRamCache(ERP5TypeTestCase):
def generalExpire(self, cache_plugin, iterations): def generalExpire(self, cache_plugin, iterations):
if not self.quiet: if not self.quiet:
print "TESTING (expire): ", cache_plugin print("TESTING (expire): ", cache_plugin)
base_timeout = 1 base_timeout = 1
values = self.prepareValues(iterations) values = self.prepareValues(iterations)
scope = "peter" scope = "peter"
...@@ -128,7 +129,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -128,7 +129,7 @@ class TestRamCache(ERP5TypeTestCase):
cache_timeout = base_timeout + random.random()*2 cache_timeout = base_timeout + random.random()*2
cache_id = "mycache_id_to_expire_%s" %(count) cache_id = "mycache_id_to_expire_%s" %(count)
if not self.quiet: if not self.quiet:
print "\t", cache_id, " ==> timeout (s) = ", cache_timeout, print("\t", cache_id, " ==> timeout (s) = ", cache_timeout, end=' ')
## set to cache ## set to cache
cache_plugin.set(cache_id, scope, value, cache_timeout) cache_plugin.set(cache_id, scope, value, cache_timeout)
...@@ -142,11 +143,11 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -142,11 +143,11 @@ class TestRamCache(ERP5TypeTestCase):
## check it, we MUST NOT have this key any more in cache ## check it, we MUST NOT have this key any more in cache
self.assertEqual(False, cache_plugin.has_key(cache_id, scope)) self.assertEqual(False, cache_plugin.has_key(cache_id, scope))
if not self.quiet: if not self.quiet:
print "\t\tOK" print("\t\tOK")
def generaltestSetGet(self, cache_plugin, iterations): def generaltestSetGet(self, cache_plugin, iterations):
if not self.quiet: if not self.quiet:
print "TESTING (set/get/has/del): ", cache_plugin print("TESTING (set/get/has/del): ", cache_plugin)
values = self.prepareValues(iterations) values = self.prepareValues(iterations)
cache_duration = 30 cache_duration = 30
scope = "peter" scope = "peter"
...@@ -158,7 +159,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -158,7 +159,7 @@ class TestRamCache(ERP5TypeTestCase):
## set to cache ## set to cache
cache_plugin.set(cache_id, scope, value, cache_duration) cache_plugin.set(cache_id, scope, value, cache_duration)
if not self.quiet: if not self.quiet:
print "\t", cache_id, print("\t", cache_id, end=' ')
## check has_key() ## check has_key()
self.assertEqual(True, cache_plugin.has_key(cache_id, scope)) self.assertEqual(True, cache_plugin.has_key(cache_id, scope))
...@@ -184,7 +185,7 @@ class TestRamCache(ERP5TypeTestCase): ...@@ -184,7 +185,7 @@ class TestRamCache(ERP5TypeTestCase):
self.assertEqual(False, cache_plugin.has_key(cache_id, scope)) self.assertEqual(False, cache_plugin.has_key(cache_id, scope))
if not self.quiet: if not self.quiet:
print "\t\tOK" print("\t\tOK")
def prepareValues(self, iterations): def prepareValues(self, iterations):
""" generate a big list of values """ """ generate a big list of values """
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import time import time
import unittest import unittest
...@@ -227,9 +228,9 @@ return result ...@@ -227,9 +228,9 @@ return result
def _cacheFactoryInstanceTest(self, my_cache, cf_name, clear_allowed): def _cacheFactoryInstanceTest(self, my_cache, cf_name, clear_allowed):
portal = self.portal portal = self.portal
print print()
print "="*40 print("="*40)
print "TESTING:", cf_name print("TESTING:", cf_name)
result = 'a short value' result = 'a short value'
#portal.portal_caches.clearCacheFactory(cf_name) #portal.portal_caches.clearCacheFactory(cf_name)
...@@ -249,12 +250,12 @@ return result ...@@ -249,12 +250,12 @@ return result
result=result) result=result)
## 1st call ## 1st call
calculation_time = callCache(real_calculation=True) calculation_time = callCache(real_calculation=True)
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
self.commit() self.commit()
## 2nd call - should be cached now ## 2nd call - should be cached now
calculation_time = callCache(real_calculation=False) calculation_time = callCache(real_calculation=False)
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
self.commit() self.commit()
## OK so far let's clear cache ## OK so far let's clear cache
...@@ -263,10 +264,10 @@ return result ...@@ -263,10 +264,10 @@ return result
## 1st call ## 1st call
calculation_time = callCache(real_calculation=True) calculation_time = callCache(real_calculation=True)
print "\n\tCalculation time (after cache clear)", calculation_time print("\n\tCalculation time (after cache clear)", calculation_time)
# Test delete method on CachingMethod # Test delete method on CachingMethod
print "\n\tCalculation time (3rd call)", calculation_time print("\n\tCalculation time (3rd call)", calculation_time)
# make sure cache id filled # make sure cache id filled
calculation_time = callCache(real_calculation=False) calculation_time = callCache(real_calculation=False)
...@@ -275,7 +276,7 @@ return result ...@@ -275,7 +276,7 @@ return result
# Check that result is computed # Check that result is computed
calculation_time = callCache(real_calculation=True) calculation_time = callCache(real_calculation=True)
print "\n\tCalculation time (4th call)", calculation_time print("\n\tCalculation time (4th call)", calculation_time)
self.commit() self.commit()
def test_03_cachePersistentObjects(self): def test_03_cachePersistentObjects(self):
...@@ -296,9 +297,9 @@ return result ...@@ -296,9 +297,9 @@ return result
def test_04_CheckConcurrentRamCacheDict(self): def test_04_CheckConcurrentRamCacheDict(self):
"""Check that all RamCache doesn't clear the same cache_dict """Check that all RamCache doesn't clear the same cache_dict
""" """
print print()
print "="*40 print("="*40)
print "TESTING: Concurrent RamCache" print("TESTING: Concurrent RamCache")
portal = self.portal portal = self.portal
result = 'Something short' result = 'Something short'
...@@ -317,7 +318,7 @@ return result ...@@ -317,7 +318,7 @@ return result
result=result) result=result)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -328,7 +329,7 @@ return result ...@@ -328,7 +329,7 @@ return result
result=result) result=result)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time) self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -342,7 +343,7 @@ return result ...@@ -342,7 +343,7 @@ return result
result=result) result=result)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (3rd call)", calculation_time print("\n\tCalculation time (3rd call)", calculation_time)
self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time) self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -351,9 +352,9 @@ return result ...@@ -351,9 +352,9 @@ return result
"""Check that persistent distributed Cache Plugin can handle keys """Check that persistent distributed Cache Plugin can handle keys
more than 250 bytes and values more than 1024 bytes. more than 250 bytes and values more than 1024 bytes.
""" """
print print()
print '=' * 40 print('=' * 40)
print 'TESTING: Long Keys and Large values' print('TESTING: Long Keys and Large values')
portal = self.portal portal = self.portal
# import the local and clear it # import the local and clear it
from Products.ERP5Type.CachePlugins.DistributedRamCache import\ from Products.ERP5Type.CachePlugins.DistributedRamCache import\
...@@ -410,7 +411,7 @@ return 'a' * 1024 * 1024 * 25 ...@@ -410,7 +411,7 @@ return 'a' * 1024 * 1024 * 25
long_parameter=long_parameter) long_parameter=long_parameter)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -423,7 +424,7 @@ return 'a' * 1024 * 1024 * 25 ...@@ -423,7 +424,7 @@ return 'a' * 1024 * 1024 * 25
long_parameter=long_parameter) long_parameter=long_parameter)
end = time.time() end = time.time()
calculation_time = end-start calculation_time = end-start
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time) self.assertTrue(1.0 > calculation_time, "1.0 <= %s" % calculation_time)
self.assertEqual(cached, result) self.assertEqual(cached, result)
self.commit() self.commit()
...@@ -431,37 +432,37 @@ return 'a' * 1024 * 1024 * 25 ...@@ -431,37 +432,37 @@ return 'a' * 1024 * 1024 * 25
def test_06_CheckCacheExpiration(self): def test_06_CheckCacheExpiration(self):
"""Check that expiracy is well handle by Cache Plugins """Check that expiracy is well handle by Cache Plugins
""" """
print print()
print "="*40 print("="*40)
print "TESTING: Cache Expiration Time" print("TESTING: Cache Expiration Time")
py_script_obj = getattr(self.portal, self.python_script_id) py_script_obj = getattr(self.portal, self.python_script_id)
cache_factory_list = ('ram_cache_factory', 'distributed_ram_cache_factory', cache_factory_list = ('ram_cache_factory', 'distributed_ram_cache_factory',
'distributed_persistent_cache_factory') 'distributed_persistent_cache_factory')
for cache_factory in cache_factory_list: for cache_factory in cache_factory_list:
print '\n\t==> %s' % cache_factory print('\n\t==> %s' % cache_factory)
my_cache = CachingMethod(py_script_obj, my_cache = CachingMethod(py_script_obj,
'py_script_obj', 'py_script_obj',
cache_factory=cache_factory) cache_factory=cache_factory)
# First call, fill the cache # First call, fill the cache
calculation_time = self._callCache(my_cache, real_calculation=True) calculation_time = self._callCache(my_cache, real_calculation=True)
print "\n\tCalculation time (1st call)", calculation_time print("\n\tCalculation time (1st call)", calculation_time)
## 2nd call - should be cached now ## 2nd call - should be cached now
calculation_time = self._callCache(my_cache, real_calculation=False) calculation_time = self._callCache(my_cache, real_calculation=False)
print "\n\tCalculation time (2nd call)", calculation_time print("\n\tCalculation time (2nd call)", calculation_time)
# Wait expiration period then check that value is computed # Wait expiration period then check that value is computed
# .1 is an additional epsilon delay to work around time precision issues # .1 is an additional epsilon delay to work around time precision issues
time_left_to_wait = .1 + self.cache_duration time_left_to_wait = .1 + self.cache_duration
print "\n\tSleep %.2f seconds to wait expiration time" % time_left_to_wait print("\n\tSleep %.2f seconds to wait expiration time" % time_left_to_wait)
time.sleep(time_left_to_wait) time.sleep(time_left_to_wait)
# Call conversion for ram_cache_factory # Call conversion for ram_cache_factory
calculation_time = self._callCache(my_cache, real_calculation=True) calculation_time = self._callCache(my_cache, real_calculation=True)
print "\n\tCalculation time (3rd call)", calculation_time print("\n\tCalculation time (3rd call)", calculation_time)
def test_06_CheckCacheBag(self): def test_06_CheckCacheBag(self):
""" """
......
...@@ -576,7 +576,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -576,7 +576,7 @@ class TestERP5Core(ERP5TypeTestCase, ZopeTestCase.Functional):
0 != i.getUid() != i.getProperty('uid')]) 0 != i.getUid() != i.getProperty('uid')])
def test_04_site_manager_and_translation_migration(self): def test_04_site_manager_and_translation_migration(self):
from zope.site.hooks import setSite from zope.component.hooks import setSite
from zope.component import queryUtility from zope.component import queryUtility
# check translation is working normaly # check translation is working normaly
erp5_ui_catalog = self.portal.Localizer.erp5_ui erp5_ui_catalog = self.portal.Localizer.erp5_ui
......
...@@ -33,7 +33,8 @@ import six ...@@ -33,7 +33,8 @@ import six
from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase from Products.ERP5Type.tests.ERP5TypeTestCase import ERP5TypeTestCase
from Products.ERP5Type.tests.utils import createZODBPythonScript from Products.ERP5Type.tests.utils import createZODBPythonScript
from Persistence import PersistentMapping from Persistence import PersistentMapping
from zope.site.hooks import setSite from zope.component.hooks import setSite
class TestLocalizer(ERP5TypeTestCase): class TestLocalizer(ERP5TypeTestCase):
def afterSetUp(self): def afterSetUp(self):
......
...@@ -289,7 +289,7 @@ class TestProxyField(ERP5TypeTestCase): ...@@ -289,7 +289,7 @@ class TestProxyField(ERP5TypeTestCase):
python_script_id = "ERP5Site_testAccessProxyFieldProperty" python_script_id = "ERP5Site_testAccessProxyFieldProperty"
python_script_parameter = "proxy_field" python_script_parameter = "proxy_field"
python_script_body = """ python_script_body = """
print proxy_field.getRecursiveTemplateField().meta_type print (proxy_field.getRecursiveTemplateField().meta_type)
return printed return printed
""" """
skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript( skin_folder.manage_addProduct['PythonScripts'].manage_addPythonScript(
......
...@@ -6,5 +6,5 @@ portal.event_module.recurseCallMethod( ...@@ -6,5 +6,5 @@ portal.event_module.recurseCallMethod(
group_method_cost=1), group_method_cost=1),
min_depth=1, min_depth=1,
max_depth=1) max_depth=1)
print "Migration started with process id: %s" %active_process.getPath() print("Migration started with process id: %s" %active_process.getPath())
return printed return printed
...@@ -6,6 +6,6 @@ object_list = list(context.portal_catalog(parent_uid=uids, portal_type = "Email ...@@ -6,6 +6,6 @@ object_list = list(context.portal_catalog(parent_uid=uids, portal_type = "Email
for o in object_list: for o in object_list:
o_value = o.getObject() o_value = o.getObject()
if o is not None: if o is not None:
print o_value.getUrlString() print(o_value.getUrlString())
return printed return printed
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
# #
############################################################################## ##############################################################################
from __future__ import print_function
import unittest import unittest
from AccessControl.SecurityManagement import newSecurityManager from AccessControl.SecurityManagement import newSecurityManager
...@@ -131,12 +132,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -131,12 +132,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
match_string1 = 'data-gadget-editable="field_%s"' % field_id match_string1 = 'data-gadget-editable="field_%s"' % field_id
match_string2 = 'data-gadget-value="%s"' % html_quote(text_content) match_string2 = 'data-gadget-value="%s"' % html_quote(text_content)
if html_text.find(match_string1) == -1: if html_text.find(match_string1) == -1:
print html_text print(html_text)
print match_string1 print(match_string1)
return False return False
if html_text.find(match_string2) == -1: if html_text.find(match_string2) == -1:
print html_text print(html_text)
print match_string2 print(match_string2)
return False return False
return True return True
...@@ -156,13 +157,13 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -156,13 +157,13 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
match_string1 = 'data-gadget-editable="field_%s"' % field_id match_string1 = 'data-gadget-editable="field_%s"' % field_id
match_string2 = 'data-gadget-value="%s"' % html_quote(text_content) match_string2 = 'data-gadget-value="%s"' % html_quote(text_content)
if html_text.find(match_string1) == -1: if html_text.find(match_string1) == -1:
print html_text print(html_text)
print match_string1 print(match_string1)
import pdb; pdb.set_trace() import pdb; pdb.set_trace()
return False return False
if html_text.find(match_string2) == -1: if html_text.find(match_string2) == -1:
print html_text print(html_text)
print match_string2 print(match_string2)
import pdb; pdb.set_trace() import pdb; pdb.set_trace()
return False return False
return True return True
...@@ -182,12 +183,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional): ...@@ -182,12 +183,12 @@ class TestEditorField(ERP5TypeTestCase, ZopeTestCase.Functional):
match_string1 = "data-gadget-editable=" match_string1 = "data-gadget-editable="
match_string2 = 'data-gadget-value="%s"' % html_quote(text_content) match_string2 = 'data-gadget-value="%s"' % html_quote(text_content)
if html_text.find(match_string1) != -1: if html_text.find(match_string1) != -1:
print html_text print(html_text)
print match_string1 print(match_string1)
return False return False
if html_text.find(match_string2) == -1: if html_text.find(match_string2) == -1:
print html_text print(html_text)
print match_string2 print(match_string2)
return False return False
return True return True
......
...@@ -872,12 +872,10 @@ class TestDocument(TestDocumentMixin): ...@@ -872,12 +872,10 @@ class TestDocument(TestDocumentMixin):
self.tic() self.tic()
test_document_set = {document_1, document_2, document_3, person, web_page, organisation} test_document_set = {document_1, document_2, document_3, person, web_page, organisation}
def getAdvancedSearchTextResultList(searchable_text, portal_type=None,src__=0): def getAdvancedSearchTextResultList(searchable_text, portal_type=None):
kw = {'full_text': searchable_text} kw = {'full_text': searchable_text}
if portal_type is not None: if portal_type is not None:
kw['portal_type'] = portal_type kw['portal_type'] = portal_type
if src__==1:
print portal.portal_catalog(src__=src__,**kw)
result_list = [x.getObject() for x in portal.portal_catalog(**kw)] result_list = [x.getObject() for x in portal.portal_catalog(**kw)]
return [x for x in result_list if x in test_document_set] return [x for x in result_list if x in test_document_set]
......
...@@ -8,5 +8,5 @@ context.ERP5Site_checkDataWithScript("Base_callPreConvert", ...@@ -8,5 +8,5 @@ context.ERP5Site_checkDataWithScript("Base_callPreConvert",
tag="pre_convert", tag="pre_convert",
packet=2, packet=2,
id_list=["document_module", "image_module", "web_page_module"]) id_list=["document_module", "image_module", "web_page_module"])
print "OK" print("OK")
return printed return printed
...@@ -42,5 +42,5 @@ tiolive_logo_image = context.portal_catalog.getResultValue( ...@@ -42,5 +42,5 @@ tiolive_logo_image = context.portal_catalog.getResultValue(
if tiolive_logo_image is not None and tiolive_logo_image.getValidationState() == 'published': if tiolive_logo_image is not None and tiolive_logo_image.getValidationState() == 'published':
tiolive_logo_image.reject() tiolive_logo_image.reject()
print "Done" print("Done")
return printed return printed
...@@ -2,5 +2,9 @@ ...@@ -2,5 +2,9 @@
#portal_preferences = context.portal_preferences #portal_preferences = context.portal_preferences
#portal_preferences.manage_delObjects(['dms_system_preference_ui_tests', 'dms_preference_ui_tests']) #portal_preferences.manage_delObjects(['dms_system_preference_ui_tests', 'dms_preference_ui_tests'])
#context.portal_caches.clearAllCache() #context.portal_caches.clearAllCache()
print "Done" # Delete System Preference
#portal_preferences = context.portal_preferences
#portal_preferences.manage_delObjects(['dms_system_preference_ui_tests', 'dms_preference_ui_tests'])
#context.portal_caches.clearAllCache()
print("Done")
return printed return printed
...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPortalType(portal_type_list) ...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPortalType(portal_type_list)
if export_tsv: if export_tsv:
for i in result: for i in result:
print '\t'.join(['"%s"' % x for x in (i['reference'], i['language'], print('\t'.join(['"%s"' % x for x in (i['reference'], i['language'],
i['business_field'], i['business_field'],
i['title'], i['description'], i['title'], i['description'],
i['field_path'])]) i['field_path'])]))
return printed return printed
else: else:
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
......
...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPropertySheet(property_sheet_ ...@@ -2,10 +2,10 @@ result = context.GlossaryModule_getTermDictListFromPropertySheet(property_sheet_
if export_tsv: if export_tsv:
for i in result: for i in result:
print '\t'.join(['"%s"' % x for x in (i['reference'], i['language'], print('\t'.join(['"%s"' % x for x in (i['reference'], i['language'],
i['business_field'], i['business_field'],
i['title'], i['description'], i['title'], i['description'],
i['field_path'])]) i['field_path'])]))
return printed return printed
else: else:
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
......
...@@ -3,10 +3,10 @@ result = context.GlossaryModule_getTermDictListFromWorkflow(template_list) ...@@ -3,10 +3,10 @@ result = context.GlossaryModule_getTermDictListFromWorkflow(template_list)
if export_tsv: if export_tsv:
for i in result: for i in result:
print '\t'.join(['"%s"' % x for x in (i['reference'], i['language'], print('\t'.join(['"%s"' % x for x in (i['reference'], i['language'],
i['business_field'], i['business_field'],
i['title'], i['description'], i['title'], i['description'],
i['workflow_id'])]) i['workflow_id'])]))
return printed return printed
else: else:
portal_catalog = context.portal_catalog portal_catalog = context.portal_catalog
......
...@@ -24,7 +24,7 @@ def formatString(string): ...@@ -24,7 +24,7 @@ def formatString(string):
# po header # po header
now = DateTime().toZone('UTC').strftime("%Y-%m-%d %H:%M+0000") now = DateTime().toZone('UTC').strftime("%Y-%m-%d %H:%M+0000")
print MESSAGE_TEMPLATE % (dict(english='""', print(MESSAGE_TEMPLATE % (dict(english='""',
translation= translation=
r'''"Project-Id-Version: ERP5 Localized Interface\n" r'''"Project-Id-Version: ERP5 Localized Interface\n"
"POT-Creation-Date: %s\n" "POT-Creation-Date: %s\n"
...@@ -34,7 +34,7 @@ r'''"Project-Id-Version: ERP5 Localized Interface\n" ...@@ -34,7 +34,7 @@ r'''"Project-Id-Version: ERP5 Localized Interface\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
''' % (now, now, language))) ''' % (now, now, language))))
catalog = context.portal_catalog catalog = context.portal_catalog
for i in catalog(portal_type='Glossary Term', for i in catalog(portal_type='Glossary Term',
...@@ -63,18 +63,18 @@ for i in catalog(portal_type='Glossary Term', ...@@ -63,18 +63,18 @@ for i in catalog(portal_type='Glossary Term',
if not english_title: if not english_title:
raise ValueError('Title of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_title)) raise ValueError('Title of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_title))
if translated_title!=english_title: if translated_title!=english_title:
print formatMessage(english=formatString(english_title), print(formatMessage(english=formatString(english_title),
translation=formatString(translated_title), translation=formatString(translated_title),
term=term) term=term))
if translated_description: if translated_description:
if not english_description: if not english_description:
raise ValueError('Description of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_description)) raise ValueError('Description of corresponding English term(%s) to "%s" is empty.' % (english_relative_url, translated_description))
if translated_description!=english_description: if translated_description!=english_description:
print formatMessage(english=formatString(english_description), print(formatMessage(english=formatString(english_description),
translation=formatString(translated_description), translation=formatString(translated_description),
term=term) term=term))
RESPONSE = context.REQUEST.RESPONSE RESPONSE = context.REQUEST.RESPONSE
RESPONSE.setHeader('Content-disposition', 'attachment;filename=translation.po') RESPONSE.setHeader('Content-disposition', 'attachment;filename=translation.po')
......
...@@ -5,6 +5,6 @@ for i in context.getPortalObject().glossary_module.objectValues(): ...@@ -5,6 +5,6 @@ for i in context.getPortalObject().glossary_module.objectValues():
lang = lang_list[0] lang = lang_list[0]
i.setLanguage(lang) i.setLanguage(lang)
i.setCategoryList([x for x in i.categories if not x.startswith('language/')]) i.setCategoryList([x for x in i.categories if not x.startswith('language/')])
print i.getPath(), lang print(i.getPath(), lang)
print 'Migration finished.' print('Migration finished.')
return printed return printed
...@@ -22,28 +22,28 @@ for diff_object in sortDiffObjectList(diff_object_list): ...@@ -22,28 +22,28 @@ for diff_object in sortDiffObjectList(diff_object_list):
if getattr(diff_object, "error", None) is not None: if getattr(diff_object, "error", None) is not None:
print("<p>") print("<p>")
print("Error") print("Error")
print("(%s) -" % html_quote(diff_object.object_class)) print(("(%s) -" % html_quote(diff_object.object_class)))
if diff_object.object_class in link_configuration: if diff_object.object_class in link_configuration:
print(link_configuration[diff_object.object_class] % {"object_id": html_quote(diff_object.object_id)}) print((link_configuration[diff_object.object_class] % {"object_id": html_quote(diff_object.object_id)}))
else: else:
print(html_quote(diff_object.object_id)) print((html_quote(diff_object.object_id)))
print("</p>") print("</p>")
if detailed: if detailed:
print("<p>") print("<p>")
print(html_quote(diff_object.error)) print((html_quote(diff_object.error)))
print("</p>") print("</p>")
else: else:
print("<p>") print("<p>")
print(html_quote(diff_object.object_state)) print((html_quote(diff_object.object_state)))
print("(%s) -" % html_quote(diff_object.object_class)) print(("(%s) -" % html_quote(diff_object.object_class)))
if diff_object.object_class in link_configuration: if diff_object.object_class in link_configuration:
print(link_configuration[diff_object.object_class] % {"object_id": html_quote(diff_object.object_id)}) print((link_configuration[diff_object.object_class] % {"object_id": html_quote(diff_object.object_id)}))
else: else:
print(html_quote(diff_object.object_id)) print((html_quote(diff_object.object_id)))
print("</p>") print("</p>")
if detailed and getattr(diff_object, "data", None) is not None: if detailed and getattr(diff_object, "data", None) is not None:
print("<div>") print("<div>")
print(DiffFile(diff_object.data).toHTML()) print((DiffFile(diff_object.data).toHTML()))
print("</div>") print("</div>")
print("</div>") print("</div>")
return printed return printed
...@@ -2,14 +2,14 @@ def sortDiffObjectList(diff_object_list): ...@@ -2,14 +2,14 @@ def sortDiffObjectList(diff_object_list):
return sorted(diff_object_list, key=lambda x: (x.object_state, x.object_class, x.object_id)) return sorted(diff_object_list, key=lambda x: (x.object_state, x.object_class, x.object_id))
for diff_object in sortDiffObjectList(diff_object_list): for diff_object in sortDiffObjectList(diff_object_list):
print("%s (%s) - %s" % (diff_object.object_state, diff_object.object_class, diff_object.object_id)) print(("%s (%s) - %s" % (diff_object.object_state, diff_object.object_class, diff_object.object_id)))
if getattr(diff_object, "error", None) is not None: if getattr(diff_object, "error", None) is not None:
if detailed: if detailed:
print(" %s" % diff_object.error) print((" %s" % diff_object.error))
print("") print("")
else: else:
if detailed and getattr(diff_object, "data", None) is not None: if detailed and getattr(diff_object, "data", None) is not None:
print("%s" % diff_object.data.lstrip()) print(("%s" % diff_object.data.lstrip()))
print("") print("")
return printed return printed
# License: GPL # License: GPL
# Author: Lukasz Nowak <lukasz.nowak@ventis.com.pl> # Author: Lukasz Nowak <lukasz.nowak@ventis.com.pl>
# Copyright 2007 Ventis s. c. # Copyright 2007 Ventis s. c.
simulations_found = context.Base_getSimulationTree(start_path=start_path) simulations_found = context.Base_getSimulationTree(start_path=start_path)
if len(simulations_found) == 0: if len(simulations_found) == 0:
print 'No simulations related' print('No simulations related')
else: else:
for simulation_root in simulations_found.iterkeys(): for simulation_root in simulations_found:
print simulation_root print(simulation_root)
for simulation in simulations_found[simulation_root]: for simulation in simulations_found[simulation_root]:
print '\t',simulation.getPath(),simulation.getPortalType(), print('\t',simulation.getPath(),simulation.getPortalType(), end=' ')
if simulation.getPortalType() == 'Simulation Movement': if simulation.getPortalType() == 'Simulation Movement':
print simulation.getCausalityState(), print(simulation.getCausalityState(), end=' ')
else: else:
print 'nostate', print('nostate', end=' ')
print simulation.getCategoriesList() print(simulation.getCategoriesList())
return printed return printed
...@@ -172,10 +172,10 @@ def formatString(string): ...@@ -172,10 +172,10 @@ def formatString(string):
else: else:
return '\n'.join(['""']+[formatString(i) for i in line_list]) return '\n'.join(['""']+[formatString(i) for i in line_list])
print '''msgid "" print('''msgid ""
msgstr "Content-Type: text/plain; charset=UTF-8" msgstr "Content-Type: text/plain; charset=UTF-8"
''' ''')
MESSAGE_TEMPLATE = '''\ MESSAGE_TEMPLATE = '''\
%s %s
...@@ -188,7 +188,7 @@ for message in message_list: ...@@ -188,7 +188,7 @@ for message in message_list:
comment_list = message_dict[message] comment_list = message_dict[message]
comment_list.sort() comment_list.sort()
comment = '\n'.join([('#: %s' % i) for i in comment_list]) comment = '\n'.join([('#: %s' % i) for i in comment_list])
print MESSAGE_TEMPLATE % (comment, formatString(message)) print(MESSAGE_TEMPLATE % (comment, formatString(message)))
RESPONSE = context.REQUEST.RESPONSE RESPONSE = context.REQUEST.RESPONSE
RESPONSE.setHeader('Content-disposition', 'attachment;filename=translation.pot') RESPONSE.setHeader('Content-disposition', 'attachment;filename=translation.pot')
......
...@@ -48,7 +48,7 @@ recurse(o, callback, seldict) ...@@ -48,7 +48,7 @@ recurse(o, callback, seldict)
for selection_name in seldict.keys(): for selection_name in seldict.keys():
if len(seldict[selection_name]) != 1 or all_selections: if len(seldict[selection_name]) != 1 or all_selections:
print "'%s' [%s]"%(selection_name,len(seldict[selection_name])) print("'%s' [%s]"%(selection_name,len(seldict[selection_name])))
for form_name in seldict[selection_name]: for form_name in seldict[selection_name]:
print "\t%s"%(form_name,) print("\t%s"%(form_name,))
return printed return printed
...@@ -3,12 +3,12 @@ ...@@ -3,12 +3,12 @@
from erp5.component.module.Log import log from erp5.component.module.Log import log
log("Obsolete script, please use BaseType_copyRoleList instead") log("Obsolete script, please use BaseType_copyRoleList instead")
print 'cloning role information from' print('cloning role information from')
print from_type print(from_type)
if to_type_list == (): if to_type_list == ():
to_type_list = (to_type,) to_type_list = (to_type,)
print "to", to_type_list print("to", to_type_list)
context.portal_types[from_type].BaseType_copyRoleList(remove_existing_roles=True, context.portal_types[from_type].BaseType_copyRoleList(remove_existing_roles=True,
portal_type_list=to_type_list) portal_type_list=to_type_list)
......
...@@ -2,11 +2,11 @@ ...@@ -2,11 +2,11 @@
""" """
portal_skin = context.REQUEST.get('portal_skin', 'View') portal_skin = context.REQUEST.get('portal_skin', 'View')
print "<html>" print("<html>")
for field_path, field in context.ZopeFind( for field_path, field in context.ZopeFind(
context.portal_skins, obj_metatypes=['ProxyField'], search_sub=1): context.portal_skins, obj_metatypes=['ProxyField'], search_sub=1):
if field.getTemplateField() is None: if field.getTemplateField() is None:
print '<a href="%s/%s/manage_main?portal_skin=%s">%s</a><br />' % (context.absolute_url(), field_path, portal_skin, field_path) print('<a href="%s/%s/manage_main?portal_skin=%s">%s</a><br />' % (context.absolute_url(), field_path, portal_skin, field_path))
print "</html>" print("</html>")
return printed return printed
...@@ -7,9 +7,9 @@ for form_path, form in context.ZopeFind( ...@@ -7,9 +7,9 @@ for form_path, form in context.ZopeFind(
try: try:
groups = form.get_groups() groups = form.get_groups()
except AttributeError as e: except AttributeError as e:
print "%s is broken: %s" % (form_path, e) print("%s is broken: %s" % (form_path, e))
if 'not_assigned' in groups: if 'not_assigned' in groups:
print 'Not assigned fields in %s: %s' % (form_path, print('Not assigned fields in %s: %s' % (form_path,
[f.getId() for f in form.get_fields_in_group('not_assigned')]) [f.getId() for f in form.get_fields_in_group('not_assigned')]))
return printed return printed
...@@ -14,14 +14,14 @@ for field_path, field in context.ZopeFind( ...@@ -14,14 +14,14 @@ for field_path, field in context.ZopeFind(
continue continue
if not (field.get_value('proxy_listbox_ids') or field.get_value('columns')): if not (field.get_value('proxy_listbox_ids') or field.get_value('columns')):
print field_path print(field_path)
continue continue
for path, name in field.get_value('proxy_listbox_ids'): for path, name in field.get_value('proxy_listbox_ids'):
if context.restrictedTraverse(path, None) is None: if context.restrictedTraverse(path, None) is None:
print ' PROBLEM: field %s uses an invalid form for %s: %s' % (field_path, name, path) print(' PROBLEM: field %s uses an invalid form for %s: %s' % (field_path, name, path))
else: else:
proxy_listbox = context.restrictedTraverse(path) proxy_listbox = context.restrictedTraverse(path)
if proxy_listbox.meta_type not in ('ProxyField', 'ListBox'): if proxy_listbox.meta_type not in ('ProxyField', 'ListBox'):
print ' PROBLEM: field %s uses an invalid proxy with %s meta_type' % (field_path, proxy_listbox.meta_type) print(' PROBLEM: field %s uses an invalid proxy with %s meta_type' % (field_path, proxy_listbox.meta_type))
return printed return printed
...@@ -6,7 +6,7 @@ container.REQUEST.RESPONSE.setHeader('content-type', 'text/html') ...@@ -6,7 +6,7 @@ container.REQUEST.RESPONSE.setHeader('content-type', 'text/html')
# make sure context is the skins tool # make sure context is the skins tool
stool = context.portal_skins stool = context.portal_skins
print '<html><body>' print('<html><body>')
skins_by_name = {} skins_by_name = {}
for skin_key, skin_path_list in stool.getSkinPaths(): for skin_key, skin_path_list in stool.getSkinPaths():
...@@ -24,9 +24,9 @@ for skin_key, skin_path_list in stool.getSkinPaths(): ...@@ -24,9 +24,9 @@ for skin_key, skin_path_list in stool.getSkinPaths():
for skin_name, location_list in skins_by_name.items(): for skin_name, location_list in skins_by_name.items():
if len(location_list) > 1: if len(location_list) > 1:
print skin_name, '<br/>' print(skin_name, '<br/>')
for location in location_list: for location in location_list:
print "&nbsp;" * 3, '<a href="%s/%s/%s/manage_main">%s</a><br/>' % (stool.absolute_url(), location, skin_name, location) print("&nbsp;" * 3, '<a href="%s/%s/%s/manage_main">%s</a><br/>' % (stool.absolute_url(), location, skin_name, location))
print '</body></html>' print('</body></html>')
return printed return printed
...@@ -5,7 +5,7 @@ if template_tool.getDiffFilterScriptList(): ...@@ -5,7 +5,7 @@ if template_tool.getDiffFilterScriptList():
else: else:
from erp5.component.module.DiffUtils import DiffFile from erp5.component.module.DiffUtils import DiffFile
print '<div style="color: black">' print('<div style="color: black">')
# XXX: ERP5VCS_doCreateJavaScriptStatus should send lists # XXX: ERP5VCS_doCreateJavaScriptStatus should send lists
if isinstance(added, basestring): if isinstance(added, basestring):
...@@ -19,20 +19,20 @@ for f in modified: ...@@ -19,20 +19,20 @@ for f in modified:
diff = DiffFile(vcs_tool.diff(f)) diff = DiffFile(vcs_tool.diff(f))
if not diff: if not diff:
continue continue
print '<input name="modified" value="%s" type="checkbox" checked="checked" />'% f print('<input name="modified" value="%s" type="checkbox" checked="checked" />'% f)
print vcs_tool.getHeader(f) print(vcs_tool.getHeader(f))
print diff.toHTML() print(diff.toHTML())
print "<hr/><br/>" print("<hr/><br/>")
for f in added: for f in added:
print '<input name="added" value="%s" type="checkbox" checked="checked" />'% f print('<input name="added" value="%s" type="checkbox" checked="checked" />'% f)
print vcs_tool.getHeader(f) print(vcs_tool.getHeader(f))
print "<br/><span style='color: green;'>File Added</span><br/><br/><hr/><br/>" print("<br/><span style='color: green;'>File Added</span><br/><br/><hr/><br/>")
for f in removed: for f in removed:
print '<input name="removed" value="%s" type="checkbox" checked="checked" />'% f print('<input name="removed" value="%s" type="checkbox" checked="checked" />'% f)
print vcs_tool.getHeader(f) print(vcs_tool.getHeader(f))
print "<br/><span style='color: red;'>File Removed</span><br/><br/><hr/><br/>" print("<br/><span style='color: red;'>File Removed</span><br/><br/><hr/><br/>")
print '</div>' print('</div>')
return printed return printed
...@@ -9,10 +9,10 @@ from string import capitalize ...@@ -9,10 +9,10 @@ from string import capitalize
def addAction(portal_type, portal_type_type, country, amortisation_method): def addAction(portal_type, portal_type_type, country, amortisation_method):
print 'Adding UI tab "Amortisation Details" for method %s on portal_type %s... ' % (amortisation_method,portal_type), print('Adding UI tab "Amortisation Details" for method %s on portal_type %s... ' % (amortisation_method,portal_type), end=' ')
id = "%s_%s_amortisation_details_view" % (country, amortisation_method) id = "%s_%s_amortisation_details_view" % (country, amortisation_method)
if id in [x.id for x in portal_type.listActions()]: if id in [x.id for x in portal_type.listActions()]:
print "Already exists" print("Already exists")
else: else:
if portal_type_type == "Immobilisation": if portal_type_type == "Immobilisation":
action = "%s_Immobilisation_viewDetails" % amortisation_method action = "%s_Immobilisation_viewDetails" % amortisation_method
...@@ -27,7 +27,7 @@ def addAction(portal_type, portal_type_type, country, amortisation_method): ...@@ -27,7 +27,7 @@ def addAction(portal_type, portal_type_type, country, amortisation_method):
permission = ('View',), permission = ('View',),
category = "object_view", category = "object_view",
visible = 1) visible = 1)
print "OK" print("OK")
return printed return printed
...@@ -44,10 +44,10 @@ amortisation_method = "".join(tokens[1:]) ...@@ -44,10 +44,10 @@ amortisation_method = "".join(tokens[1:])
for portal_type in context.portal_types.objectValues(): for portal_type in context.portal_types.objectValues():
# Check if the portal_type is Immobilisation # Check if the portal_type is Immobilisation
if portal_type.id == "Immobilisation": if portal_type.id == "Immobilisation":
print addAction(portal_type, "Immobilisation", country, amortisation_method), print(addAction(portal_type, "Immobilisation", country, amortisation_method), end=' ')
else: else:
# Check if the portal_type is amortisable # Check if the portal_type is amortisable
if "immobilise" in [x.id for x in portal_type.listActions()]: if "immobilise" in [x.id for x in portal_type.listActions()]:
print addAction(portal_type, "Item", country, amortisation_method), print(addAction(portal_type, "Item", country, amortisation_method), end=' ')
return printed return printed
...@@ -10,18 +10,18 @@ actions_to_add = [ ...@@ -10,18 +10,18 @@ actions_to_add = [
] ]
print 'Adding Immobilisation Item Actions to Portal Type %s :' % context.getId() print('Adding Immobilisation Item Actions to Portal Type %s :' % context.getId())
action_list = context.listActions() action_list = context.listActions()
for action_to_add in actions_to_add: for action_to_add in actions_to_add:
print "- Adding Action '%s (%s)'... " % (action_to_add['id'],action_to_add['name']), print("- Adding Action '%s (%s)'... " % (action_to_add['id'],action_to_add['name']), end=' ')
found = 0 found = 0
for action in action_list: for action in action_list:
if getattr(action, 'id', None) == action_to_add['id']: if getattr(action, 'id', None) == action_to_add['id']:
print 'already exists' print('already exists')
found = 1 found = 1
if not found: if not found:
context.addAction(**action_to_add) context.addAction(**action_to_add)
print "OK" print("OK")
print print()
return printed return printed
...@@ -8,7 +8,7 @@ amortisation_method_view = 'amortisation_method_view' ...@@ -8,7 +8,7 @@ amortisation_method_view = 'amortisation_method_view'
action_list = context.listActions() action_list = context.listActions()
print "Making portal type '%s' an Immobilisation Movement :" % context.getId() print("Making portal type '%s' an Immobilisation Movement :" % context.getId())
# Add a view for each amortisation method # Add a view for each amortisation method
amortisation_method_list = context.Immobilisation_getAmortisationMethodList() amortisation_method_list = context.Immobilisation_getAmortisationMethodList()
for method in amortisation_method_list: for method in amortisation_method_list:
...@@ -17,13 +17,13 @@ for method in amortisation_method_list: ...@@ -17,13 +17,13 @@ for method in amortisation_method_list:
title = method[1].title or id title = method[1].title or id
action_id = view_id_basis % (region, id) action_id = view_id_basis % (region, id)
print "- Adding View for method '%s'... " % title, print("- Adding View for method '%s'... " % title, end=' ')
# Check if the action already exists # Check if the action already exists
exists = 0 exists = 0
for action in action_list: for action in action_list:
if getattr(action, "id", None) == action_id: if getattr(action, "id", None) == action_id:
print "already exists" print("already exists")
exists = 1 exists = 1
if not exists: if not exists:
...@@ -37,8 +37,8 @@ for method in amortisation_method_list: ...@@ -37,8 +37,8 @@ for method in amortisation_method_list:
permission = view_permissions_basis, permission = view_permissions_basis,
category = "object_view", category = "object_view",
visible=1) visible=1)
print "OK" print("OK")
print print()
return printed return printed
...@@ -18,18 +18,18 @@ actions_to_add = [ ...@@ -18,18 +18,18 @@ actions_to_add = [
] ]
print 'Adding Immobilisation Item Actions to Portal Type %s :' % context.getId() print('Adding Immobilisation Item Actions to Portal Type %s :' % context.getId())
action_list = context.listActions() action_list = context.listActions()
for action_to_add in actions_to_add: for action_to_add in actions_to_add:
print "- Adding Action '%s (%s)'... " % (action_to_add['id'],action_to_add['name']), print("- Adding Action '%s (%s)'... " % (action_to_add['id'],action_to_add['name']), end=' ')
found = 0 found = 0
for action in action_list: for action in action_list:
if getattr(action, 'id', None) == action_to_add['id']: if getattr(action, 'id', None) == action_to_add['id']:
print 'already exists' print('already exists')
found = 1 found = 1
if not found: if not found:
context.addAction(**action_to_add) context.addAction(**action_to_add)
print "OK" print("OK")
print print()
return printed return printed
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>permission_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>role_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>group_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Provides access to workflow history</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_error_message</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission_list</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>role_list</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Workflow Variable" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_local_properties</string> </key>
<value>
<tuple>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>permission_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>role_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
<dictionary>
<item>
<key> <string>id</string> </key>
<value> <string>group_list</string> </value>
</item>
<item>
<key> <string>type</string> </key>
<value> <string>lines</string> </value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key> <string>automatic_update</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Provides access to workflow history</string> </value>
</item>
<item>
<key> <string>for_catalog</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>group_list</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>variable_error_message</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>permission_list</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Workflow Variable</string> </value>
</item>
<item>
<key> <string>role_list</string> </key>
<value>
<tuple/>
</value>
</item>
<item>
<key> <string>status_included</string> </key>
<value> <int>0</int> </value>
</item>
<item>
<key> <string>title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>variable_default_expression</string> </key>
<value> <string>state_change/getHistory</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
user_preferences = context.KnowledgeBox_getDefaultPreferencesDict() user_preferences = context.KnowledgeBox_getDefaultPreferencesDict()
print user_preferences print(user_preferences)
return printed return printed
...@@ -17,5 +17,5 @@ if remove_existing_pads: ...@@ -17,5 +17,5 @@ if remove_existing_pads:
user_knowledge_pad_list = context.ERP5Site_getKnowledgePadListForUser(mode = mode) user_knowledge_pad_list = context.ERP5Site_getKnowledgePadListForUser(mode = mode)
context.knowledge_pad_module.manage_delObjects([x.getId() for x in user_knowledge_pad_list]) context.knowledge_pad_module.manage_delObjects([x.getId() for x in user_knowledge_pad_list])
print "Done" print("Done")
return printed return printed
...@@ -37,16 +37,16 @@ document_list = portal.portal_catalog( ...@@ -37,16 +37,16 @@ document_list = portal.portal_catalog(
path_list = [software_product_rurl] path_list = [software_product_rurl]
print " Processing File List \r===============================\r" print(" Processing File List \r===============================\r")
for document_brain in document_list: for document_brain in document_list:
document = document_brain.getObject() document = document_brain.getObject()
if document.getFollowUp(): if document.getFollowUp():
continue continue
print document.getId() print(document.getId())
new_document = document.Base_createCloneDocument(batch_mode=True) new_document = document.Base_createCloneDocument(batch_mode=True)
new_id = base_id + new_document.getReference().replace('.', '_') new_id = base_id + new_document.getReference().replace('.', '_')
if new_id in new_document.getParentValue(): if new_id in new_document.getParentValue():
print " deleting %s" % new_id print(" deleting %s" % new_id)
new_document.getParentValue().manage_delObjects([new_id]) new_document.getParentValue().manage_delObjects([new_id])
new_document.setId(new_id) new_document.setId(new_id)
path_list.append(new_document.getRelativeUrl()) path_list.append(new_document.getRelativeUrl())
...@@ -54,8 +54,8 @@ for document_brain in document_list: ...@@ -54,8 +54,8 @@ for document_brain in document_list:
# new_document.setVersion(base_id + "dev") # new_document.setVersion(base_id + "dev")
new_document.setFollowUp(software_product_rurl) new_document.setFollowUp(software_product_rurl)
print "\r\r Here is your path list\r===============================\r\r" print("\r\r Here is your path list\r===============================\r\r")
print '\r'.join(path_list) print('\r'.join(path_list))
print "\r\r===============================\r\r" print("\r\r===============================\r\r")
print " Done" print(" Done")
return printed return printed
...@@ -23,6 +23,8 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -23,6 +23,8 @@ var EnemyDroneAPI = /** @class */ (function () {
this._drone_dict_list = []; this._drone_dict_list = [];
this._acceleration = DEFAULT_ACCELERATION; this._acceleration = DEFAULT_ACCELERATION;
this._collision_sector = COLLISION_SECTOR; this._collision_sector = COLLISION_SECTOR;
this._is_landing = false;
this._is_ready_to_fly = true;
} }
/* /*
** Function called on start phase of the drone, just before onStart AI script ** Function called on start phase of the drone, just before onStart AI script
...@@ -49,7 +51,6 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -49,7 +51,6 @@ var EnemyDroneAPI = /** @class */ (function () {
if (drone._maxSinkRate > drone._maxSpeed) { if (drone._maxSinkRate > drone._maxSpeed) {
throw new Error('max sink rate cannot be superior to max speed'); throw new Error('max sink rate cannot be superior to max speed');
} }
drone._maxOrientation = this.getMaxOrientation();
return; return;
}; };
/* /*
...@@ -57,10 +58,12 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -57,10 +58,12 @@ var EnemyDroneAPI = /** @class */ (function () {
*/ */
EnemyDroneAPI.prototype.internal_update = function (context, delta_time) { EnemyDroneAPI.prototype.internal_update = function (context, delta_time) {
context._speed += context._acceleration * delta_time / 1000; context._speed += context._acceleration * delta_time / 1000;
if (context._speed > context._maxSpeed) if (context._speed > context._maxSpeed) {
context._speed = context._maxSpeed; context._speed = context._maxSpeed;
if (context._speed < -context._maxSpeed) }
if (context._speed < -context._maxSpeed) {
context._speed = -context._maxSpeed; context._speed = -context._maxSpeed;
}
var updateSpeed = context._speed * delta_time / 1000; var updateSpeed = context._speed * delta_time / 1000;
if (context._direction.x !== 0 || if (context._direction.x !== 0 ||
context._direction.y !== 0 || context._direction.y !== 0 ||
...@@ -68,13 +71,9 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -68,13 +71,9 @@ var EnemyDroneAPI = /** @class */ (function () {
context._controlMesh.position.addInPlace( context._controlMesh.position.addInPlace(
new BABYLON.Vector3(context._direction.x * updateSpeed, new BABYLON.Vector3(context._direction.x * updateSpeed,
context._direction.y * updateSpeed, context._direction.y * updateSpeed,
context._direction.z * updateSpeed)); context._direction.z * updateSpeed)
);
} }
var orientationValue = context._maxOrientation *
(context._speed / context._maxSpeed);
context._mesh.rotation = new BABYLON.Vector3(
orientationValue * context._direction.z, 0,
-orientationValue * context._direction.x);
context._controlMesh.computeWorldMatrix(true); context._controlMesh.computeWorldMatrix(true);
context._mesh.computeWorldMatrix(true); context._mesh.computeWorldMatrix(true);
return; return;
...@@ -119,7 +118,9 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -119,7 +118,9 @@ var EnemyDroneAPI = /** @class */ (function () {
EnemyDroneAPI.prototype.internal_setTargetCoordinates = EnemyDroneAPI.prototype.internal_setTargetCoordinates =
function (drone, coordinates) { function (drone, coordinates) {
if (!drone._canPlay) return; if (!drone._canPlay) {
return;
}
var x = coordinates.x, y = coordinates.y, z = coordinates.z; var x = coordinates.x, y = coordinates.y, z = coordinates.z;
if (isNaN(x) || isNaN(y) || isNaN(z)) { if (isNaN(x) || isNaN(y) || isNaN(z)) {
throw new Error('Target coordinates must be numbers'); throw new Error('Target coordinates must be numbers');
...@@ -240,7 +241,7 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -240,7 +241,7 @@ var EnemyDroneAPI = /** @class */ (function () {
' return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2 + (a.z - b.z) ** 2);\n' + ' return Math.sqrt((a.x - b.x) ** 2 + (a.y - b.y) ** 2 + (a.z - b.z) ** 2);\n' +
'}\n' + '}\n' +
'\n' + '\n' +
'me.onStart = function () {\n' + 'me.onStart = function (timestamp) {\n' +
' me.setDirection(0,0,0);\n' + ' me.setDirection(0,0,0);\n' +
' return;\n' + ' return;\n' +
'\n' + '\n' +
...@@ -279,20 +280,20 @@ var EnemyDroneAPI = /** @class */ (function () { ...@@ -279,20 +280,20 @@ var EnemyDroneAPI = /** @class */ (function () {
EnemyDroneAPI.prototype.getMaxAcceleration = function () { EnemyDroneAPI.prototype.getMaxAcceleration = function () {
return this._flight_parameters.drone.maxAcceleration; return this._flight_parameters.drone.maxAcceleration;
}; };
EnemyDroneAPI.prototype.getMaxOrientation = function () { EnemyDroneAPI.prototype.getMaxCommandFrequency = function () {
//TODO should be a game parameter (but how to force value to PI quarters?) return Infinity;
return Math.PI / 4;
}; };
EnemyDroneAPI.prototype.triggerParachute = function (drone) { EnemyDroneAPI.prototype.land = function (drone) {
var drone_pos = drone.getCurrentPosition(); var drone_pos = drone.getCurrentPosition();
drone.setTargetCoordinates(drone_pos.latitude, drone_pos.longitude, 5); drone.setTargetCoordinates(drone_pos.latitude, drone_pos.longitude, 0);
this._is_ready_to_fly = false;
this._is_landing = true;
}; };
EnemyDroneAPI.prototype.landed = function (drone) { EnemyDroneAPI.prototype.isReadyToFly = function () {
var drone_pos = drone.getCurrentPosition(); return this._is_ready_to_fly;
return Math.floor(drone_pos.altitude) < 10;
}; };
EnemyDroneAPI.prototype.exit = function () { EnemyDroneAPI.prototype.isLanding = function () {
return; return this._is_landing;
}; };
EnemyDroneAPI.prototype.getInitialAltitude = function () { EnemyDroneAPI.prototype.getInitialAltitude = function () {
return 0; return 0;
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.46035.33513.61849</string> </value> <value> <string>1014.60631.26636.59528</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697031010.99</float> <float>1709288499.16</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -31,6 +31,8 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -31,6 +31,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
this._loiter_radius = 100; this._loiter_radius = 100;
//this._start_altitude = 0; //this._start_altitude = 0;
this._loiter_mode = false; this._loiter_mode = false;
this._is_landing = false;
this._is_ready_to_fly = true;
this._drone_dict_list = []; this._drone_dict_list = [];
} }
/* /*
...@@ -86,45 +88,19 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -86,45 +88,19 @@ var FixedWingDroneAPI = /** @class */ (function () {
if (drone._maxClimbRate > drone._maxSpeed) { if (drone._maxClimbRate > drone._maxSpeed) {
throw new Error('max climb rate cannot be superior to max speed'); throw new Error('max climb rate cannot be superior to max speed');
} }
drone._maxOrientation = this.getMaxOrientation(); drone._maxCommandFrequency = this.getMaxCommandFrequency();
if (drone._maxCommandFrequency <= 0) {
throw new Error('max command frequence must be superior to 0');
}
return; return;
}; };
/* /*
** Function called on every drone update, right before onUpdate AI script ** Function called on every drone update, right before onUpdate AI script
*/ */
FixedWingDroneAPI.prototype.internal_update = function (context, delta_time) { FixedWingDroneAPI.prototype.internal_update = function (context, delta_time) {
var diff, newrot, orientationValue, rotStep;
//TODO rotation
if (context._rotationTarget) {
rotStep = BABYLON.Vector3.Zero();
diff = context._rotationTarget.subtract(context._controlMesh.rotation);
rotStep.x = (diff.x >= 1) ? 1 : diff.x;
rotStep.y = (diff.y >= 1) ? 1 : diff.y;
rotStep.z = (diff.z >= 1) ? 1 : diff.z;
if (rotStep === BABYLON.Vector3.Zero()) {
context._rotationTarget = null;
return;
}
newrot = new BABYLON.Vector3(context._controlMesh.rotation.x +
(rotStep.x * context._rotationSpeed),
context._controlMesh.rotation.y +
(rotStep.y * context._rotationSpeed),
context._controlMesh.rotation.z +
(rotStep.z * context._rotationSpeed)
);
context._controlMesh.rotation = newrot;
}
this._updateSpeed(context, delta_time); this._updateSpeed(context, delta_time);
this._updatePosition(context, delta_time); this._updatePosition(context, delta_time);
//TODO rotation
orientationValue = context._maxOrientation *
(context._speed / context._maxSpeed);
context._mesh.rotation =
new BABYLON.Vector3(orientationValue * context._direction.z, 0,
-orientationValue * context._direction.x);
context._controlMesh.computeWorldMatrix(true); context._controlMesh.computeWorldMatrix(true);
context._mesh.computeWorldMatrix(true); context._mesh.computeWorldMatrix(true);
}; };
...@@ -144,7 +120,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -144,7 +120,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
'latitude' : drone_position.latitude, 'latitude' : drone_position.latitude,
'longitude' : drone_position.longitude, 'longitude' : drone_position.longitude,
'yaw': drone.getYaw(), 'yaw': drone.getYaw(),
'speed': drone.getAirSpeed(), 'speed': drone.getSpeed(),
'climbRate': drone.getClimbRate() 'climbRate': drone.getClimbRate()
}; };
_this._drone_dict_list[_this._id] = drone_info; _this._drone_dict_list[_this._id] = drone_info;
...@@ -158,7 +134,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -158,7 +134,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
}; };
FixedWingDroneAPI.prototype._updateSpeed = function (drone, delta_time) { FixedWingDroneAPI.prototype._updateSpeed = function (drone, delta_time) {
var speed = drone.getAirSpeed(), speedDiff, speedUpdate; var speed = drone.get3DSpeed(), speedDiff, speedUpdate;
if (speed !== this._targetSpeed) { if (speed !== this._targetSpeed) {
speedDiff = this._targetSpeed - speed; speedDiff = this._targetSpeed - speed;
speedUpdate = drone._acceleration * delta_time / 1000; speedUpdate = drone._acceleration * delta_time / 1000;
...@@ -231,7 +207,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -231,7 +207,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed = this._getVerticalSpeed(drone); verticalSpeed = this._getVerticalSpeed(drone);
groundSpeed = Math.sqrt( groundSpeed = Math.sqrt(
Math.pow(drone.getAirSpeed(), 2) - Math.pow(verticalSpeed, 2) Math.pow(drone.get3DSpeed(), 2) - Math.pow(verticalSpeed, 2)
); );
distance = (groundSpeed * delta_time / 1000) / R; distance = (groundSpeed * delta_time / 1000) / R;
...@@ -240,7 +216,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -240,7 +216,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
newLatRad = Math.asin( newLatRad = Math.asin(
currentSinLat * distanceCos + currentSinLat * distanceCos +
currentCosLat * distanceSin * Math.cos(newYawRad) currentCosLat * distanceSin * Math.cos(newYawRad)
); );
newLonRad = currentLonRad + Math.atan2( newLonRad = currentLonRad + Math.atan2(
Math.sin(newYawRad) * distanceSin * currentCosLat, Math.sin(newYawRad) * distanceSin * currentCosLat,
...@@ -256,10 +232,10 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -256,10 +232,10 @@ var FixedWingDroneAPI = /** @class */ (function () {
// swap y and z axis so z axis represents altitude // swap y and z axis so z axis represents altitude
drone._controlMesh.position.addInPlace(new BABYLON.Vector3( drone._controlMesh.position.addInPlace(new BABYLON.Vector3(
Math.abs(newCoordinates.x - drone.position.x) * Math.abs(newCoordinates.x - drone.position.x) *
(newCoordinates.x < drone.position.x ? -1 : 1), (newCoordinates.x < drone.position.x ? -1 : 1),
verticalSpeed * delta_time / 1000, verticalSpeed * delta_time / 1000,
Math.abs(newCoordinates.y - drone.position.y) * Math.abs(newCoordinates.y - drone.position.y) *
(newCoordinates.y < drone.position.y ? -1 : 1) (newCoordinates.y < drone.position.y ? -1 : 1)
)); ));
yawToDirection = this._toRad(-newYaw + 90); yawToDirection = this._toRad(-newYaw + 90);
drone.setDirection( drone.setDirection(
...@@ -293,40 +269,28 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -293,40 +269,28 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed = this._computeVerticalSpeed( verticalSpeed = this._computeVerticalSpeed(
altitudeDiff, altitudeDiff,
this.getMaxClimbRate(), this.getMaxClimbRate(),
drone.getAirSpeed(), drone.get3DSpeed(),
this.getMaxPitchAngle() this.getMaxPitchAngle()
); );
} else { } else {
verticalSpeed = -this._computeVerticalSpeed( verticalSpeed = -this._computeVerticalSpeed(
Math.abs(altitudeDiff), Math.abs(altitudeDiff),
this.getMaxSinkRate(), this.getMaxSinkRate(),
drone.getAirSpeed(), drone.get3DSpeed(),
-this.getMinPitchAngle() -this.getMinPitchAngle()
); );
} }
return verticalSpeed; return verticalSpeed;
}; };
FixedWingDroneAPI.prototype.setRotation = function (drone, x, y, z) {
//TODO rotation
drone._rotationTarget = new BABYLON.Vector3(x, z, y);
};
FixedWingDroneAPI.prototype.setRotationBy = function (drone, x, y, z) {
//TODO rotation
drone._rotationTarget = new BABYLON.Vector3(drone.rotation.x + x,
drone.rotation.y + z,
drone.rotation.z + y);
};
FixedWingDroneAPI.prototype.setSpeed = function (drone, speed) { FixedWingDroneAPI.prototype.setSpeed = function (drone, speed) {
this._targetSpeed = Math.max( this._targetSpeed = Math.max(
Math.min(speed, this.getMaxSpeed()), Math.min(speed, this.getMaxSpeed()),
this.getMinSpeed() this.getMinSpeed()
); );
drone._acceleration = (this._targetSpeed > drone.getAirSpeed()) ? drone._acceleration = (this._targetSpeed > drone.get3DSpeed()) ?
this.getMaxAcceleration() : -this.getMaxDeceleration(); this.getMaxAcceleration() : -this.getMaxDeceleration();
}; };
FixedWingDroneAPI.prototype.setStartingPosition = function (drone, x, y, z) { FixedWingDroneAPI.prototype.setStartingPosition = function (drone, x, y, z) {
...@@ -345,7 +309,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -345,7 +309,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
}; };
FixedWingDroneAPI.prototype.internal_setTargetCoordinates = FixedWingDroneAPI.prototype.internal_setTargetCoordinates =
function (drone, coordinates, radius) { function (drone, coordinates, speed, radius) {
if (radius) { if (radius) {
this._loiter_mode = true; this._loiter_mode = true;
if (radius >= LOITER_LIMIT) { if (radius >= LOITER_LIMIT) {
...@@ -354,6 +318,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -354,6 +318,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
} else { } else {
this._loiter_mode = false; this._loiter_mode = false;
} }
this.setSpeed(drone, speed);
}; };
FixedWingDroneAPI.prototype.sendMsg = function (msg, to) { FixedWingDroneAPI.prototype.sendMsg = function (msg, to) {
...@@ -489,14 +454,13 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -489,14 +454,13 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI.prototype.getMaxClimbRate = function () { FixedWingDroneAPI.prototype.getMaxClimbRate = function () {
return this._flight_parameters.drone.maxClimbRate; return this._flight_parameters.drone.maxClimbRate;
}; };
FixedWingDroneAPI.prototype.getMaxOrientation = function () { FixedWingDroneAPI.prototype.getMaxCommandFrequency = function () {
//TODO should be a game parameter (but how to force value to PI quarters?) return this._flight_parameters.drone.maxCommandFrequency;
return Math.PI / 4;
}; };
FixedWingDroneAPI.prototype.getYawVelocity = function (drone) { FixedWingDroneAPI.prototype.getYawVelocity = function (drone) {
return 360 * EARTH_GRAVITY * return 360 * EARTH_GRAVITY *
Math.tan(this._toRad(this.getMaxRollAngle())) / Math.tan(this._toRad(this.getMaxRollAngle())) /
(2 * Math.PI * drone.getAirSpeed()); (2 * Math.PI * drone.get3DSpeed());
}; };
FixedWingDroneAPI.prototype.getYaw = function (drone) { FixedWingDroneAPI.prototype.getYaw = function (drone) {
var direction = drone.worldDirection; var direction = drone.worldDirection;
...@@ -522,7 +486,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -522,7 +486,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
var maxVerticalSpeed = var maxVerticalSpeed =
Math.min(altitude_diff, Math.min(max_climb_rate, speed)); Math.min(altitude_diff, Math.min(max_climb_rate, speed));
return (this._toDeg(Math.asin(maxVerticalSpeed / speed)) > max_pitch) ? return (this._toDeg(Math.asin(maxVerticalSpeed / speed)) > max_pitch) ?
speed * Math.sin(this._toRad(max_pitch)) speed * Math.sin(this._toRad(max_pitch))
: maxVerticalSpeed; : maxVerticalSpeed;
}; };
FixedWingDroneAPI.prototype._toRad = function (angle) { FixedWingDroneAPI.prototype._toRad = function (angle) {
...@@ -532,25 +496,34 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -532,25 +496,34 @@ var FixedWingDroneAPI = /** @class */ (function () {
return angle * 180 / Math.PI; return angle * 180 / Math.PI;
}; };
FixedWingDroneAPI.prototype.getClimbRate = function (drone) { FixedWingDroneAPI.prototype.getClimbRate = function (drone) {
return drone.worldDirection.y * drone.getAirSpeed(); return drone.worldDirection.y * drone.get3DSpeed();
}; };
FixedWingDroneAPI.prototype.getGroundSpeed = function (drone) { FixedWingDroneAPI.prototype.getSpeed = function (drone) {
var direction = drone.worldDirection; var direction = drone.worldDirection;
return Math.sqrt( return Math.sqrt(
Math.pow(direction.x * drone.getAirSpeed(), 2) + Math.pow(direction.x * drone.get3DSpeed(), 2) +
Math.pow(direction.z * drone.getAirSpeed(), 2) Math.pow(direction.z * drone.get3DSpeed(), 2)
); );
}; };
FixedWingDroneAPI.prototype.triggerParachute = function (drone) { FixedWingDroneAPI.prototype.takeOff = function () {
var drone_pos = drone.getCurrentPosition(); return console.log("Fixed-wing drones can only be taken off manually.");
drone.setTargetCoordinates(drone_pos.latitude, drone_pos.longitude, 5);
}; };
FixedWingDroneAPI.prototype.landed = function (drone) { FixedWingDroneAPI.prototype.land = function (drone) {
var drone_pos = drone.getCurrentPosition(); var drone_pos = drone.getCurrentPosition();
return Math.floor(drone_pos.altitude) < 10; drone.setTargetCoordinates(
drone_pos.latitude,
drone_pos.longitude,
0,
drone.get3DSpeed()
);
this._is_ready_to_fly = false;
this._is_landing = true;
}; };
FixedWingDroneAPI.prototype.exit = function () { FixedWingDroneAPI.prototype.isReadyToFly = function () {
return; return this._is_ready_to_fly;
};
FixedWingDroneAPI.prototype.isLanding = function () {
return this._is_landing;
}; };
FixedWingDroneAPI.prototype.getInitialAltitude = function () { FixedWingDroneAPI.prototype.getInitialAltitude = function () {
return this._map_dict.start_AMSL; return this._map_dict.start_AMSL;
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.46032.14056.1553</string> </value> <value> <string>1014.60714.57448.36454</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1696870145.24</float> <float>1709288420.35</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.57487.9176.36369</string> </value> <value> <string>1014.60733.7318.44953</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697558075.38</float> <float>1709546292.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -153,14 +153,24 @@ ...@@ -153,14 +153,24 @@
<h3>Functions called by game on event</h3> <h3>Functions called by game on event</h3>
<!-- Start --> <!-- Start -->
<h4 class="item-name" id="start"><span>onStart</span><span>: void</span></h4> <h4 class="item-name" id="start"><span>onStart</span><span>: timestamp</span></h4>
<p class="item-descr">Function called on game start.</p> <p class="item-descr">Function called on game start.</p>
<div>
<h5 class="item-param-1">Param</h5>
<h5 class="item-param-2">Description</h5>
</div>
<div>
<p class="item-param-1">timestamp: Integer</p>
<p class="item-param-2">Timestamp in milliseconds from UNIX epoch</p>
</div>
<div> <div>
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
</div> </div>
<p class="item-param-1">me.onStart = function() {<br> <p class="item-param-1">me.onStart = function(timestamp) {<br>
&nbsp;&nbsp;//one time execution code<br> &nbsp;&nbsp;//one time execution code<br>
} }
</p> </p>
...@@ -168,7 +178,7 @@ ...@@ -168,7 +178,7 @@
<div class="line"></div> <div class="line"></div>
<!-- Update --> <!-- Update -->
<h4 class="item-name" id="update"><span>onUpdate</span><span>: void</span></h4> <h4 class="item-name" id="update"><span>onUpdate</span><span>: timestamp</span></h4>
<p class="item-descr">Function called on game update, 60 times / second. <br></p> <p class="item-descr">Function called on game update, 60 times / second. <br></p>
<div> <div>
...@@ -183,7 +193,7 @@ ...@@ -183,7 +193,7 @@
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
<p class="item-example">me.onUpdate = function() {<br> <p class="item-example">me.onUpdate = function(timestamp) {<br>
&nbsp;&nbsp;//code executed 60 times per second<br> &nbsp;&nbsp;//code executed 60 times per second<br>
} }
</p> </p>
...@@ -340,6 +350,24 @@ ...@@ -340,6 +350,24 @@
<div class="line"></div> <div class="line"></div>
<!-- takeOff -->
<h4 class="item-name" id="takeOff"><span>takeOff</span><span>: void</span></h4>
<p class="item-descr">Trigger drone's takeoff (has only effect on multicopters as fixed wings drones need to take off manually).</p>
<div>
<h5 class="item-param-1">Param</h5>
<h5 class="item-param-2">Description</h5>
</div>
<div>
<h5 class="item-param-1">Example</h5>
</div>
<p class="item-param-1">me.takeOff();<br>
</p>
<div class="line"></div>
<!-- setTargetCoordinates --> <!-- setTargetCoordinates -->
<h4 class="item-name" id="setTargetCoordinates"><span>setTargetCoordinates</span><span>: void</span></h4> <h4 class="item-name" id="setTargetCoordinates"><span>setTargetCoordinates</span><span>: void</span></h4>
<p class="item-descr"> <p class="item-descr">
...@@ -363,6 +391,10 @@ ...@@ -363,6 +391,10 @@
<p class="item-param-1">altitude: Float</p> <p class="item-param-1">altitude: Float</p>
<p class="item-param-2">altitude value (in meters).</p> <p class="item-param-2">altitude value (in meters).</p>
</div> </div>
<div>
<p class="item-param-1">speed: Float</p>
<p class="item-param-2">speed value (in meters per second).</p>
</div>
<div> <div>
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
...@@ -370,35 +402,12 @@ ...@@ -370,35 +402,12 @@
<div> <div>
<p class="item-example"> <p class="item-example">
me.setTargetCoordinates(lat, lon, altitude);<br> me.setTargetCoordinates(lat, lon, altitude, speed);<br>
</p> </p>
</div> </div>
<div class="line"></div> <div class="line"></div>
<!-- setAirSpeed -->
<h4 class="item-name" id="setAirSpeed"><span>setAirSpeed</span><span>: void</span></h4>
<p class="item-descr">Set the drone speed in meters/second. The drone will move at the given value.</p>
<div>
<h5 class="item-param-1">Param</h5>
<h5 class="item-param-2">Description</h5>
</div>
<div>
<p class="item-param-1">speed: Float</p>
<p class="item-param-2">Speed value</p>
</div>
<div>
<h5 class="item-param-1">Example</h5>
</div>
<p class="item-param-1">me.setAirSpeed(16);<br>
</p>
<div class="line"></div>
<!-- loiter --> <!-- loiter -->
<h4 class="item-name" id="loiter"><span>loiter</span><span>: void</span></h4> <h4 class="item-name" id="loiter"><span>loiter</span><span>: void</span></h4>
<p class="item-descr">Set the drone to loiter mode, it will loiter around the target coordinates. If the given radius is inferior to LOITER_LIMIT (30), then the chosen radius will be the last accepted value when calling loiter function (100 by default).</p> <p class="item-descr">Set the drone to loiter mode, it will loiter around the target coordinates. If the given radius is inferior to LOITER_LIMIT (30), then the chosen radius will be the last accepted value when calling loiter function (100 by default).</p>
...@@ -458,9 +467,9 @@ ...@@ -458,9 +467,9 @@
<div class="line"></div> <div class="line"></div>
<!-- triggerParachute --> <!-- land -->
<h4 class="item-name" id="triggerParachute"><span>triggerParachute</span><span>: void</span></h4> <h4 class="item-name" id="land"><span>land</span><span>: void</span></h4>
<p class="item-descr">Indicates the drone to deploy the parachute to finish the landing.</p> <p class="item-descr">Indicates the drone to trigger landing.</p>
<div> <div>
<h5 class="item-param-1">Param</h5> <h5 class="item-param-1">Param</h5>
...@@ -471,23 +480,33 @@ ...@@ -471,23 +480,33 @@
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
</div> </div>
<p class="item-param-1">me.triggerParachute();<br> <p class="item-param-1">me.land();<br>
</p> </p>
<div class="line"></div> <div class="line"></div>
<!-- landed --> <!-- isReadyToFly -->
<h4 class="item-name" id="landed"><span>landed</span><span>: boolean</span></h4> <h4 class="item-name" id="isReadyToFly"><span>isReadyToFly</span><span>: void</span></h4>
<p class="item-descr">Indicates if the drone has landed (reached the floor altitude).</p> <p class="item-descr">Check if drone takeoff is finished.</p>
<div> <div>
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
</div> </div>
<p class="item-example"> <p class="item-param-1">me.isReadyToFly();<br>
if (me.landed()) {<br> </p>
&nbsp;&nbsp;//do something<br>
}<br> <div class="line"></div>
<!-- isLanding -->
<h4 class="item-name" id="isLanding"><span>isLanding</span><span>: void</span></h4>
<p class="item-descr">Check if drone landing has been triggered.</p>
<div>
<h5 class="item-param-1">Example</h5>
</div>
<p class="item-param-1">me.isLanding();<br>
</p> </p>
<div class="line"></div> <div class="line"></div>
...@@ -520,15 +539,15 @@ ...@@ -520,15 +539,15 @@
<div class="line"></div> <div class="line"></div>
<!-- getAirSpeed --> <!-- getSpeed -->
<h4 class="item-name" id="getAirSpeed"><span>getAirSpeed</span><span>: Float</span></h4> <h4 class="item-name" id="getSpeed"><span>getSpeed</span><span>: Float</span></h4>
<p class="item-descr">Get drone air speed in meters/second.</p> <p class="item-descr">Get drone ground speed in meters/second as wind is neglected in simulation. In real flights with fixed wings drones the returned value is the airspeed.</p>
<div> <div>
<h5 class="item-param-1">Example</h5> <h5 class="item-param-1">Example</h5>
</div> </div>
<p class="item-param-1">me.getAirSpeed();<br> <p class="item-param-1">me.getSpeed();<br>
</p> </p>
<div class="line"></div> <div class="line"></div>
...@@ -572,19 +591,6 @@ ...@@ -572,19 +591,6 @@
<div class="line"></div> <div class="line"></div>
<!-- getSinkRate -->
<h4 class="item-name" id="getSinkRate"><span>getSinkRate</span><span>: Float</span></h4>
<p class="item-descr">Get drone sink rate in meters/second.</p>
<div>
<h5 class="item-param-1">Example</h5>
</div>
<p class="item-param-1">me.getSinkRate();<br>
</p>
<div class="line"></div>
<h3>Drone properties</h3> <h3>Drone properties</h3>
<div class="line"></div> <div class="line"></div>
......
...@@ -244,7 +244,7 @@ ...@@ -244,7 +244,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1013.8667.7605.21589</string> </value> <value> <string>1014.48209.18178.31351</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -264,7 +264,7 @@ ...@@ -264,7 +264,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1702410728.19</float> <float>1708710825.64</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -77,6 +77,7 @@ var OperatorAPI = /** @class */ (function () { ...@@ -77,6 +77,7 @@ var OperatorAPI = /** @class */ (function () {
MAX_PITCH = 25, MAX_PITCH = 25,
MAX_CLIMB_RATE = 8, MAX_CLIMB_RATE = 8,
MAX_SINK_RATE = 3, MAX_SINK_RATE = 3,
MAX_COMMAND_FREQUENCY = 2,
NUMBER_OF_DRONES = 5, NUMBER_OF_DRONES = 5,
// Non-inputs parameters // Non-inputs parameters
EPSILON = "15", EPSILON = "15",
...@@ -104,7 +105,7 @@ var OperatorAPI = /** @class */ (function () { ...@@ -104,7 +105,7 @@ var OperatorAPI = /** @class */ (function () {
' );\n' + ' );\n' +
'}\n' + '}\n' +
'\n' + '\n' +
'me.onStart = function () {\n' + 'me.onStart = function (timestamp) {\n' +
' me.direction_set = false;\n' + ' me.direction_set = false;\n' +
' me.dodging = false;\n' + ' me.dodging = false;\n' +
' me.ongoing_detection = false;\n' + ' me.ongoing_detection = false;\n' +
...@@ -136,7 +137,8 @@ var OperatorAPI = /** @class */ (function () { ...@@ -136,7 +137,8 @@ var OperatorAPI = /** @class */ (function () {
' me.setTargetCoordinates(\n' + ' me.setTargetCoordinates(\n' +
' me.flag_positions[me.next_checkpoint].position.latitude,\n' + ' me.flag_positions[me.next_checkpoint].position.latitude,\n' +
' me.flag_positions[me.next_checkpoint].position.longitude,\n' + ' me.flag_positions[me.next_checkpoint].position.longitude,\n' +
' me.flag_positions[me.next_checkpoint].position.altitude + me.id\n' + ' me.flag_positions[me.next_checkpoint].position.altitude + me.id,\n' +
' ' + DEFAULT_SPEED + '\n' +
' );\n' + ' );\n' +
//' console.log("[DEMO] Going to Checkpoint %d", me.next_checkpoint);\n' + //' console.log("[DEMO] Going to Checkpoint %d", me.next_checkpoint);\n' +
' }\n' + ' }\n' +
...@@ -162,12 +164,6 @@ var OperatorAPI = /** @class */ (function () { ...@@ -162,12 +164,6 @@ var OperatorAPI = /** @class */ (function () {
' }\n' + ' }\n' +
' return;\n' + ' return;\n' +
' }\n' + ' }\n' +
' if (me.next_checkpoint == me.flag_positions.length) {\n' +
' me.triggerParachute();\n' +
' }\n' +
' if (me.landed()) {\n' +
' me.exit();\n' +
' }\n' +
'};\n' + '};\n' +
'\n' + '\n' +
'me.onDroneViewInfo = function (drone_view) {\n' + 'me.onDroneViewInfo = function (drone_view) {\n' +
...@@ -182,7 +178,7 @@ var OperatorAPI = /** @class */ (function () { ...@@ -182,7 +178,7 @@ var OperatorAPI = /** @class */ (function () {
' } else {\n' + ' } else {\n' +
' dodge_point.longitude = dodge_point.longitude * -1;\n' + ' dodge_point.longitude = dodge_point.longitude * -1;\n' +
' }\n' + ' }\n' +
' me.setTargetCoordinates(dodge_point.latitude, dodge_point.longitude, me.getCurrentPosition().altitude);\n' + ' me.setTargetCoordinates(dodge_point.latitude, dodge_point.longitude, me.getCurrentPosition().altitude, ' + DEFAULT_SPEED + ');\n' +
' return;\n' + ' return;\n' +
' }\n' + ' }\n' +
'};', '};',
...@@ -680,6 +676,17 @@ var OperatorAPI = /** @class */ (function () { ...@@ -680,6 +676,17 @@ var OperatorAPI = /** @class */ (function () {
"hidden": 0, "hidden": 0,
"type": "FloatField" "type": "FloatField"
}, },
"my_drone_max_command_frequency": {
"description": "",
"title": "Drone max command frequency",
"default": gadget.state.drone_max_command_frequency,
"css_class": "",
"required": 1,
"editable": 1,
"key": "drone_max_command_frequency",
"hidden": 0,
"type": "FloatField"
},
"my_number_of_drones": { "my_number_of_drones": {
"description": "", "description": "",
"title": "Number of drones", "title": "Number of drones",
...@@ -708,7 +715,8 @@ var OperatorAPI = /** @class */ (function () { ...@@ -708,7 +715,8 @@ var OperatorAPI = /** @class */ (function () {
[["my_drone_min_speed"], ["my_drone_speed"], ["my_drone_max_speed"], [["my_drone_min_speed"], ["my_drone_speed"], ["my_drone_max_speed"],
["my_drone_max_acceleration"], ["my_drone_max_deceleration"], ["my_drone_max_acceleration"], ["my_drone_max_deceleration"],
["my_drone_max_roll"], ["my_drone_min_pitch"], ["my_drone_max_pitch"], ["my_drone_max_roll"], ["my_drone_min_pitch"], ["my_drone_max_pitch"],
["my_drone_max_sink_rate"], ["my_drone_max_climb_rate"]] ["my_drone_max_sink_rate"], ["my_drone_max_climb_rate"],
["my_drone_max_command_frequency"]]
]] ]]
} }
}); });
...@@ -836,6 +844,7 @@ var OperatorAPI = /** @class */ (function () { ...@@ -836,6 +844,7 @@ var OperatorAPI = /** @class */ (function () {
"maxPitchAngle": parseFloat(gadget.state.drone_max_pitch), "maxPitchAngle": parseFloat(gadget.state.drone_max_pitch),
"maxSinkRate": parseFloat(gadget.state.drone_max_sink_rate), "maxSinkRate": parseFloat(gadget.state.drone_max_sink_rate),
"maxClimbRate": parseFloat(gadget.state.drone_max_climb_rate), "maxClimbRate": parseFloat(gadget.state.drone_max_climb_rate),
"maxCommandFrequency": parseFloat(gadget.state.drone_max_command_frequency),
"list": drone_list "list": drone_list
}, },
"gameTime": parseInt(gadget.state.simulation_time, 10), "gameTime": parseInt(gadget.state.simulation_time, 10),
...@@ -950,6 +959,7 @@ var OperatorAPI = /** @class */ (function () { ...@@ -950,6 +959,7 @@ var OperatorAPI = /** @class */ (function () {
operator_script: DEFAULT_OPERATOR_SCRIPT, operator_script: DEFAULT_OPERATOR_SCRIPT,
drone_script: DEFAULT_SCRIPT_CONTENT, drone_script: DEFAULT_SCRIPT_CONTENT,
number_of_drones: NUMBER_OF_DRONES, number_of_drones: NUMBER_OF_DRONES,
drone_max_command_frequency: MAX_COMMAND_FREQUENCY,
drone_max_climb_rate: MAX_CLIMB_RATE, drone_max_climb_rate: MAX_CLIMB_RATE,
drone_max_sink_rate: MAX_SINK_RATE, drone_max_sink_rate: MAX_SINK_RATE,
drone_max_pitch: MAX_PITCH, drone_max_pitch: MAX_PITCH,
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.57494.145.60023</string> </value> <value> <string>1014.48194.32365.65399</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697558059.95</float> <float>1708709921.07</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test Drone Capture Flag OJS app (expected failure)</title> <title>Test Drone Capture Flag OJS app (expected failure)</title>
<!-- This test is expected to fail as the drone simulator runs on a web worker canvas, which relies on a very new feature: offscreen canvas <!-- This test is expected to fail as the drone simulator runs on a web worker canvas, which relies on a very new feature: offscreen canvas
---- This feature is not supported yet by the latest Firefox ESR used in the test nodes --> ---- This feature is not supported yet by the latest Firefox ESR used in the test nodes (error: webgl not supported) -->
</head> </head>
<body> <body>
<table cellpadding="1" cellspacing="1" border="1"> <table cellpadding="1" cellspacing="1" border="1">
...@@ -30,36 +30,16 @@ ...@@ -30,36 +30,16 @@
<td>//div[contains(@data-gadget-url, 'gadget_erp5_page_drone_capture_flag_script_page.html')]</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_page_drone_capture_flag_script_page.html')]</td>
<td></td> <td></td>
<tr> <tr>
<!-- Check game -->
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//label[text()='Simulation Speed']</td> <td>//span[@id="loading"]</td>
<td></td>
<tr>
<tr>
<td>waitForElementPresent</td>
<td>//div[contains(@data-gadget-url, 'codemirror.gadget.html')]</td>
<td></td> <td></td>
<tr> <tr>
<!-- Check panel --> <!-- Check panel -->
<tr>
<td>assertElementPresent</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_panel_drone_capture_flag.html')]//a[contains(@class, 'ui-icon-puzzle-piece') and text()='Run Game']</td>
<td></td>
<tr>
<!-- Run game -->
<tr>
<td>pause</td>
<td>3000</td>
<td></td>
</tr>
<tr>
<td>click</td>
<td>//div[contains(@data-gadget-url, 'gadget_erp5_page_drone_capture_flag_script_page.html')]//input[@type="submit" and @name="action_run"]</td>
<td></td>
<tr>
<tr> <tr>
<td>waitForElementPresent</td> <td>waitForElementPresent</td>
<td>//span[@id="loading"]</td> <td>//div[contains(@data-gadget-url, 'gadget_erp5_panel_drone_capture_flag.html')]//a[contains(@class, 'ui-icon-puzzle-piece') and text()='Run Game']</td>
<td></td> <td></td>
<tr> <tr>
<!-- Check simulator gadget and babylon lib --> <!-- Check simulator gadget and babylon lib -->
......
...@@ -5,13 +5,15 @@ ...@@ -5,13 +5,15 @@
var SIMULATION_SPEED = 10, var SIMULATION_SPEED = 10,
SIMULATION_TIME = 270, SIMULATION_TIME = 270,
MAP_SIZE = 1905, MIN_LAT = 45.6364,
min_lat = 45.6364, MAX_LAT = 45.65,
max_lat = 45.65, MIN_LON = 14.2521,
min_lon = 14.2521, MAX_LON = 14.2766,
max_lon = 14.2766,
map_height = 700, map_height = 700,
start_AMSL = 595, start_AMSL = 595,
INIT_LON = 14.2658,
INIT_LAT = 45.6412,
INIT_ALT = 15,
DEFAULT_SPEED = 16, DEFAULT_SPEED = 16,
MAX_ACCELERATION = 6, MAX_ACCELERATION = 6,
MAX_DECELERATION = 1, MAX_DECELERATION = 1,
...@@ -31,6 +33,7 @@ ...@@ -31,6 +33,7 @@
' else\n' + ' else\n' +
' console.log(msg + ": FAIL");\n' + ' console.log(msg + ": FAIL");\n' +
'}\n' + '}\n' +
'\n' +
'function distance(lat1, lon1, lat2, lon2) {\n' + 'function distance(lat1, lon1, lat2, lon2) {\n' +
' var R = 6371e3, // meters\n' + ' var R = 6371e3, // meters\n' +
' la1 = lat1 * Math.PI / 180, // lat, lon in radians\n' + ' la1 = lat1 * Math.PI / 180, // lat, lon in radians\n' +
...@@ -42,39 +45,46 @@ ...@@ -42,39 +45,46 @@
' h = haversine_phi + Math.cos(la1) * Math.cos(la2) * sin_lon * sin_lon;\n' + ' h = haversine_phi + Math.cos(la1) * Math.cos(la2) * sin_lon * sin_lon;\n' +
' return 2 * R * Math.asin(Math.sqrt(h));\n' + ' return 2 * R * Math.asin(Math.sqrt(h));\n' +
'}\n' + '}\n' +
'\n' +
'function compare(coord1, coord2) {\n' + 'function compare(coord1, coord2) {\n' +
' assert(coord1.x, coord2.x, "Latitude")\n' + ' assert(coord1.latitude, coord2.latitude, "Latitude")\n' +
' assert(coord1.y, coord2.y, "Longitude")\n' + ' assert(coord1.longitude, coord2.longitude, "Longitude")\n' +
' assert(coord1.z, coord2.z, "Altitude")\n' + ' assert(coord1.altitude, coord2.altitude, "Altitude")\n' +
'}\n' + '}\n' +
'me.onStart = function () {\n' + '\n' +
' assert(me.getAirSpeed(), 16, "Initial speed");\n' + 'me.onStart = function (timestamp) {\n' +
' assert(me.getSpeed(), ' + DEFAULT_SPEED + ', "Initial speed");\n' +
' assert(me.getYaw(), 0, "Yaw angle")\n' + ' assert(me.getYaw(), 0, "Yaw angle")\n' +
' me.initialPosition = me.getCurrentPosition();\n' + ' me.initialPosition = me.getCurrentPosition();\n' +
' me.start_time = timestamp;\n' +
' me.setTargetCoordinates(\n' + ' me.setTargetCoordinates(\n' +
' me.initialPosition.x + 0.01,\n' + ' me.initialPosition.latitude + 0.01,\n' +
' me.initialPosition.y,\n' + ' me.initialPosition.longitude,\n' +
' me.initialPosition.z\n' + ' me.getAltitudeAbs(),\n' +
' ' + DEFAULT_SPEED + '\n' +
' );\n' + ' );\n' +
'};\n' + '};\n' +
'\n' +
'me.onUpdate = function (timestamp) {\n' + 'me.onUpdate = function (timestamp) {\n' +
' var current_position = me.getCurrentPosition(),\n' + ' var current_position = me.getCurrentPosition(),\n' +
' realDistance = distance(\n' + ' realDistance = distance(\n' +
' me.initialPosition.x,\n' + ' me.initialPosition.latitude,\n' +
' me.initialPosition.y,\n' + ' me.initialPosition.longitude,\n' +
' me.getCurrentPosition().x,\n' + ' me.getCurrentPosition().latitude,\n' +
' me.getCurrentPosition().y\n' + ' me.getCurrentPosition().longitude\n' +
').toFixed(8),\n' + ' ).toFixed(8),\n' +
' expectedDistance = (me.getAirSpeed() * timestamp / 1000).toFixed(8);\n' + ' time_interval = timestamp - me.start_time,\n' +
' assert(timestamp, 1000 / 60, "Timestamp");\n' + ' expected_interval = 1000 / 60,\n' +
' assert(realDistance, expectedDistance, "Distance");\n' + ' expectedDistance = (me.getSpeed() * expected_interval / 1000).toFixed(8);\n' +
' current_position.x = current_position.x.toFixed(7);\n' + ' assert(time_interval, Math.floor(expected_interval), "Timestamp");\n' +
' assert(realDistance, expectedDistance, "Distance");\n' +
' current_position.latitude = current_position.latitude.toFixed(7);\n' +
' compare(current_position, {\n' + ' compare(current_position, {\n' +
' x: (me.initialPosition.x + 2.3992831666911723e-06).toFixed(7),\n' + ' latitude: (me.initialPosition.latitude + 2.3992831666911723e-06).toFixed(7),\n' +
' y: me.initialPosition.y,\n' + ' longitude: me.initialPosition.longitude,\n' +
' z: me.initialPosition.z\n' + ' altitude: me.initialPosition.altitude\n' +
'});\n' + ' });\n' +
'me.exit(me.triggerParachute());\n' + ' me.exit(me.land());\n' +
'};', '};',
DRAW = true, DRAW = true,
LOG = true, LOG = true,
...@@ -82,6 +92,7 @@ ...@@ -82,6 +92,7 @@
DRONE_LIST = [], DRONE_LIST = [],
LOGIC_FILE_LIST = [ LOGIC_FILE_LIST = [
'gadget_erp5_page_drone_capture_flag_logic.js', 'gadget_erp5_page_drone_capture_flag_logic.js',
'gadget_erp5_page_drone_capture_map_utils.js',
'gadget_erp5_page_drone_capture_flag_fixedwingdrone.js', 'gadget_erp5_page_drone_capture_flag_fixedwingdrone.js',
'gadget_erp5_page_drone_capture_flag_enemydrone.js' 'gadget_erp5_page_drone_capture_flag_enemydrone.js'
]; ];
...@@ -100,7 +111,7 @@ ...@@ -100,7 +111,7 @@
.declareJob('runGame', function runGame() { .declareJob('runGame', function runGame() {
var gadget = this, i, var gadget = this, i,
fragment = gadget.element.querySelector('.simulator_div'), fragment = gadget.element.querySelector('.simulator_div'),
game_parameters_json, map_json; game_parameters_json, map_json, operator_init_msg;
DRONE_LIST = []; DRONE_LIST = [];
fragment = domsugar(gadget.element.querySelector('.simulator_div'), fragment = domsugar(gadget.element.querySelector('.simulator_div'),
[domsugar('div')]).firstElementChild; [domsugar('div')]).firstElementChild;
...@@ -109,26 +120,25 @@ ...@@ -109,26 +120,25 @@
"script_content": DEFAULT_SCRIPT_CONTENT}; "script_content": DEFAULT_SCRIPT_CONTENT};
} }
map_json = { map_json = {
"map_size": parseFloat(MAP_SIZE),
"height": parseInt(map_height, 10), "height": parseInt(map_height, 10),
"start_AMSL": parseFloat(start_AMSL), "start_AMSL": parseFloat(start_AMSL),
"min_lat": parseFloat(min_lat), "min_lat": parseFloat(MIN_LAT),
"max_lat": parseFloat(max_lat), "max_lat": parseFloat(MAX_LAT),
"min_lon": parseFloat(min_lon), "min_lon": parseFloat(MIN_LON),
"max_lon": parseFloat(max_lon), "max_lon": parseFloat(MAX_LON),
"flag_list": [{ "flag_list": [],
"position": {
"x": -27,
"y": 72,
"z": 10
}
}],
"obstacle_list" : [], "obstacle_list" : [],
"drones": { "enemy_list" : [],
"user": DRONE_LIST, "initial_position": {
"enemy": [] "longitude": parseFloat(INIT_LON),
"latitude": parseFloat(INIT_LAT),
"altitude": parseFloat(INIT_ALT)
} }
}; };
operator_init_msg = {
"flag_positions": []
};
/*jslint evil: false*/
game_parameters_json = { game_parameters_json = {
"debug_test_mode": true, "debug_test_mode": true,
"drone": { "drone": {
...@@ -141,7 +151,8 @@ ...@@ -141,7 +151,8 @@
"minPitchAngle": parseFloat(MIN_PITCH), "minPitchAngle": parseFloat(MIN_PITCH),
"maxPitchAngle": parseFloat(MAX_PITCH), "maxPitchAngle": parseFloat(MAX_PITCH),
"maxSinkRate": parseFloat(MAX_SINK_RATE), "maxSinkRate": parseFloat(MAX_SINK_RATE),
"maxClimbRate": parseFloat(MAX_CLIMB_RATE) "maxClimbRate": parseFloat(MAX_CLIMB_RATE),
"list": DRONE_LIST
}, },
"gameTime": parseInt(SIMULATION_TIME, 10), "gameTime": parseInt(SIMULATION_TIME, 10),
"simulation_speed": parseInt(SIMULATION_SPEED, 10), "simulation_speed": parseInt(SIMULATION_SPEED, 10),
...@@ -150,6 +161,7 @@ ...@@ -150,6 +161,7 @@
"communication": 0 "communication": 0
}, },
"map": map_json, "map": map_json,
"operator_init_msg": operator_init_msg,
"draw_flight_path": DRAW, "draw_flight_path": DRAW,
"temp_flight_path": true, "temp_flight_path": true,
"log_drone_flight": LOG, "log_drone_flight": LOG,
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1010.33861.49321.40789</string> </value> <value> <string>1014.60680.20078.34286</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1692294109.04</float> <float>1709286290.59</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -207,11 +207,11 @@ var DroneLogAPI = /** @class */ (function () { ...@@ -207,11 +207,11 @@ var DroneLogAPI = /** @class */ (function () {
DroneLogAPI.prototype.getFlightParameters = function () { DroneLogAPI.prototype.getFlightParameters = function () {
return this._flight_parameters; return this._flight_parameters;
}; };
DroneLogAPI.prototype.exit = function (drone) { DroneLogAPI.prototype.isReadyToFly = function () {
return; return true;
}; };
DroneLogAPI.prototype.set_loiter_mode = function (loiter) { DroneLogAPI.prototype.getMaxCommandFrequency = function () {
return; return Infinity;
}; };
return DroneLogAPI; return DroneLogAPI;
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.48679.53693.47701</string> </value> <value> <string>1014.60631.26636.59528</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697030760.48</float> <float>1709288518.39</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -30,6 +30,8 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -30,6 +30,8 @@ var FixedWingDroneAPI = /** @class */ (function () {
this._loiter_radius = 100; this._loiter_radius = 100;
//this._start_altitude = 0; //this._start_altitude = 0;
this._loiter_mode = false; this._loiter_mode = false;
this._is_landing = false;
this._is_ready_to_fly = true;
this._drone_dict_list = []; this._drone_dict_list = [];
} }
Object.defineProperty(FixedWingDroneAPI.prototype, "isCollidable", { Object.defineProperty(FixedWingDroneAPI.prototype, "isCollidable", {
...@@ -90,45 +92,19 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -90,45 +92,19 @@ var FixedWingDroneAPI = /** @class */ (function () {
if (drone._maxClimbRate > drone._maxSpeed) { if (drone._maxClimbRate > drone._maxSpeed) {
throw new Error('max climb rate cannot be superior to max speed'); throw new Error('max climb rate cannot be superior to max speed');
} }
drone._maxOrientation = this.getMaxOrientation(); drone._maxCommandFrequency = this.getMaxCommandFrequency();
if (drone._maxCommandFrequency <= 0) {
throw new Error('max command frequence must be superior to 0');
}
return; return;
}; };
/* /*
** Function called on every drone update, right before onUpdate AI script ** Function called on every drone update, right before onUpdate AI script
*/ */
FixedWingDroneAPI.prototype.internal_update = function (context, delta_time) { FixedWingDroneAPI.prototype.internal_update = function (context, delta_time) {
var diff, newrot, orientationValue, rotStep;
//TODO rotation
if (context._rotationTarget) {
rotStep = BABYLON.Vector3.Zero();
diff = context._rotationTarget.subtract(context._controlMesh.rotation);
rotStep.x = (diff.x >= 1) ? 1 : diff.x;
rotStep.y = (diff.y >= 1) ? 1 : diff.y;
rotStep.z = (diff.z >= 1) ? 1 : diff.z;
if (rotStep === BABYLON.Vector3.Zero()) {
context._rotationTarget = null;
return;
}
newrot = new BABYLON.Vector3(context._controlMesh.rotation.x +
(rotStep.x * context._rotationSpeed),
context._controlMesh.rotation.y +
(rotStep.y * context._rotationSpeed),
context._controlMesh.rotation.z +
(rotStep.z * context._rotationSpeed)
);
context._controlMesh.rotation = newrot;
}
this._updateSpeed(context, delta_time); this._updateSpeed(context, delta_time);
this._updatePosition(context, delta_time); this._updatePosition(context, delta_time);
//TODO rotation
orientationValue = context._maxOrientation *
(context._speed / context._maxSpeed);
context._mesh.rotation =
new BABYLON.Vector3(orientationValue * context._direction.z, 0,
-orientationValue * context._direction.x);
context._controlMesh.computeWorldMatrix(true); context._controlMesh.computeWorldMatrix(true);
context._mesh.computeWorldMatrix(true); context._mesh.computeWorldMatrix(true);
}; };
...@@ -148,7 +124,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -148,7 +124,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
'latitude' : drone_position.latitude, 'latitude' : drone_position.latitude,
'longitude' : drone_position.longitude, 'longitude' : drone_position.longitude,
'yaw': drone.getYaw(), 'yaw': drone.getYaw(),
'speed': drone.getAirSpeed(), 'speed': drone.getSpeed(),
'climbRate': drone.getClimbRate() 'climbRate': drone.getClimbRate()
}; };
_this._drone_dict_list[_this._id] = drone_info; _this._drone_dict_list[_this._id] = drone_info;
...@@ -162,7 +138,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -162,7 +138,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
}; };
FixedWingDroneAPI.prototype._updateSpeed = function (drone, delta_time) { FixedWingDroneAPI.prototype._updateSpeed = function (drone, delta_time) {
var speed = drone.getAirSpeed(), speedDiff, speedUpdate; var speed = drone.get3DSpeed(), speedDiff, speedUpdate;
if (speed !== this._targetSpeed) { if (speed !== this._targetSpeed) {
speedDiff = this._targetSpeed - speed; speedDiff = this._targetSpeed - speed;
speedUpdate = drone._acceleration * delta_time / 1000; speedUpdate = drone._acceleration * delta_time / 1000;
...@@ -235,7 +211,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -235,7 +211,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed = this._getVerticalSpeed(drone); verticalSpeed = this._getVerticalSpeed(drone);
groundSpeed = Math.sqrt( groundSpeed = Math.sqrt(
Math.pow(drone.getAirSpeed(), 2) - Math.pow(verticalSpeed, 2) Math.pow(drone.get3DSpeed(), 2) - Math.pow(verticalSpeed, 2)
); );
distance = (groundSpeed * delta_time / 1000) / R; distance = (groundSpeed * delta_time / 1000) / R;
...@@ -297,39 +273,27 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -297,39 +273,27 @@ var FixedWingDroneAPI = /** @class */ (function () {
verticalSpeed = this._computeVerticalSpeed( verticalSpeed = this._computeVerticalSpeed(
altitudeDiff, altitudeDiff,
this.getMaxClimbRate(), this.getMaxClimbRate(),
drone.getAirSpeed(), drone.get3DSpeed(),
this.getMaxPitchAngle() this.getMaxPitchAngle()
); );
} else { } else {
verticalSpeed = -this._computeVerticalSpeed( verticalSpeed = -this._computeVerticalSpeed(
Math.abs(altitudeDiff), Math.abs(altitudeDiff),
this.getMaxSinkRate(), this.getMaxSinkRate(),
drone.getAirSpeed(), drone.get3DSpeed(),
-this.getMinPitchAngle() -this.getMinPitchAngle()
); );
} }
return verticalSpeed; return verticalSpeed;
}; };
FixedWingDroneAPI.prototype.setRotation = function (drone, x, y, z) {
//TODO rotation
drone._rotationTarget = new BABYLON.Vector3(x, z, y);
};
FixedWingDroneAPI.prototype.setRotationBy = function (drone, x, y, z) {
//TODO rotation
drone._rotationTarget = new BABYLON.Vector3(drone.rotation.x + x,
drone.rotation.y + z,
drone.rotation.z + y);
};
FixedWingDroneAPI.prototype.setSpeed = function (drone, speed) { FixedWingDroneAPI.prototype.setSpeed = function (drone, speed) {
this._targetSpeed = Math.max( this._targetSpeed = Math.max(
Math.min(speed, this.getMaxSpeed()), Math.min(speed, this.getMaxSpeed()),
this.getMinSpeed() this.getMinSpeed()
); );
drone._acceleration = (this._targetSpeed > drone.getAirSpeed()) drone._acceleration = (this._targetSpeed > drone.get3DSpeed())
? this.getMaxAcceleration() : -this.getMaxDeceleration(); ? this.getMaxAcceleration() : -this.getMaxDeceleration();
}; };
...@@ -349,7 +313,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -349,7 +313,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
}; };
FixedWingDroneAPI.prototype.internal_setTargetCoordinates = FixedWingDroneAPI.prototype.internal_setTargetCoordinates =
function (drone, coordinates, radius) { function (drone, coordinates, speed, radius) {
if (radius) { if (radius) {
this._loiter_mode = true; this._loiter_mode = true;
if (radius >= LOITER_LIMIT) { if (radius >= LOITER_LIMIT) {
...@@ -358,6 +322,7 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -358,6 +322,7 @@ var FixedWingDroneAPI = /** @class */ (function () {
} else { } else {
this._loiter_mode = false; this._loiter_mode = false;
} }
this.setSpeed(drone, speed);
}; };
FixedWingDroneAPI.prototype.sendMsg = function (msg, to) { FixedWingDroneAPI.prototype.sendMsg = function (msg, to) {
...@@ -447,14 +412,13 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -447,14 +412,13 @@ var FixedWingDroneAPI = /** @class */ (function () {
FixedWingDroneAPI.prototype.getMaxClimbRate = function () { FixedWingDroneAPI.prototype.getMaxClimbRate = function () {
return this._flight_parameters.drone.maxClimbRate; return this._flight_parameters.drone.maxClimbRate;
}; };
FixedWingDroneAPI.prototype.getMaxOrientation = function () { FixedWingDroneAPI.prototype.getMaxCommandFrequency = function () {
//TODO should be a game parameter (but how to force value to PI quarters?) return this._flight_parameters.drone.maxCommandFrequency;
return Math.PI / 4;
}; };
FixedWingDroneAPI.prototype.getYawVelocity = function (drone) { FixedWingDroneAPI.prototype.getYawVelocity = function (drone) {
return 360 * EARTH_GRAVITY return 360 * EARTH_GRAVITY
* Math.tan(this._toRad(this.getMaxRollAngle())) * Math.tan(this._toRad(this.getMaxRollAngle()))
/ (2 * Math.PI * drone.getAirSpeed()); / (2 * Math.PI * drone.get3DSpeed());
}; };
FixedWingDroneAPI.prototype.getYaw = function (drone) { FixedWingDroneAPI.prototype.getYaw = function (drone) {
var direction = drone.worldDirection; var direction = drone.worldDirection;
...@@ -491,25 +455,34 @@ var FixedWingDroneAPI = /** @class */ (function () { ...@@ -491,25 +455,34 @@ var FixedWingDroneAPI = /** @class */ (function () {
return angle * 180 / Math.PI; return angle * 180 / Math.PI;
}; };
FixedWingDroneAPI.prototype.getClimbRate = function (drone) { FixedWingDroneAPI.prototype.getClimbRate = function (drone) {
return drone.worldDirection.y * drone.getAirSpeed(); return drone.worldDirection.y * drone.get3DSpeed();
}; };
FixedWingDroneAPI.prototype.getGroundSpeed = function (drone) { FixedWingDroneAPI.prototype.getSpeed = function (drone) {
var direction = drone.worldDirection; var direction = drone.worldDirection;
return Math.sqrt( return Math.sqrt(
Math.pow(direction.x * drone.getAirSpeed(), 2) Math.pow(direction.x * drone.get3DSpeed(), 2)
+ Math.pow(direction.z * drone.getAirSpeed(), 2) + Math.pow(direction.z * drone.get3DSpeed(), 2)
); );
}; };
FixedWingDroneAPI.prototype.triggerParachute = function (drone) { FixedWingDroneAPI.prototype.takeOff = function () {
var drone_pos = drone.getCurrentPosition(); return console.log("Fixed-wing drones can only be taken off manually.");
drone.setTargetCoordinates(drone_pos.latitude, drone_pos.longitude, 5);
}; };
FixedWingDroneAPI.prototype.landed = function (drone) { FixedWingDroneAPI.prototype.land = function (drone) {
var drone_pos = drone.getCurrentPosition(); var drone_pos = drone.getCurrentPosition();
return Math.floor(drone_pos.altitude) < 10; drone.setTargetCoordinates(
drone_pos.latitude,
drone_pos.longitude,
0,
drone.get3DSpeed()
);
this._is_ready_to_fly = false;
this._is_landing = true;
}; };
FixedWingDroneAPI.prototype.exit = function () { FixedWingDroneAPI.prototype.isReadyToFly = function () {
return; return this._is_ready_to_fly;
};
FixedWingDroneAPI.prototype.isLanding = function () {
return this._is_landing;
}; };
FixedWingDroneAPI.prototype.getInitialAltitude = function () { FixedWingDroneAPI.prototype.getInitialAltitude = function () {
return this._map_dict.start_AMSL; return this._map_dict.start_AMSL;
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.48679.53693.47701</string> </value> <value> <string>1014.60724.24572.64853</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697030763.04</float> <float>1709289024.77</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -25,11 +25,11 @@ var DroneManager = /** @class */ (function () { ...@@ -25,11 +25,11 @@ var DroneManager = /** @class */ (function () {
this._maxRollAngle = 0; this._maxRollAngle = 0;
this._maxSinkRate = 0; this._maxSinkRate = 0;
this._maxClimbRate = 0; this._maxClimbRate = 0;
this._maxOrientation = 0; this._maxCommandFrequency = 0;
this._last_command_timestamp = 0;
this._speed = 0; this._speed = 0;
this._acceleration = 0; this._acceleration = 0;
this._direction = new BABYLON.Vector3(0, 0, 1); // North this._direction = new BABYLON.Vector3(0, 0, 1); // North
this._rotationSpeed = 0.4;
this._scene = scene; this._scene = scene;
this._canUpdate = true; this._canUpdate = true;
this._id = id; this._id = id;
...@@ -126,7 +126,7 @@ var DroneManager = /** @class */ (function () { ...@@ -126,7 +126,7 @@ var DroneManager = /** @class */ (function () {
this._canCommunicate = true; this._canCommunicate = true;
this._targetCoordinates = initial_position; this._targetCoordinates = initial_position;
try { try {
return this.onStart(); return this.onStart(this._API._gameManager._game_duration);
} catch (error) { } catch (error) {
console.warn('Drone crashed on start due to error:', error); console.warn('Drone crashed on start due to error:', error);
this._internal_crash(error); this._internal_crash(error);
...@@ -136,22 +136,29 @@ var DroneManager = /** @class */ (function () { ...@@ -136,22 +136,29 @@ var DroneManager = /** @class */ (function () {
* Set a target point to move * Set a target point to move
*/ */
DroneManager.prototype.setTargetCoordinates = DroneManager.prototype.setTargetCoordinates =
function (latitude, longitude, altitude) { function (latitude, longitude, altitude, speed) {
this._internal_setTargetCoordinates(latitude, longitude, altitude); this._internal_setTargetCoordinates(latitude, longitude, altitude, speed);
}; };
DroneManager.prototype._internal_setTargetCoordinates = DroneManager.prototype._internal_setTargetCoordinates =
function (latitude, longitude, altitude, radius) { function (latitude, longitude, altitude, speed, radius) {
if (!this._canPlay) { if (!this._canPlay || !this.isReadyToFly()) {
return; return;
} }
if (this._API._gameManager._game_duration - this._last_command_timestamp
< 1000 / this._API.getMaxCommandFrequency()) {
this._internal_crash(new Error('Minimum interval between commands is ' +
1000 / this._API.getMaxCommandFrequency() + ' milliseconds'));
}
//convert real geo-coordinates to virtual x-y coordinates //convert real geo-coordinates to virtual x-y coordinates
this._targetCoordinates = this._targetCoordinates =
this._API.processCoordinates(latitude, longitude, altitude); this._API.processCoordinates(latitude, longitude, altitude);
return this._API.internal_setTargetCoordinates( this._API.internal_setTargetCoordinates(
this, this,
this._targetCoordinates, this._targetCoordinates,
speed,
radius radius
); );
this._last_command_timestamp = this._API._gameManager._game_duration;
}; };
DroneManager.prototype.internal_update = function (delta_time) { DroneManager.prototype.internal_update = function (delta_time) {
var context = this; var context = this;
...@@ -197,15 +204,6 @@ var DroneManager = /** @class */ (function () { ...@@ -197,15 +204,6 @@ var DroneManager = /** @class */ (function () {
} }
return this._API.setStartingPosition(this, x, y, z); return this._API.setStartingPosition(this, x, y, z);
}; };
DroneManager.prototype.setAirSpeed = function (speed) {
if (!this._canPlay) {
return;
}
if (isNaN(speed)) {
throw new Error('Speed must be a number');
}
return this._API.setSpeed(this, speed);
};
DroneManager.prototype.setDirection = function (x, y, z) { DroneManager.prototype.setDirection = function (x, y, z) {
if (!this._canPlay) { if (!this._canPlay) {
return; return;
...@@ -217,20 +215,6 @@ var DroneManager = /** @class */ (function () { ...@@ -217,20 +215,6 @@ var DroneManager = /** @class */ (function () {
this._direction = new BABYLON.Vector3(x, z, y).normalize(); this._direction = new BABYLON.Vector3(x, z, y).normalize();
}; };
//TODO rotation
DroneManager.prototype.setRotation = function (x, y, z) {
if (!this._canPlay) {
return;
}
return this._API.setRotation(this, x, y, z);
};
DroneManager.prototype.setRotationBy = function (x, y, z) {
if (!this._canPlay) {
return;
}
return this._API.setRotation(this, x, y, z);
};
/** /**
* Send a message to drones * Send a message to drones
* @param msg The message to send * @param msg The message to send
...@@ -299,11 +283,12 @@ var DroneManager = /** @class */ (function () { ...@@ -299,11 +283,12 @@ var DroneManager = /** @class */ (function () {
* Make the drone loiter (circle with a set radius) * Make the drone loiter (circle with a set radius)
*/ */
DroneManager.prototype.loiter = DroneManager.prototype.loiter =
function (latitude, longitude, altitude, radius) { function (latitude, longitude, altitude, radius, speed) {
this._internal_setTargetCoordinates( this._internal_setTargetCoordinates(
latitude, latitude,
longitude, longitude,
altitude, altitude,
speed,
radius radius
); );
}; };
...@@ -316,27 +301,29 @@ var DroneManager = /** @class */ (function () { ...@@ -316,27 +301,29 @@ var DroneManager = /** @class */ (function () {
DroneManager.prototype.getYaw = function () { DroneManager.prototype.getYaw = function () {
return this._API.getYaw(this); return this._API.getYaw(this);
}; };
DroneManager.prototype.getAirSpeed = function () { DroneManager.prototype.get3DSpeed = function () {
return this._speed; return this._speed;
}; };
DroneManager.prototype.getGroundSpeed = function () { DroneManager.prototype.getSpeed = function () {
return this._API.getGroundSpeed(this); return this._API.getSpeed(this);
}; };
DroneManager.prototype.getClimbRate = function () { DroneManager.prototype.getClimbRate = function () {
return this._API.getClimbRate(this); return this._API.getClimbRate(this);
}; };
DroneManager.prototype.getSinkRate = function () { DroneManager.prototype.takeOff = function () {
return this._API.getSinkRate(); return this._API.takeOff();
}; };
DroneManager.prototype.triggerParachute = function () { DroneManager.prototype.land = function () {
return this._API.triggerParachute(this); return this._API.land(this);
}; };
DroneManager.prototype.exit = function () { DroneManager.prototype.exit = function () {
this._internal_crash(); return this._internal_crash();
return this._API.exit();
}; };
DroneManager.prototype.landed = function () { DroneManager.prototype.isReadyToFly = function () {
return this._API.landed(this); return this._API.isReadyToFly();
};
DroneManager.prototype.isLanding = function () {
return this._API.isLanding();
}; };
/** /**
* Set the drone last checkpoint reached * Set the drone last checkpoint reached
...@@ -349,12 +336,12 @@ var DroneManager = /** @class */ (function () { ...@@ -349,12 +336,12 @@ var DroneManager = /** @class */ (function () {
/** /**
* Function called on game start * Function called on game start
*/ */
DroneManager.prototype.onStart = function () { return; }; DroneManager.prototype.onStart = function (timestamp) { return; };
/** /**
* Function called on game update * Function called on game update
* @param timestamp The tic value * @param timestamp The tic value
*/ */
DroneManager.prototype.onUpdate = function () { return; }; DroneManager.prototype.onUpdate = function (timestamp) { return; };
/** /**
* Function called when drone crashes * Function called when drone crashes
*/ */
...@@ -675,8 +662,12 @@ var GameManager = /** @class */ (function () { ...@@ -675,8 +662,12 @@ var GameManager = /** @class */ (function () {
drone._tick += 1; drone._tick += 1;
if (drone._API.isCollidable && drone.can_play) { if (drone._API.isCollidable && drone.can_play) {
if (drone.getCurrentPosition().altitude <= 0) { if (drone.getCurrentPosition().altitude <= 0) {
drone._internal_crash(new Error('Drone ' + drone.id + if (!drone.isLanding()) {
' touched the floor.')); drone._internal_crash(new Error('Drone ' + drone.id +
' touched the floor.'));
} else {
drone._internal_crash();
}
} else { } else {
_this._droneList.forEach(function (other) { _this._droneList.forEach(function (other) {
if (other.can_play && drone.id !== other.id) { if (other.can_play && drone.id !== other.id) {
...@@ -729,7 +720,7 @@ var GameManager = /** @class */ (function () { ...@@ -729,7 +720,7 @@ var GameManager = /** @class */ (function () {
game_manager._game_duration, geo_coordinates.latitude, game_manager._game_duration, geo_coordinates.latitude,
geo_coordinates.longitude, geo_coordinates.longitude,
map_info.start_AMSL + drone_position.z, map_info.start_AMSL + drone_position.z,
drone_position.z, drone.getYaw(), drone.getGroundSpeed(), drone_position.z, drone.getYaw(), drone.getSpeed(),
drone.getClimbRate() drone.getClimbRate()
]); ]);
} }
...@@ -912,8 +903,8 @@ var GameManager = /** @class */ (function () { ...@@ -912,8 +903,8 @@ var GameManager = /** @class */ (function () {
_this.ongoing_update_promise = null; _this.ongoing_update_promise = null;
_this.finish_deferred = RSVP.defer(); _this.finish_deferred = RSVP.defer();
console.log("Simulation started."); console.log("Simulation started.");
this._game_duration = 0; this._game_duration = Date.now();
this._totalTime = GAMEPARAMETERS.gameTime; this._totalTime = GAMEPARAMETERS.gameTime + this._game_duration;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () { .push(function () {
......
...@@ -240,7 +240,7 @@ ...@@ -240,7 +240,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.48744.22696.33177</string> </value> <value> <string>1014.60716.53618.32563</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -260,7 +260,7 @@ ...@@ -260,7 +260,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697032866.09</float> <float>1709288704.17</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
MAX_PITCH = 25, MAX_PITCH = 25,
MAX_CLIMB_RATE = 8, MAX_CLIMB_RATE = 8,
MAX_SINK_RATE = 3, MAX_SINK_RATE = 3,
MAX_COMMAND_FREQUENCY = 2,
INITIAL_POSITION = { INITIAL_POSITION = {
"latitude": 45.6412, "latitude": 45.6412,
"longitude": 14.2658, "longitude": 14.2658,
...@@ -87,18 +88,19 @@ ...@@ -87,18 +88,19 @@
' return 2 * R * Math.asin(Math.sqrt(h));\n' + ' return 2 * R * Math.asin(Math.sqrt(h));\n' +
'}\n' + '}\n' +
'\n' + '\n' +
'me.onStart = function () {\n' + 'me.onStart = function (timestamp) {\n' +
' me.direction_set = false;\n' + ' me.direction_set = false;\n' +
' me.next_checkpoint = 0;\n' + ' me.next_checkpoint = 0;\n' +
'};\n' + '};\n' +
'\n' + '\n' +
'me.onUpdate = function (timestamp) {' + 'me.onUpdate = function (timestamp) {\n' +
' if (!me.direction_set) {\n' + ' if (!me.direction_set) {\n' +
' if (me.next_checkpoint < CHECKPOINT_LIST.length) {\n' + ' if (me.next_checkpoint < CHECKPOINT_LIST.length) {\n' +
' me.setTargetCoordinates(\n' + ' me.setTargetCoordinates(\n' +
' CHECKPOINT_LIST[me.next_checkpoint].latitude,\n' + ' CHECKPOINT_LIST[me.next_checkpoint].latitude,\n' +
' CHECKPOINT_LIST[me.next_checkpoint].longitude,\n' + ' CHECKPOINT_LIST[me.next_checkpoint].longitude,\n' +
' CHECKPOINT_LIST[me.next_checkpoint].altitude + ALTITUDE + ALTITUDE * me.id\n' + ' CHECKPOINT_LIST[me.next_checkpoint].altitude + ALTITUDE + ALTITUDE * me.id,\n' +
' ' + DEFAULT_SPEED + '\n' +
' );\n' + ' );\n' +
' console.log("[DEMO] Going to Checkpoint %d", me.next_checkpoint);\n' + ' console.log("[DEMO] Going to Checkpoint %d", me.next_checkpoint);\n' +
' }\n' + ' }\n' +
...@@ -299,6 +301,17 @@ ...@@ -299,6 +301,17 @@
"hidden": 0, "hidden": 0,
"type": "FloatField" "type": "FloatField"
}, },
"my_drone_max_command_frequency": {
"description": "",
"title": "Drone max command frequency",
"default": MAX_COMMAND_FREQUENCY,
"css_class": "",
"required": 1,
"editable": 1,
"key": "drone_max_command_frequency",
"hidden": 0,
"type": "FloatField"
},
"my_minimum_latitud": { "my_minimum_latitud": {
"description": "", "description": "",
"title": "Minimum latitude", "title": "Minimum latitude",
...@@ -441,7 +454,8 @@ ...@@ -441,7 +454,8 @@
[["my_start_AMSL"], ["my_drone_min_speed"], ["my_drone_speed"], [["my_start_AMSL"], ["my_drone_min_speed"], ["my_drone_speed"],
["my_drone_max_speed"], ["my_drone_max_acceleration"], ["my_drone_max_speed"], ["my_drone_max_acceleration"],
["my_drone_max_deceleration"], ["my_drone_max_roll"], ["my_drone_min_pitch"], ["my_drone_max_deceleration"], ["my_drone_max_roll"], ["my_drone_min_pitch"],
["my_drone_max_pitch"], ["my_drone_max_sink_rate"], ["my_drone_max_climb_rate"]] ["my_drone_max_pitch"], ["my_drone_max_sink_rate"], ["my_drone_max_climb_rate"],
["my_drone_max_command_frequency"]]
], [ ], [
"bottom", "bottom",
[["my_script"]] [["my_script"]]
...@@ -479,7 +493,8 @@ ...@@ -479,7 +493,8 @@
"minPitchAngle": parseFloat(options.drone_min_pitch), "minPitchAngle": parseFloat(options.drone_min_pitch),
"maxPitchAngle": parseFloat(options.drone_max_pitch), "maxPitchAngle": parseFloat(options.drone_max_pitch),
"maxSinkRate": parseFloat(options.drone_max_sink_rate), "maxSinkRate": parseFloat(options.drone_max_sink_rate),
"maxClimbRate": parseFloat(options.drone_max_climb_rate) "maxClimbRate": parseFloat(options.drone_max_climb_rate),
"maxCommandFrequency": parseFloat(options.drone_max_command_frequency)
}, },
"gameTime": parseInt(options.simulation_time, 10), "gameTime": parseInt(options.simulation_time, 10),
"simulation_speed": parseInt(options.simulation_speed, 10), "simulation_speed": parseInt(options.simulation_speed, 10),
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1011.48716.48246.13943</string> </value> <value> <string>1014.60725.60577.24917</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1697031250.03</float> <float>1709289017.41</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
...@@ -56,14 +56,16 @@ ...@@ -56,14 +56,16 @@
' assert(coord1.altitude, coord2.altitude, "Altitude")\n' + ' assert(coord1.altitude, coord2.altitude, "Altitude")\n' +
'}\n' + '}\n' +
'\n' + '\n' +
'me.onStart = function () {\n' + 'me.onStart = function (timestamp) {\n' +
' assert(me.getAirSpeed(), 16, "Initial speed");\n' + ' assert(me.getSpeed(), ' + DEFAULT_SPEED + ', "Initial speed");\n' +
' assert(me.getYaw(), 0, "Yaw angle")\n' + ' assert(me.getYaw(), 0, "Yaw angle")\n' +
' me.initialPosition = me.getCurrentPosition();\n' + ' me.initialPosition = me.getCurrentPosition();\n' +
' me.start_time = timestamp;\n' +
' me.setTargetCoordinates(\n' + ' me.setTargetCoordinates(\n' +
' me.initialPosition.latitude + 0.01,\n' + ' me.initialPosition.latitude + 0.01,\n' +
' me.initialPosition.longitude,\n' + ' me.initialPosition.longitude,\n' +
' me.getAltitudeAbs()\n' + ' me.getAltitudeAbs(),\n' +
' ' + DEFAULT_SPEED + '\n' +
' );\n' + ' );\n' +
'};\n' + '};\n' +
'\n' + '\n' +
...@@ -75,8 +77,10 @@ ...@@ -75,8 +77,10 @@
' me.getCurrentPosition().latitude,\n' + ' me.getCurrentPosition().latitude,\n' +
' me.getCurrentPosition().longitude\n' + ' me.getCurrentPosition().longitude\n' +
' ).toFixed(8),\n' + ' ).toFixed(8),\n' +
' expectedDistance = (me.getAirSpeed() * timestamp / 1000).toFixed(8);\n' + ' time_interval = timestamp - me.start_time,\n' +
' assert(timestamp, 1000 / 60, "Timestamp");\n' + ' expected_interval = 1000 / 60,\n' +
' expectedDistance = (me.getSpeed() * expected_interval / 1000).toFixed(8);\n' +
' assert(time_interval.toFixed(4), expected_interval.toFixed(4), "Timestamp");\n' +
' assert(realDistance, expectedDistance, "Distance");\n' + ' assert(realDistance, expectedDistance, "Distance");\n' +
' current_position.latitude = current_position.latitude.toFixed(7);\n' + ' current_position.latitude = current_position.latitude.toFixed(7);\n' +
' compare(current_position, {\n' + ' compare(current_position, {\n' +
...@@ -84,7 +88,7 @@ ...@@ -84,7 +88,7 @@
' longitude: me.initialPosition.longitude,\n' + ' longitude: me.initialPosition.longitude,\n' +
' altitude: me.initialPosition.altitude\n' + ' altitude: me.initialPosition.altitude\n' +
' });\n' + ' });\n' +
' me.exit(me.triggerParachute());\n' + ' me.exit(me.land());\n' +
'};', '};',
DRAW = true, DRAW = true,
LOG = true, LOG = true,
......
...@@ -246,7 +246,7 @@ ...@@ -246,7 +246,7 @@
</item> </item>
<item> <item>
<key> <string>serial</string> </key> <key> <string>serial</string> </key>
<value> <string>1012.50925.12802.42871</string> </value> <value> <string>1014.60681.20667.37171</string> </value>
</item> </item>
<item> <item>
<key> <string>state</string> </key> <key> <string>state</string> </key>
...@@ -266,7 +266,7 @@ ...@@ -266,7 +266,7 @@
</tuple> </tuple>
<state> <state>
<tuple> <tuple>
<float>1701095838.64</float> <float>1709286436.53</float>
<string>UTC</string> <string>UTC</string>
</tuple> </tuple>
</state> </state>
......
container.REQUEST.RESPONSE.setHeader('Content-Type', 'text/html') container.REQUEST.RESPONSE.setHeader('Content-Type', 'text/html')
print "<html><body><h1 class='test-script-title'>Title is : " + parameter + "</h1></body></html>" print("<html><body><h1 class='test-script-title'>Title is : " + parameter + "</h1></body></html>")
return printed return printed
...@@ -8,8 +8,8 @@ line_dict_list = context.PaySheetTransaction_getLineListAsDict() ...@@ -8,8 +8,8 @@ line_dict_list = context.PaySheetTransaction_getLineListAsDict()
title_list = ['Designation\t\t', 'Base', 'Employer Rate', 'Employer Share', title_list = ['Designation\t\t', 'Base', 'Employer Rate', 'Employer Share',
'Employee Rate', 'Employee Share'] 'Employee Rate', 'Employee Share']
print '\t\t'.join(title_list) print('\t\t'.join(title_list))
print '' print('')
def rightPad(string, length): def rightPad(string, length):
string=str(string) string=str(string)
...@@ -36,6 +36,6 @@ for line in line_dict_list: ...@@ -36,6 +36,6 @@ for line in line_dict_list:
string_to_display.append(rightPad(' ', 24)) string_to_display.append(rightPad(' ', 24))
string_to_display.append(rightPad(' ', 24)) string_to_display.append(rightPad(' ', 24))
print ''.join(string_to_display) print(''.join(string_to_display))
return printed return printed
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
</item> </item>
<item> <item>
<key> <string>title</string> </key> <key> <string>title</string> </key>
<value> <string>Print DSN report</string> </value> <value> <string>Print DSN</string> </value>
</item> </item>
<item> <item>
<key> <string>visible</string> </key> <key> <string>visible</string> </key>
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
<dictionary> <dictionary>
<item> <item>
<key> <string>text</string> </key> <key> <string>text</string> </key>
<value> <string>string:${object_url}/DSNReport_printAsFile</string> </value> <value> <string>string:${object_url}/DSNMonthlyReport_viewFilePrintDialog</string> </value>
</item> </item>
</dictionary> </dictionary>
</pickle> </pickle>
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment