Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
###FOR PUSHING STATIC TO AWS
###用于将静态文件推送到 AWS



Expand All @@ -15,7 +15,7 @@



###FOR GENERAL USES
###通用配置



Expand Down
20 changes: 10 additions & 10 deletions environment/frontend_server/frontend_server/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# 项目内部的路径构建方式如下: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# 快速启动开发设置 - 不适用于生产环境
# 参见 https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
# 安全警告: 生产环境中使用的密钥必须保密!
SECRET_KEY = 'c7l%1%b=2sh$o9zqvd4i*h8*__^@-5sm-y)m(1ib2t92)43@62'

# SECURITY WARNING: don't run with debug turned on in production!
# 安全警告: 不要在生产环境中启用调试模式!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition
# 应用定义

INSTALLED_APPS = [
'django.contrib.admin',
Expand Down Expand Up @@ -74,7 +74,7 @@
WSGI_APPLICATION = 'frontend_server.wsgi.application'


# Database
# 数据库
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
Expand All @@ -85,7 +85,7 @@
}


# Password validation
# 密码验证
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
Expand All @@ -104,7 +104,7 @@
]


# Internationalization
# 国际化
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'
Expand All @@ -118,7 +118,7 @@
USE_TZ = True


# Static files (CSS, JavaScript, Images)
# 静态文件 (CSS, JavaScript, 图片)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'
Expand Down
20 changes: 10 additions & 10 deletions environment/frontend_server/frontend_server/settings/local.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
# 项目内部的路径构建方式如下: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
# 快速启动开发设置 - 不适用于生产环境
# 参见 https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
# 安全警告: 生产环境中使用的密钥必须保密!
SECRET_KEY = 'c7l%1%b=2sh$o9zqvd4i*h8*__^@-5sm-y)m(1ib2t92)43@62'

# SECURITY WARNING: don't run with debug turned on in production!
# 安全警告: 不要在生产环境中启用调试模式!
DEBUG = True

ALLOWED_HOSTS = []


# Application definition
# 应用定义

INSTALLED_APPS = [
'django.contrib.admin',
Expand Down Expand Up @@ -74,7 +74,7 @@
WSGI_APPLICATION = 'frontend_server.wsgi.application'


# Database
# 数据库
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
Expand All @@ -85,7 +85,7 @@
}


# Password validation
# 密码验证
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
Expand All @@ -104,7 +104,7 @@
]


# Internationalization
# 国际化
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'
Expand All @@ -118,7 +118,7 @@
USE_TZ = True


# Static files (CSS, JavaScript, Images)
# 静态文件 (CSS, JavaScript, 图片)
# https://docs.djangoproject.com/en/2.2/howto/static-files/


Expand Down
24 changes: 12 additions & 12 deletions environment/frontend_server/frontend_server/urls.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
"""frontend_server URL Configuration
"""frontend_server URL 配置

The `urlpatterns` list routes URLs to views. For more information please see:
`urlpatterns` 列表将 URL 路由到视图。更多信息请参见:
https://docs.djangoproject.com/en/2.2/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
示例:
函数视图
1. 添加导入: from my_app import views
2. 向 urlpatterns 添加一个 URL: path('', views.home, name='home')
基于类的视图
1. 添加导入: from other_app.views import Home
2. 向 urlpatterns 添加一个 URL: path('', Home.as_view(), name='home')
包含另一个 URLconf
1. 导入 include() 函数: from django.urls import include, path
2. 向 urlpatterns 添加一个 URL: path('blog/', include('blog.urls'))
"""
from django.conf.urls import include, url
from django.urls import path
Expand Down
6 changes: 3 additions & 3 deletions environment/frontend_server/frontend_server/wsgi.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
WSGI config for frontend_server project.
frontend_server 项目的 WSGI 配置。

It exposes the WSGI callable as a module-level variable named ``application``.
它将 WSGI 可调用对象公开为名为 ``application`` 的模块级变量。

For more information on this file, see
有关此文件的更多信息,请参阅
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
// Phaser 3.0 global settings.
// Configuration meant to be passed to the main Phaser game instance.
const config = {
type: Phaser.AUTO,
type: Phaser.CANVAS,
width: 1500,
height: 800,
parent: "game-container",
Expand Down
2 changes: 1 addition & 1 deletion environment/frontend_server/translator/tests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
from django.test import TestCase

# Create your tests here.
# 在此处创建您的测试。
75 changes: 35 additions & 40 deletions environment/frontend_server/translator/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""
Author: Joon Sung Park ([email protected])
File: views.py
作者: Joon Sung Park ([email protected])
文件: views.py
"""
import os
import string
Expand Down Expand Up @@ -32,7 +32,7 @@ def demo(request, sim_code, step, play_speed="2"):
if play_speed not in play_speed_opt: play_speed = 2
else: play_speed = play_speed_opt[play_speed]

