-
Notifications
You must be signed in to change notification settings - Fork 11
Init module for generation scripts #65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
iskrich
wants to merge
3
commits into
lanit-summer:master
Choose a base branch
from
iskrich:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,57 @@ | ||
| #Generic for script.cel file | ||
| script = [ | ||
| '{\n', | ||
| 'time{utc "2015-01-01T00:01:24.0000"}\n', | ||
| 'select{object "Orbit-test-spacecraft"}\n', | ||
| 'center {time 5.0}\n', | ||
| 'goto { time 5.0 }\n', | ||
| 'follow{}\n', | ||
| 'lock{}\n', | ||
| '}' | ||
| ] | ||
|
|
||
| #Generic for orbit.ssc file | ||
| scriptSSC = [ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Тот же коммент что и для makeScript и script |
||
| '"Orbit-test-spacecraft" "Sol"\n', | ||
| '{\n', | ||
| '\tClass "spacecraft"\n', | ||
| '\tMesh "orbit.3ds"\n', | ||
| '\tRadius 0.011\n', | ||
| '\tOrientation [ 180 1 0 0 ]\n', | ||
| '\tTimeline [\n', | ||
| '\t# Phase 3: Solstice mission\n', | ||
| '\t{\n', | ||
| '\tBeginning "2015 01 01 00:00:00"\n', | ||
| '\tEnding "2020 9 15 17:02:00"\n', | ||
| '\tOrbitFrame { EclipticJ2000 { Center "Sol/Earth" } }\n', | ||
| '\tSampledTrajectory { Source "orbit.xyzv" }\n', | ||
| '\t}\n', | ||
| '\t]\n', | ||
| '}\n', | ||
| ] | ||
|
|
||
|
|
||
| def makeScript(beginDate,shipName): | ||
| #set new begin date | ||
| script[1] = 'time{utc "' + str(beginDate) + '"}\n' | ||
| #set new ship object | ||
| script[2] = 'select{object "' + str(shipName) + '"}\n' | ||
|
|
||
| f = open("script.cel","w") | ||
| for line in script: | ||
| f.write(line) | ||
|
|
||
| def makeSSCScript(beginDate, endDate, shipName): | ||
| #set new ship name | ||
| scriptSSC[0] = '"'+str(shipName)+'" "Sol"\n' | ||
| #set new begin/end date | ||
| scriptSSC[9] = '\tBeginning "' +str(beginDate)+'"\n' | ||
| scriptSSC[10] = '\tEnding "' +str(endDate)+'"\n' | ||
|
|
||
| f = open("orbit.ssc","w") | ||
| for line in scriptSSC: | ||
| f.write(line) | ||
|
|
||
| if __name__ == '__main__': | ||
| makeScript("2015 01 01 00:00:00","ORBIT") | ||
| makeSSCScript("2015 01 01 00:00:00","2016 01 01 00:00:00","ORBIT") | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
эти массив строк нигде не используется кроме как в методе makeScript - поэтому нет смысла выносить его отдельно. Можно сразу писать в самом методе, тогда получится примерно следующее:
+def makeScript(beginDate,shipName):
script = [
{\n',
+'}'
]
.....
Плюс нужно проверять что параметры метода не пустые и валидные
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Валидацию завтра реализую.
По поводу решения вынести шаблон скрипта в глобальное поле:
дефолтные скрипты могут часто использоваться, достать без генерации можно будет как
scriptFactory.scriptThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А почему они будут часто использоваться?
Что мне не нравится в script - это явно прописанное время. Сейчас там прописана дата, пусть условно она актуальна сейчас(хотя там 2015 год...), но, например. пройдет еще год - хотим мы по дефолту иметь там 2015? На мой взгляд, если нам реально нужно возвращать по дефолту что-то, то хочется там видеть время с 1 января текущего года.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Нет ли в питоне каких то средств работы с временем? что нибудь типа DateTime.UTCNow()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
да, есть.
январь 2015 это то, начиная откуда по дефолту генерится траектория. Поэтому и скрипт дефолтный такой.
В питоне есть именные параметры метода, можем сделать, что если begind/endDate не заданы, берём текущую дату. шаблон скрипта соответственно будет внутри метода.
полиморфизм соответственно будет в том, что если вызываем метод без параметров, будет возвращаться дефолтный скрипт с текущей датой.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тогда ещё вопрос с датой окончания
можно захардкодить например +1 год...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Да хорошо, можно даже не текущую дату, а начало текущего года, ну и конец года как дату окончания - по дефолту 1 год для околоземных орбит нормально мне кажется.