# Loading the basic meta information about the simulation.
# 加载关于模拟的基本元信息。
meta = dict()
with open (meta_file) as json_file:
meta = json.load(json_file)
Expand All @@ -44,12 +44,12 @@ def demo(request, sim_code, step, play_speed="2"):
start_datetime += datetime.timedelta(seconds=sec_per_step)
start_datetime = start_datetime.strftime("%Y-%m-%dT%H:%M:%S")

# Loading the movement file
# 加载移动文件
raw_all_movement = dict()
with open(move_file) as json_file:
raw_all_movement = json.load(json_file)

# Loading all names of the personas
# 加载所有角色的名称
persona_names = dict()
persona_names = []
persona_names_set = set()
Expand All @@ -59,15 +59,13 @@ def demo(request, sim_code, step, play_speed="2"):
"initial": p[0] + p.split(" ")[-1][0]}]
persona_names_set.add(p)

# <all_movement> is the main movement variable that we are passing to the
# frontend. Whereas we use ajax scheme to communicate steps to the frontend
# during the simulation stage, for this demo, we send all movement
# information in one step.
# <all_movement> 是我们传递给前端的主要移动变量。
# 在模拟阶段,我们使用 ajax 方案与前端通信步骤,但在此演示中,
# 我们一步发送所有移动信息。
all_movement = dict()

# Preparing the initial step.
# <init_prep> sets the locations and descriptions of all agents at the
# beginning of the demo determined by <step>.
# 准备初始步骤。
# <init_prep> 设置由 <step> 决定的演示开始时所有代理的位置和描述。
init_prep = dict()
for int_key in range(step+1):
key = str(int_key)
Expand All @@ -80,7 +78,7 @@ def demo(request, sim_code, step, play_speed="2"):
persona_init_pos[p.replace(" ","_")] = init_prep[p]["movement"]
all_movement[step] = init_prep

# Finish loading <all_movement>
# 完成加载 <all_movement>
for int_key in range(step+1, len(raw_all_movement.keys())):
all_movement[int_key] = raw_all_movement[str(int_key)]

Expand Down Expand Up @@ -240,15 +238,14 @@ def path_tester(request):

def process_environment(request):
"""
<FRONTEND to BACKEND>
This sends the frontend visual world information to the backend server.
It does this by writing the current environment representation to
"storage/environment.json" file.

ARGS:
request: Django request
RETURNS:
HttpResponse: string confirmation message.
<前端到后端>
此函数将前端可视化世界信息发送到后端服务器。
它通过将当前环境表示写入 "storage/environment.json" 文件来完成此操作。

参数:
request: Django 请求
返回:
HttpResponse: 字符串确认消息。
"""
# f_curr_sim_code = "temp_storage/curr_sim_code.json"
# with open(f_curr_sim_code) as json_file:
Expand All @@ -262,21 +259,19 @@ def process_environment(request):
with open(f"storage/{sim_code}/environment/{step}.json", "w") as outfile:
outfile.write(json.dumps(environment, indent=2))

return HttpResponse("received")
return HttpResponse("已接收")


def update_environment(request):
"""
<BACKEND to FRONTEND>
This sends the backend computation of the persona behavior to the frontend
visual server.
It does this by reading the new movement information from
"storage/movement.json" file.

ARGS:
request: Django request
RETURNS:
HttpResponse
<后端到前端>
此函数将角色行为的后端计算结果发送到前端可视化服务器。
它通过从 "storage/movement.json" 文件读取新的移动信息来完成此操作。

参数:
request: Django 请求
返回:
JsonResponse
"""
# f_curr_sim_code = "temp_storage/curr_sim_code.json"
# with open(f_curr_sim_code) as json_file:
Expand All @@ -297,21 +292,21 @@ def update_environment(request):

def path_tester_update(request):
"""
Processing the path and saving it to path_tester_env.json temp storage for
conducting the path tester.
处理路径并将其保存到 path_tester_env.json 临时存储中,
以便进行路径测试。

ARGS:
request: Django request
RETURNS:
HttpResponse: string confirmation message.
参数:
request: Django 请求
返回:
HttpResponse: 字符串确认消息。
"""
data = json.loads(request.body)
camera = data["camera"]

with open(f"temp_storage/path_tester_env.json", "w") as outfile:
outfile.write(json.dumps(camera, indent=2))

return HttpResponse("received")
return HttpResponse("已接收")



Expand Down
Loading