unageanu-jiji 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +0 -0
- data/README +0 -0
- data/bin/jiji.rb +6 -0
- data/html/css/calendar.css +432 -0
- data/html/css/datatable.css +299 -0
- data/html/css/default.css +557 -0
- data/html/css/dialog.css +77 -0
- data/html/img/auto_trade_off.gif +0 -0
- data/html/img/auto_trade_on.gif +0 -0
- data/html/img/back_bottom.gif +0 -0
- data/html/img/back_middle.gif +0 -0
- data/html/img/back_top.gif +0 -0
- data/html/img/bt-create-title-1.gif +0 -0
- data/html/img/bt-create-title-2.gif +0 -0
- data/html/img/bt-create-title-3.gif +0 -0
- data/html/img/button_add.gif +0 -0
- data/html/img/button_add_gray.gif +0 -0
- data/html/img/button_add_over.gif +0 -0
- data/html/img/button_apply.gif +0 -0
- data/html/img/button_apply_gray.gif +0 -0
- data/html/img/button_apply_over.gif +0 -0
- data/html/img/button_calendar.gif +0 -0
- data/html/img/button_calendar_over.gif +0 -0
- data/html/img/button_cancel.gif +0 -0
- data/html/img/button_cancel.jpg +0 -0
- data/html/img/button_cancel_gray.gif +0 -0
- data/html/img/button_cancel_over.gif +0 -0
- data/html/img/button_cancel_over.jpg +0 -0
- data/html/img/button_close.gif +0 -0
- data/html/img/button_close_gray.gif +0 -0
- data/html/img/button_close_over.gif +0 -0
- data/html/img/button_ok.gif +0 -0
- data/html/img/button_ok_gray.gif +0 -0
- data/html/img/button_ok_over.gif +0 -0
- data/html/img/button_remove.gif +0 -0
- data/html/img/button_remove_gray.gif +0 -0
- data/html/img/button_remove_over.gif +0 -0
- data/html/img/button_start.gif +0 -0
- data/html/img/button_start_over.gif +0 -0
- data/html/img/button_update.gif +0 -0
- data/html/img/button_update_gray.gif +0 -0
- data/html/img/button_update_over.gif +0 -0
- data/html/img/circle.gif +0 -0
- data/html/img/delta.gif +0 -0
- data/html/img/dialog_info.jpg +0 -0
- data/html/img/dialog_input.jpg +0 -0
- data/html/img/dialog_warn.jpg +0 -0
- data/html/img/dt-arrow-dn.png +0 -0
- data/html/img/dt-arrow-up.png +0 -0
- data/html/img/foot.jpg +0 -0
- data/html/img/h3_bt-create_0.gif +0 -0
- data/html/img/h3_bt-create_1.gif +0 -0
- data/html/img/h3_bt-create_2.gif +0 -0
- data/html/img/h3_result_0.gif +0 -0
- data/html/img/h3_result_1.gif +0 -0
- data/html/img/h3_result_2.gif +0 -0
- data/html/img/h3_result_3.gif +0 -0
- data/html/img/h3_result_4.gif +0 -0
- data/html/img/h3_result_5.gif +0 -0
- data/html/img/h3_result_6.gif +0 -0
- data/html/img/h3_rt-setting_0.gif +0 -0
- data/html/img/h3_rt-setting_1.gif +0 -0
- data/html/img/head.jpg +0 -0
- data/html/img/line_white.gif +0 -0
- data/html/img/loading.gif +0 -0
- data/html/img/panel_100_bottom.gif +0 -0
- data/html/img/panel_100_middle.gif +0 -0
- data/html/img/panel_100_top.gif +0 -0
- data/html/img/panel_140_650_b.gif +0 -0
- data/html/img/panel_140_650_m.gif +0 -0
- data/html/img/panel_140_650_t.gif +0 -0
- data/html/img/panel_140_660_b.gif +0 -0
- data/html/img/panel_140_660_m.gif +0 -0
- data/html/img/panel_140_660_t.gif +0 -0
- data/html/img/panel_140_b.gif +0 -0
- data/html/img/panel_140_m.gif +0 -0
- data/html/img/panel_140_t.gif +0 -0
- data/html/img/panel_260_b.gif +0 -0
- data/html/img/panel_260_m.gif +0 -0
- data/html/img/panel_260_t.gif +0 -0
- data/html/img/panel_300_b.gif +0 -0
- data/html/img/panel_300_m.gif +0 -0
- data/html/img/panel_300_t.gif +0 -0
- data/html/img/panel_320_b.gif +0 -0
- data/html/img/panel_320_m.gif +0 -0
- data/html/img/panel_320_t.gif +0 -0
- data/html/img/panel_360_b.gif +0 -0
- data/html/img/panel_360_m.gif +0 -0
- data/html/img/panel_360_t.gif +0 -0
- data/html/img/panel_380_b.gif +0 -0
- data/html/img/panel_380_m.gif +0 -0
- data/html/img/panel_380_t.gif +0 -0
- data/html/img/panel_500_b.gif +0 -0
- data/html/img/panel_500_m.gif +0 -0
- data/html/img/panel_500_t.gif +0 -0
- data/html/img/panel_620_b.gif +0 -0
- data/html/img/panel_620_m.gif +0 -0
- data/html/img/panel_620_t.gif +0 -0
- data/html/img/panel_780_b.gif +0 -0
- data/html/img/panel_780_m.gif +0 -0
- data/html/img/panel_780_t.gif +0 -0
- data/html/img/problem.gif +0 -0
- data/html/img/progressbar.gif +0 -0
- data/html/img/result-title-1-1.gif +0 -0
- data/html/img/result-title-1-2.gif +0 -0
- data/html/img/result-title-2-1.gif +0 -0
- data/html/img/result-title-2-2.gif +0 -0
- data/html/img/result-title-3-1.gif +0 -0
- data/html/img/result-title-4-1.gif +0 -0
- data/html/img/rt-setting-title-1.gif +0 -0
- data/html/img/rt-setting-title-2.gif +0 -0
- data/html/img/s.gif +0 -0
- data/html/img/scroll.gif +0 -0
- data/html/img/separator.gif +0 -0
- data/html/img/sidebar_agent.png +0 -0
- data/html/img/sidebar_agent_edit.png +0 -0
- data/html/img/sidebar_agent_edit_agent.png +0 -0
- data/html/img/sidebar_agent_edit_agent_over.png +0 -0
- data/html/img/sidebar_agent_edit_agent_s.png +0 -0
- data/html/img/sidebar_agent_edit_over.png +0 -0
- data/html/img/sidebar_agent_edit_s.png +0 -0
- data/html/img/sidebar_agent_edit_shared_lib.png +0 -0
- data/html/img/sidebar_agent_edit_shared_lib_over.png +0 -0
- data/html/img/sidebar_agent_edit_shared_lib_s.png +0 -0
- data/html/img/sidebar_back.gif +0 -0
- data/html/img/sidebar_bt.png +0 -0
- data/html/img/sidebar_bt_create.png +0 -0
- data/html/img/sidebar_bt_create_over.png +0 -0
- data/html/img/sidebar_bt_create_s.png +0 -0
- data/html/img/sidebar_bt_result.png +0 -0
- data/html/img/sidebar_bt_result_over.png +0 -0
- data/html/img/sidebar_bt_result_s.png +0 -0
- data/html/img/sidebar_result_rmt.png +0 -0
- data/html/img/sidebar_result_rmt_over.png +0 -0
- data/html/img/sidebar_result_rmt_s.png +0 -0
- data/html/img/sidebar_rt.png +0 -0
- data/html/img/sidebar_rt_setting.png +0 -0
- data/html/img/sidebar_rt_setting_over.png +0 -0
- data/html/img/sidebar_rt_setting_s.png +0 -0
- data/html/img/sprite.png +0 -0
- data/html/img/submenu_agents.png +0 -0
- data/html/img/submenu_agents_over.png +0 -0
- data/html/img/submenu_agents_s.png +0 -0
- data/html/img/submenu_graph.png +0 -0
- data/html/img/submenu_graph_over.png +0 -0
- data/html/img/submenu_graph_s.png +0 -0
- data/html/img/submenu_info.png +0 -0
- data/html/img/submenu_info_over.png +0 -0
- data/html/img/submenu_info_s.png +0 -0
- data/html/img/submenu_log.png +0 -0
- data/html/img/submenu_log_over.png +0 -0
- data/html/img/submenu_log_s.png +0 -0
- data/html/img/submenu_operation.png +0 -0
- data/html/img/submenu_operation_over.png +0 -0
- data/html/img/submenu_operation_s.png +0 -0
- data/html/img/submenu_trade.png +0 -0
- data/html/img/submenu_trade_over.png +0 -0
- data/html/img/submenu_trade_s.png +0 -0
- data/html/img/td_over.gif +0 -0
- data/html/img/td_over_d.gif +0 -0
- data/html/img/td_selected.gif +0 -0
- data/html/img/thead.gif +0 -0
- data/html/img/transparent.gif +0 -0
- data/html/index.html +480 -0
- data/html/js/W3CDTF.js +131 -0
- data/html/js/agent-editor-page.js +350 -0
- data/html/js/agent-selector.js +642 -0
- data/html/js/app.js +226 -0
- data/html/js/bt-create-page.js +186 -0
- data/html/js/codepress/codepress.css +21 -0
- data/html/js/codepress/codepress.html +35 -0
- data/html/js/codepress/codepress.js +138 -0
- data/html/js/codepress/engines/gecko.js +293 -0
- data/html/js/codepress/engines/khtml.js +0 -0
- data/html/js/codepress/engines/msie.js +304 -0
- data/html/js/codepress/engines/older.js +0 -0
- data/html/js/codepress/engines/opera.js +260 -0
- data/html/js/codepress/images/line-numbers.gif +0 -0
- data/html/js/codepress/images/line-numbers.png +0 -0
- data/html/js/codepress/index.html +443 -0
- data/html/js/codepress/languages/asp.css +71 -0
- data/html/js/codepress/languages/asp.js +117 -0
- data/html/js/codepress/languages/autoit.css +13 -0
- data/html/js/codepress/languages/autoit.js +32 -0
- data/html/js/codepress/languages/csharp.css +9 -0
- data/html/js/codepress/languages/csharp.js +25 -0
- data/html/js/codepress/languages/css.css +10 -0
- data/html/js/codepress/languages/css.js +23 -0
- data/html/js/codepress/languages/generic.css +9 -0
- data/html/js/codepress/languages/generic.js +25 -0
- data/html/js/codepress/languages/html.css +13 -0
- data/html/js/codepress/languages/html.js +59 -0
- data/html/js/codepress/languages/java.css +7 -0
- data/html/js/codepress/languages/java.js +24 -0
- data/html/js/codepress/languages/javascript.css +8 -0
- data/html/js/codepress/languages/javascript.js +30 -0
- data/html/js/codepress/languages/perl.css +11 -0
- data/html/js/codepress/languages/perl.js +27 -0
- data/html/js/codepress/languages/php.css +12 -0
- data/html/js/codepress/languages/php.js +61 -0
- data/html/js/codepress/languages/ruby.css +10 -0
- data/html/js/codepress/languages/ruby.js +26 -0
- data/html/js/codepress/languages/sql.css +10 -0
- data/html/js/codepress/languages/sql.js +30 -0
- data/html/js/codepress/languages/text.css +5 -0
- data/html/js/codepress/languages/text.js +9 -0
- data/html/js/codepress/languages/vbscript.css +71 -0
- data/html/js/codepress/languages/vbscript.js +117 -0
- data/html/js/codepress/languages/xsl.css +15 -0
- data/html/js/codepress/languages/xsl.js +103 -0
- data/html/js/codepress/license.txt +458 -0
- data/html/js/container-min.js +1 -0
- data/html/js/container-utils.js +78 -0
- data/html/js/dialog.js +270 -0
- data/html/js/edit_area/autocompletion.js +493 -0
- data/html/js/edit_area/edit_area.css +507 -0
- data/html/js/edit_area/edit_area.js +510 -0
- data/html/js/edit_area/edit_area_compressor.php +408 -0
- data/html/js/edit_area/edit_area_full.gz +0 -0
- data/html/js/edit_area/edit_area_full.js +38 -0
- data/html/js/edit_area/edit_area_full_with_plugins.gz +0 -0
- data/html/js/edit_area/edit_area_full_with_plugins.js +39 -0
- data/html/js/edit_area/edit_area_functions.js +1098 -0
- data/html/js/edit_area/edit_area_loader.js +1070 -0
- data/html/js/edit_area/elements_functions.js +337 -0
- data/html/js/edit_area/highlight.js +283 -0
- data/html/js/edit_area/images/Thumbs.db +0 -0
- data/html/js/edit_area/images/autocompletion.gif +0 -0
- data/html/js/edit_area/images/close.gif +0 -0
- data/html/js/edit_area/images/fullscreen.gif +0 -0
- data/html/js/edit_area/images/go_to_line.gif +0 -0
- data/html/js/edit_area/images/help.gif +0 -0
- data/html/js/edit_area/images/highlight.gif +0 -0
- data/html/js/edit_area/images/load.gif +0 -0
- data/html/js/edit_area/images/move.gif +0 -0
- data/html/js/edit_area/images/newdocument.gif +0 -0
- data/html/js/edit_area/images/opacity.png +0 -0
- data/html/js/edit_area/images/processing.gif +0 -0
- data/html/js/edit_area/images/redo.gif +0 -0
- data/html/js/edit_area/images/reset_highlight.gif +0 -0
- data/html/js/edit_area/images/save.gif +0 -0
- data/html/js/edit_area/images/search.gif +0 -0
- data/html/js/edit_area/images/smooth_selection.gif +0 -0
- data/html/js/edit_area/images/spacer.gif +0 -0
- data/html/js/edit_area/images/statusbar_resize.gif +0 -0
- data/html/js/edit_area/images/undo.gif +0 -0
- data/html/js/edit_area/keyboard.js +145 -0
- data/html/js/edit_area/langs/cs.js +65 -0
- data/html/js/edit_area/langs/de.js +65 -0
- data/html/js/edit_area/langs/dk.js +65 -0
- data/html/js/edit_area/langs/en.js +65 -0
- data/html/js/edit_area/langs/eo.js +65 -0
- data/html/js/edit_area/langs/es.js +62 -0
- data/html/js/edit_area/langs/fr.js +65 -0
- data/html/js/edit_area/langs/hr.js +65 -0
- data/html/js/edit_area/langs/it.js +65 -0
- data/html/js/edit_area/langs/ja.js +65 -0
- data/html/js/edit_area/langs/mk.js +65 -0
- data/html/js/edit_area/langs/nl.js +65 -0
- data/html/js/edit_area/langs/pl.js +65 -0
- data/html/js/edit_area/langs/pt.js +65 -0
- data/html/js/edit_area/langs/ru.js +65 -0
- data/html/js/edit_area/langs/sk.js +65 -0
- data/html/js/edit_area/license_apache.txt +7 -0
- data/html/js/edit_area/license_bsd.txt +10 -0
- data/html/js/edit_area/license_lgpl.txt +458 -0
- data/html/js/edit_area/manage_area.js +466 -0
- data/html/js/edit_area/plugins/charmap/charmap.js +90 -0
- data/html/js/edit_area/plugins/charmap/css/charmap.css +64 -0
- data/html/js/edit_area/plugins/charmap/images/charmap.gif +0 -0
- data/html/js/edit_area/plugins/charmap/jscripts/map.js +373 -0
- data/html/js/edit_area/plugins/charmap/langs/cs.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/de.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/dk.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/en.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/eo.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/es.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/fr.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/hr.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/it.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/ja.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/mk.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/nl.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/pl.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/pt.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/ru.js +6 -0
- data/html/js/edit_area/plugins/charmap/langs/sk.js +6 -0
- data/html/js/edit_area/plugins/charmap/popup.html +24 -0
- data/html/js/edit_area/plugins/test/css/test.css +3 -0
- data/html/js/edit_area/plugins/test/images/Thumbs.db +0 -0
- data/html/js/edit_area/plugins/test/images/test.gif +0 -0
- data/html/js/edit_area/plugins/test/langs/cs.js +4 -0
- data/html/js/edit_area/plugins/test/langs/de.js +4 -0
- data/html/js/edit_area/plugins/test/langs/dk.js +4 -0
- data/html/js/edit_area/plugins/test/langs/en.js +4 -0
- data/html/js/edit_area/plugins/test/langs/eo.js +4 -0
- data/html/js/edit_area/plugins/test/langs/es.js +4 -0
- data/html/js/edit_area/plugins/test/langs/fr.js +4 -0
- data/html/js/edit_area/plugins/test/langs/hr.js +4 -0
- data/html/js/edit_area/plugins/test/langs/it.js +4 -0
- data/html/js/edit_area/plugins/test/langs/ja.js +4 -0
- data/html/js/edit_area/plugins/test/langs/mk.js +4 -0
- data/html/js/edit_area/plugins/test/langs/nl.js +4 -0
- data/html/js/edit_area/plugins/test/langs/pl.js +4 -0
- data/html/js/edit_area/plugins/test/langs/pt.js +4 -0
- data/html/js/edit_area/plugins/test/langs/ru.js +4 -0
- data/html/js/edit_area/plugins/test/langs/sk.js +4 -0
- data/html/js/edit_area/plugins/test/test.js +110 -0
- data/html/js/edit_area/plugins/test/test2.js +1 -0
- data/html/js/edit_area/reg_syntax.js +164 -0
- data/html/js/edit_area/reg_syntax/basic.js +69 -0
- data/html/js/edit_area/reg_syntax/brainfuck.js +44 -0
- data/html/js/edit_area/reg_syntax/c.js +62 -0
- data/html/js/edit_area/reg_syntax/coldfusion.js +119 -0
- data/html/js/edit_area/reg_syntax/cpp.js +65 -0
- data/html/js/edit_area/reg_syntax/css.js +84 -0
- data/html/js/edit_area/reg_syntax/html.js +50 -0
- data/html/js/edit_area/reg_syntax/js.js +93 -0
- data/html/js/edit_area/reg_syntax/pas.js +82 -0
- data/html/js/edit_area/reg_syntax/perl.js +88 -0
- data/html/js/edit_area/reg_syntax/php.js +156 -0
- data/html/js/edit_area/reg_syntax/python.js +144 -0
- data/html/js/edit_area/reg_syntax/robotstxt.js +24 -0
- data/html/js/edit_area/reg_syntax/ruby.js +67 -0
- data/html/js/edit_area/reg_syntax/sql.js +55 -0
- data/html/js/edit_area/reg_syntax/tsql.js +87 -0
- data/html/js/edit_area/reg_syntax/vb.js +52 -0
- data/html/js/edit_area/reg_syntax/xml.js +56 -0
- data/html/js/edit_area/regexp.js +135 -0
- data/html/js/edit_area/resize_area.js +82 -0
- data/html/js/edit_area/search_replace.js +174 -0
- data/html/js/edit_area/template.html +99 -0
- data/html/js/json-broker-client.js +61 -0
- data/html/js/page-manager.js +93 -0
- data/html/js/prototype.js +4184 -0
- data/html/js/result-page.js +707 -0
- data/html/js/rt-setting-page.js +122 -0
- data/html/js/sidebar.js +246 -0
- data/html/js/templates.js +208 -0
- data/html/js/utils.js +716 -0
- data/html/js/uuid.js +103 -0
- data/html/swf/chart.swf +0 -0
- data/lib/jiji/agent/agent.rb +93 -0
- data/lib/jiji/agent/agent_manager.rb +133 -0
- data/lib/jiji/agent/agent_registry.rb +248 -0
- data/lib/jiji/agent/permitter.rb +128 -0
- data/lib/jiji/agent/util.rb +16 -0
- data/lib/jiji/collector.rb +219 -0
- data/lib/jiji/command.rb +129 -0
- data/lib/jiji/configuration.rb +80 -0
- data/lib/jiji/dao/rate_dao.rb +149 -0
- data/lib/jiji/dao/timed_data_dao.rb +334 -0
- data/lib/jiji/dao/trade_result_dao.rb +128 -0
- data/lib/jiji/error.rb +33 -0
- data/lib/jiji/models.rb +169 -0
- data/lib/jiji/observer.rb +105 -0
- data/lib/jiji/operator.rb +405 -0
- data/lib/jiji/output.rb +165 -0
- data/lib/jiji/process.rb +182 -0
- data/lib/jiji/process_manager.rb +189 -0
- data/lib/jiji/registry.rb +255 -0
- data/lib/jiji/server.rb +115 -0
- data/lib/jiji/service/agent_service.rb +131 -0
- data/lib/jiji/service/hello_service.rb +10 -0
- data/lib/jiji/service/output_service.rb +58 -0
- data/lib/jiji/service/process_service.rb +78 -0
- data/lib/jiji/service/rate_service.rb +33 -0
- data/lib/jiji/service/system_service.rb +14 -0
- data/lib/jiji/service/trade_result_service.rb +32 -0
- data/lib/jiji/single_click_client.rb +95 -0
- data/lib/jiji/util/block_to_session.rb +70 -0
- data/lib/jiji/util/cache.rb +79 -0
- data/lib/jiji/util/csv_append_support.rb +15 -0
- data/lib/jiji/util/file_lock.rb +86 -0
- data/lib/jiji/util/fix_yaml_bug.rb +11 -0
- data/lib/jiji/util/iterator.rb +70 -0
- data/lib/jiji/util/json_broker.rb +53 -0
- data/lib/jiji/util/json_rpc_requestor.rb +30 -0
- data/lib/jiji/util/synchronize_interceptor.rb +41 -0
- data/lib/jiji/util/thread_use_generator.rb +52 -0
- data/lib/jiji/util/util.rb +179 -0
- data/swf/build.xml +23 -0
- data/swf/chart/FxChart-config.xml +9 -0
- data/swf/chart/FxChart.mxml +17 -0
- data/swf/chart/fx/chart/Chart.as +155 -0
- data/swf/chart/fx/chart/ctrl/AutoUpdate.as +96 -0
- data/swf/chart/fx/chart/ctrl/Controller.as +258 -0
- data/swf/chart/fx/chart/ctrl/Event.as +75 -0
- data/swf/chart/fx/chart/model/Model.as +226 -0
- data/swf/chart/fx/chart/model/TimedData.as +40 -0
- data/swf/chart/fx/chart/ui/AbstractChartUI.as +59 -0
- data/swf/chart/fx/chart/ui/AbstractDrawChartUI.as +63 -0
- data/swf/chart/fx/chart/ui/Constants.as +233 -0
- data/swf/chart/fx/chart/ui/InformationWindow.as +224 -0
- data/swf/chart/fx/chart/ui/LayerManager.as +95 -0
- data/swf/chart/fx/chart/ui/Loading.as +32 -0
- data/swf/chart/fx/chart/ui/Pointer.as +59 -0
- data/swf/chart/fx/chart/ui/RangeInfoWindow.as +84 -0
- data/swf/chart/fx/chart/ui/RenderingContext.as +54 -0
- data/swf/chart/fx/chart/ui/ScaleSelector.as +95 -0
- data/swf/chart/fx/chart/ui/Scroll.as +240 -0
- data/swf/chart/fx/chart/ui/ScrollBar.as +378 -0
- data/swf/chart/fx/chart/ui/Stage.as +97 -0
- data/swf/chart/fx/chart/ui/TradeDetailWindow.as +146 -0
- data/swf/chart/fx/chart/ui/TradeResult.as +334 -0
- data/swf/chart/fx/chart/ui/Window.as +96 -0
- data/swf/chart/fx/chart/ui/candle/Axis.as +112 -0
- data/swf/chart/fx/chart/ui/candle/Candle.as +79 -0
- data/swf/chart/fx/chart/ui/candle/CandleChart.as +81 -0
- data/swf/chart/fx/chart/ui/graph/Graph.as +198 -0
- data/swf/chart/fx/chart/ui/graph/GraphManager.as +177 -0
- data/swf/chart/fx/chart/ui/resource/buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/cursor_hand.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/diff_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_buy_3.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/down_sell_3.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/draw_buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/draw_sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/end_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/fixed.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/loading.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/max_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/min_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_handle.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_handle_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_handle_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_left.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_left_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_left_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_right.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_right_a.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_bar_right_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_handle.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_info_handle.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_d.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_down.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_g.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_left_button_up.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_outer.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_outer_left.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_outer_right.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_d.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_down.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_g.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_o.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_right_button_up.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_slider_left.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/scroll_slider_right.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/start_label.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/stripe.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/stripe_b.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/stripe_r.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/unfixed.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_buy_3.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell_1.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell_2.gif +0 -0
- data/swf/chart/fx/chart/ui/resource/up_sell_3.gif +0 -0
- data/swf/chart/fx/net/StubFactory.as +113 -0
- data/swf/chart/fx/util/ListenerSupport.as +55 -0
- data/swf/chart/fx/util/PositionManager.as +94 -0
- data/swf/chart/fx/util/ScaleFormatter.as +156 -0
- data/swf/chart/fx/util/Util.as +61 -0
- data/swf/chart/log.as +40 -0
- data/swf/lib/corelib.swc +0 -0
- data/test/BackCollectorTest/basic/2008-08-04/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-04/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-04/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-05/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-05/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-05/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-06/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-06/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-06/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-07/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-07/USDJPY.csv +5 -0
- data/test/BackCollectorTest/basic/2008-08-07/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-05.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/basic/AUDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-05.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/basic/USDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-05.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/basic/ZARJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-04/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-04/USDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-04/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-06/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-06/USDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-06/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-07/AUDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-07/USDJPY.csv +5 -0
- data/test/BackCollectorTest/lack/2008-08-07/ZARJPY.csv +5 -0
- data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/lack/AUDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/lack/USDJPY/raw/2008-08-07.csv +5 -0
- data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-04.csv +5 -0
- data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-06.csv +5 -0
- data/test/BackCollectorTest/lack/ZARJPY/raw/2008-08-07.csv +5 -0
- data/test/ProcessManagerTest/agents/moving_average.rb +95 -0
- data/test/ProcessManagerTest/conf/configuration.yaml +19 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-21.csv +5853 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-22.csv +5821 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-23.csv +5921 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-24.csv +5956 -0
- data/test/ProcessManagerTest/rate_datas/EURJPY/raw/2008-08-25.csv +5796 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-21.csv +5853 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-22.csv +5821 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-23.csv +5921 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-24.csv +5956 -0
- data/test/ProcessManagerTest/rate_datas/USDJPY/raw/2008-08-25.csv +5796 -0
- data/test/all_tests.rb +26 -0
- data/test/service/all_service_tests.rb +10 -0
- data/test/service/test_AgentService.rb +185 -0
- data/test/service/test_OutputService.rb +33 -0
- data/test/service/test_RateService.rb +56 -0
- data/test/test_AgentManager.rb +307 -0
- data/test/test_AgentRegistory.rb +566 -0
- data/test/test_BackTestCollector.rb +281 -0
- data/test/test_BlockToSession.rb +74 -0
- data/test/test_CSV.rb +85 -0
- data/test/test_Collector.rb +246 -0
- data/test/test_Configuration.rb +61 -0
- data/test/test_Configuration_a.yaml +6 -0
- data/test/test_Operator.rb +501 -0
- data/test/test_Output.rb +169 -0
- data/test/test_Output_registry.rb +49 -0
- data/test/test_PeriodicallyAgent.rb +180 -0
- data/test/test_Permitter.rb +217 -0
- data/test/test_Process.rb +186 -0
- data/test/test_ProcessManager.rb +312 -0
- data/test/test_RateDao.rb +697 -0
- data/test/test_SingleClickClient.rb +115 -0
- data/test/test_SynchronizeInterceptor.rb +75 -0
- data/test/test_TradeResultDao.rb +487 -0
- data/test/test_configuration.yaml +16 -0
- data/test/testutils.rb +37 -0
- metadata +750 -0
@@ -0,0 +1,80 @@
|
|
1
|
+
|
2
|
+
require 'jiji/util/fix_yaml_bug'
|
3
|
+
require 'jiji/util/file_lock'
|
4
|
+
|
5
|
+
module JIJI
|
6
|
+
|
7
|
+
#
|
8
|
+
#==設定値
|
9
|
+
#
|
10
|
+
class Configuration
|
11
|
+
|
12
|
+
#コンストラクタ
|
13
|
+
#configuration_file:: 設定ファイルのパス
|
14
|
+
def initialize( configuration_file=nil )
|
15
|
+
if configuration_file && File.exist?( configuration_file )
|
16
|
+
FileLock.new( configuration_file ).readlock {|f|
|
17
|
+
tmp = YAML.load f
|
18
|
+
@conf = key_to_sym( tmp )
|
19
|
+
}
|
20
|
+
else
|
21
|
+
@conf = {}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
#値を取得する。
|
26
|
+
#names:: 値を示すパス 例) [:foo, :var]
|
27
|
+
#default:: 値が存在しない場合の初期値
|
28
|
+
#return:: 値
|
29
|
+
def get( names, default )
|
30
|
+
v = names.inject(@conf) {|conf,i|
|
31
|
+
if conf.kind_of?(Hash)
|
32
|
+
conf[i]
|
33
|
+
else
|
34
|
+
break default
|
35
|
+
end
|
36
|
+
}
|
37
|
+
v == nil ? default : v
|
38
|
+
end
|
39
|
+
|
40
|
+
#値を設定する。
|
41
|
+
#※設定した値は元のファイルには反映されない。プログラムを終了すると失われる。
|
42
|
+
#names:: 値を示すパス 例) [:foo, :var]
|
43
|
+
#value:: 値
|
44
|
+
def set( names, value=nil)
|
45
|
+
key = names.pop
|
46
|
+
names.inject(@conf) {|conf, i|
|
47
|
+
if conf[i].kind_of?(Hash)
|
48
|
+
conf[i]
|
49
|
+
elsif conf[i] == nil
|
50
|
+
conf[i] = {}
|
51
|
+
else
|
52
|
+
raise "illegal key."
|
53
|
+
end
|
54
|
+
}[key] = value
|
55
|
+
end
|
56
|
+
|
57
|
+
#値が存在するか評価する。
|
58
|
+
#names:: 値を示すパス 例) [:foo, :var]
|
59
|
+
#return:: 値があればtrue
|
60
|
+
def key?( names )
|
61
|
+
v = names.inject(@conf) {|conf,i|
|
62
|
+
if conf.kind_of?(Hash)
|
63
|
+
conf[i]
|
64
|
+
else
|
65
|
+
break nil
|
66
|
+
end
|
67
|
+
}
|
68
|
+
v != nil
|
69
|
+
end
|
70
|
+
|
71
|
+
private
|
72
|
+
def key_to_sym( map )
|
73
|
+
map.inject({}) {|r,e|
|
74
|
+
v = e[1].kind_of?(Hash) ? key_to_sym( e[1] ) : e[1]
|
75
|
+
r.store(e[0].to_sym, v)
|
76
|
+
r
|
77
|
+
}
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,149 @@
|
|
1
|
+
|
2
|
+
require 'thread'
|
3
|
+
require 'jiji/util/csv_append_support'
|
4
|
+
require 'jiji/util/util'
|
5
|
+
require 'jiji/models'
|
6
|
+
require 'jiji/dao/timed_data_dao'
|
7
|
+
|
8
|
+
module JIJI
|
9
|
+
module Dao
|
10
|
+
|
11
|
+
# レートDAO
|
12
|
+
class RateDao
|
13
|
+
|
14
|
+
def initialize( data_dir, scales=[] )
|
15
|
+
@data_dir = data_dir
|
16
|
+
@scales = scales
|
17
|
+
@daos = {}
|
18
|
+
@mutex = Mutex.new
|
19
|
+
end
|
20
|
+
|
21
|
+
# 所定の期間のレートデータを得る。
|
22
|
+
def each( scale=:raw, pair=:USDJPY, start_date=nil, end_date=nil )
|
23
|
+
dao( pair ).each_data( scale, start_date, end_date ) {|row,time|
|
24
|
+
yield row
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
# 所定の期間のすべての通貨ペアのレートデータを得る。
|
29
|
+
def each_all_pair_rates( scale=:raw, start_date=nil, end_date=nil, &block )
|
30
|
+
pairs = list_pairs
|
31
|
+
its = nil
|
32
|
+
begin
|
33
|
+
its = pairs.map {|p|
|
34
|
+
dao(p).each_data( scale,start_date,end_date )
|
35
|
+
}
|
36
|
+
_each_all_pair_rates( pairs, its, &block )
|
37
|
+
ensure
|
38
|
+
its.each {|i| i.close } if its
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# 次のレートを追加する。
|
43
|
+
def next_rates( rates )
|
44
|
+
rates.each_pair {|pair,v|
|
45
|
+
dao(pair) << v
|
46
|
+
}
|
47
|
+
end
|
48
|
+
|
49
|
+
# ペアに対応するdaoを取得する
|
50
|
+
def dao(pair)
|
51
|
+
@mutex.synchronize {
|
52
|
+
return @daos[pair] if @daos.key? pair
|
53
|
+
|
54
|
+
dir = "#{@data_dir}/#{pair.to_s}"
|
55
|
+
FileUtils.mkdir_p dir unless File.exists? dir
|
56
|
+
|
57
|
+
aggregators = @scales.map {|s| RatesAggregator.new(s) }
|
58
|
+
aggregators << RawRatesAggregator.new
|
59
|
+
|
60
|
+
@daos[pair] = TimedDataDao.new( dir, aggregators )
|
61
|
+
@daos[pair]
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
def list_pairs
|
66
|
+
list = []
|
67
|
+
Dir.glob( "#{@data_dir}/*" ) {|d|
|
68
|
+
next unless File.directory? d
|
69
|
+
next unless d =~ /\/([A-Z]+)$/
|
70
|
+
list << $1
|
71
|
+
}
|
72
|
+
list
|
73
|
+
end
|
74
|
+
|
75
|
+
private
|
76
|
+
def _each_all_pair_rates( pairs, its )
|
77
|
+
buff = PairBuffer.new
|
78
|
+
exist_next = true
|
79
|
+
while( exist_next )
|
80
|
+
exist_next = false
|
81
|
+
its.each_index {|index|
|
82
|
+
it = its[index]
|
83
|
+
if ( it.next? )
|
84
|
+
# 末尾のデータはDAOで使うための日時指定で不要なので取り除く
|
85
|
+
item = it.next
|
86
|
+
item.pop
|
87
|
+
buff.add( pairs[index], item )
|
88
|
+
exist_next = true
|
89
|
+
else
|
90
|
+
exist_next = exist_next || false
|
91
|
+
end
|
92
|
+
}
|
93
|
+
yield buff.next if buff.next?
|
94
|
+
end
|
95
|
+
yield buff.next while buff.next?
|
96
|
+
end
|
97
|
+
|
98
|
+
|
99
|
+
class RatesAggregator < JIJI::Dao::AbstractAggregator
|
100
|
+
def initialize( scale )
|
101
|
+
super
|
102
|
+
end
|
103
|
+
def aggregate( timed_data )
|
104
|
+
unless @rate
|
105
|
+
@rate = PeriodicallyRate.new
|
106
|
+
@rate.start_time = timed_data.time
|
107
|
+
end
|
108
|
+
@rate << timed_data
|
109
|
+
end
|
110
|
+
def aggregated
|
111
|
+
@rate.end_time = @end
|
112
|
+
vs = @rate
|
113
|
+
@rate = PeriodicallyRate.new
|
114
|
+
@rate.start_time = @end
|
115
|
+
return vs
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
class RawRatesAggregator < JIJI::Dao::Aggregator
|
120
|
+
def initialize
|
121
|
+
super( "raw" )
|
122
|
+
end
|
123
|
+
def next( timed_data )
|
124
|
+
yield timed_data
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
class PairBuffer
|
129
|
+
def initialize
|
130
|
+
@buff = {}
|
131
|
+
end
|
132
|
+
def add( pair, data )
|
133
|
+
time = data.last.to_i
|
134
|
+
@buff[time] = {} unless @buff[time]
|
135
|
+
@buff[time][pair.to_sym] = data
|
136
|
+
end
|
137
|
+
def next?
|
138
|
+
@buff.length > 0
|
139
|
+
end
|
140
|
+
def next
|
141
|
+
keys = @buff.keys.sort!
|
142
|
+
@buff.delete keys[0]
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
@@ -0,0 +1,334 @@
|
|
1
|
+
require 'jiji/error'
|
2
|
+
require 'date'
|
3
|
+
require 'jiji/util/csv_append_support'
|
4
|
+
require 'jiji/util/file_lock'
|
5
|
+
require 'jiji/util/iterator'
|
6
|
+
|
7
|
+
module JIJI
|
8
|
+
module Dao
|
9
|
+
|
10
|
+
# 時間を持つデータ
|
11
|
+
module TimedData
|
12
|
+
def values
|
13
|
+
[]
|
14
|
+
end
|
15
|
+
attr :time, true
|
16
|
+
end
|
17
|
+
|
18
|
+
BasicTimedData = Struct.new( :values, :time )
|
19
|
+
|
20
|
+
# 時間を持つデータをCSVで記録するためのDao
|
21
|
+
# データの記録、
|
22
|
+
# 一定期間のデータの集約結果の記録、
|
23
|
+
# 一定期間のデータの読み込み、
|
24
|
+
# をサポート。
|
25
|
+
#
|
26
|
+
class TimedDataDao
|
27
|
+
|
28
|
+
DATE_FORMAT = "%Y-%m-%d"
|
29
|
+
MONTHLY_DATE_FORMAT = "%Y-%m"
|
30
|
+
|
31
|
+
def initialize( root_dir, aggregator=[] )
|
32
|
+
@root_dir = root_dir
|
33
|
+
@aggregator = aggregator
|
34
|
+
end
|
35
|
+
|
36
|
+
# 指定期間のデータを読み込む
|
37
|
+
def each_data( scale=:raw, start_time=nil, end_time=nil, &block )
|
38
|
+
sd = start_time || first_day( scale )
|
39
|
+
ed = end_time || last_day( scale )
|
40
|
+
|
41
|
+
it = ( !sd || !ed ) \
|
42
|
+
? EmptyIterator.new \
|
43
|
+
: TimedDataIterator.new( scale, sd, ed, self )
|
44
|
+
if block_given?
|
45
|
+
it.each {|row|
|
46
|
+
time = row.pop.to_i
|
47
|
+
block.call( row, time )
|
48
|
+
}
|
49
|
+
else
|
50
|
+
return it
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
# データを強制的に書き込む
|
55
|
+
# バックテストで取引が完了し場合に使用し、結果を表性的に書き出す。
|
56
|
+
def flush( time )
|
57
|
+
@aggregator.each {|ag|
|
58
|
+
ag_dir = ag_dir(ag)
|
59
|
+
ag.flush( time ) {|data|
|
60
|
+
out( ag, ag_dir, data )
|
61
|
+
}
|
62
|
+
}
|
63
|
+
end
|
64
|
+
|
65
|
+
# データを追加する
|
66
|
+
def <<(timed_data)
|
67
|
+
@aggregator.each {|ag|
|
68
|
+
ag_dir = ag_dir(ag)
|
69
|
+
ag.next( timed_data ) {|data|
|
70
|
+
out( ag, ag_dir, data )
|
71
|
+
}
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
# 利用可能なデータ一覧を得る
|
76
|
+
def list_data_files( scale, pattern="*" )
|
77
|
+
Dir.glob( "#{@root_dir}/#{scale.to_s}/#{pattern}.csv" ).map{|d| File.basename(d) }.sort!
|
78
|
+
end
|
79
|
+
# 利用可能な最後のデータ
|
80
|
+
def last_day( scale )
|
81
|
+
l = list_data_files( scale )
|
82
|
+
return nil if l.empty?
|
83
|
+
if TimedDataDao.dairy?(scale)
|
84
|
+
to_time( l.last[0..-5], true ) + 24*60*60
|
85
|
+
else
|
86
|
+
to_time( l.last[0..-5], false ) + 24*60*60*31
|
87
|
+
end
|
88
|
+
end
|
89
|
+
# 利用可能な最初のデータ
|
90
|
+
def first_day( scale )
|
91
|
+
l = list_data_files( scale )
|
92
|
+
l.empty? ? nil : to_time( l.first[0..-5], TimedDataDao.dairy?(scale) )
|
93
|
+
end
|
94
|
+
# 利用可能な最後のデータ
|
95
|
+
def last_time( scale )
|
96
|
+
l = list_data_files( scale )
|
97
|
+
return nil if l.empty?
|
98
|
+
date = nil
|
99
|
+
it = each_file_data( "#{@root_dir}/#{scale}/#{l.last}" )
|
100
|
+
it.each { |row|
|
101
|
+
date = row.last
|
102
|
+
}
|
103
|
+
date.to_i
|
104
|
+
end
|
105
|
+
# 利用可能な最初のデータ
|
106
|
+
def first_time( scale )
|
107
|
+
l = list_data_files( scale )
|
108
|
+
return nil if l.empty?
|
109
|
+
date = nil
|
110
|
+
it = each_file_data( "#{@root_dir}/#{scale}/#{l.first}" )
|
111
|
+
it.each { |row|
|
112
|
+
date = row.last
|
113
|
+
break
|
114
|
+
}
|
115
|
+
date.to_i
|
116
|
+
end
|
117
|
+
# 文字列を時刻に変換する
|
118
|
+
def to_time( str, dairy=true )
|
119
|
+
d = DateTime.strptime(str, dairy ? DATE_FORMAT : MONTHLY_DATE_FORMAT)
|
120
|
+
Time.local( d.year, d.month, d.day )
|
121
|
+
end
|
122
|
+
# 時刻を日を示す文字列に変換する
|
123
|
+
def to_date_str( time, dairy=true )
|
124
|
+
time.strftime( dairy ? DATE_FORMAT : MONTHLY_DATE_FORMAT)
|
125
|
+
end
|
126
|
+
def self.dairy?(scale)
|
127
|
+
scale.to_s =~ /^(raw|\d+[smh])$/
|
128
|
+
end
|
129
|
+
|
130
|
+
# 特定の日のデータを列挙する
|
131
|
+
def each_dairy_data( scale, date, start_date=nil, end_date=nil)
|
132
|
+
file = "#{@root_dir}/#{scale}/#{to_date_str(date, TimedDataDao.dairy?(scale))}.csv"
|
133
|
+
each_file_data( file, start_date, end_date )
|
134
|
+
end
|
135
|
+
|
136
|
+
attr_reader :aggregator
|
137
|
+
|
138
|
+
private
|
139
|
+
|
140
|
+
# データを保存する
|
141
|
+
def out( ag, ag_dir, data )
|
142
|
+
date = to_date_str( data.time, TimedDataDao.dairy?(ag.scale) )
|
143
|
+
file = "#{ag_dir}/#{date}.csv"
|
144
|
+
CSV.open( file, 'a' ) {|w|
|
145
|
+
w << ( data.values.map{|i|i.to_s} << data.time.to_i )
|
146
|
+
}
|
147
|
+
end
|
148
|
+
|
149
|
+
# アグリゲーターが使用するデータ保存先ディレクトリを作成する。
|
150
|
+
def ag_dir( ag )
|
151
|
+
dir = "#{@root_dir}/#{ag.scale}"
|
152
|
+
FileUtils.mkdir_p dir unless File.exist? dir
|
153
|
+
return dir
|
154
|
+
end
|
155
|
+
|
156
|
+
# ファイルのデータを列挙する
|
157
|
+
def each_file_data( file, start_date=nil, end_date=nil)
|
158
|
+
return EmptyIterator.new unless File.exist? file
|
159
|
+
it = CSVIterator.new( CSV.open( file, 'r' ) )
|
160
|
+
return Filter.new( it ) {|row|
|
161
|
+
time = row.last.to_i
|
162
|
+
if start_date && time < start_date.to_i
|
163
|
+
:next
|
164
|
+
elsif end_date && time > end_date.to_i
|
165
|
+
:break
|
166
|
+
else
|
167
|
+
:true
|
168
|
+
end
|
169
|
+
}
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
# CSVReaderをIteratorにする。
|
174
|
+
class CSVIterator < Iterator
|
175
|
+
def initialize( reader )
|
176
|
+
super()
|
177
|
+
@reader = reader
|
178
|
+
@item = @reader.shift
|
179
|
+
end
|
180
|
+
def next?
|
181
|
+
!@item.empty?
|
182
|
+
end
|
183
|
+
def next
|
184
|
+
begin
|
185
|
+
@item
|
186
|
+
ensure
|
187
|
+
@item = @reader.shift
|
188
|
+
end
|
189
|
+
end
|
190
|
+
def close
|
191
|
+
@reader.close
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
# 複数のCSVファイルのデータを順番に読み込む。
|
196
|
+
class TimedDataIterator < Iterator
|
197
|
+
def initialize( scale, start_time, end_time, dao )
|
198
|
+
super()
|
199
|
+
@dao = dao
|
200
|
+
@start_time = start_time
|
201
|
+
@end_time = end_time
|
202
|
+
@scale = scale
|
203
|
+
@current = start_time
|
204
|
+
@current_date = Date.new( @current.year, @current.mon, \
|
205
|
+
TimedDataDao.dairy?(@scale) ? @current.day : 1 )
|
206
|
+
next_iterator
|
207
|
+
end
|
208
|
+
def next?
|
209
|
+
@it && @it.next?
|
210
|
+
end
|
211
|
+
def next
|
212
|
+
begin
|
213
|
+
@it.next
|
214
|
+
ensure
|
215
|
+
next_iterator unless @it.next?
|
216
|
+
end
|
217
|
+
end
|
218
|
+
def close
|
219
|
+
@it.close if @it
|
220
|
+
end
|
221
|
+
def next_iterator
|
222
|
+
@it.close if @it
|
223
|
+
@it = nil
|
224
|
+
while ( @current.to_f <= @end_time.to_f )
|
225
|
+
begin
|
226
|
+
it = @dao.each_dairy_data( @scale, @current, @start_time, @end_time)
|
227
|
+
if it != nil && it.next?
|
228
|
+
@it = it
|
229
|
+
return
|
230
|
+
else
|
231
|
+
it.close
|
232
|
+
end
|
233
|
+
ensure
|
234
|
+
@current_date = TimedDataDao.dairy?(@scale) ? @current_date+1 : @current_date >> 1
|
235
|
+
@current = Time.local(@current_date.year, @current_date.mon, @current_date.day)
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
end
|
240
|
+
|
241
|
+
# 一定期間のデータを集約するクラス
|
242
|
+
class Aggregator
|
243
|
+
def initialize( scale )
|
244
|
+
@scale = scale
|
245
|
+
end
|
246
|
+
# データを受け取り、集約したデータがある場合、それを引数としてブロックを実行する。
|
247
|
+
def next( timed_data )
|
248
|
+
end
|
249
|
+
# 集約したデータがある場合、それを引数としてブロックを実行する。
|
250
|
+
def flush( time )
|
251
|
+
end
|
252
|
+
attr_reader :scale
|
253
|
+
end
|
254
|
+
|
255
|
+
# 集約を行なわないAggregator
|
256
|
+
class RawAggregator < Aggregator
|
257
|
+
def initialize
|
258
|
+
super("raw")
|
259
|
+
end
|
260
|
+
def next( timed_data )
|
261
|
+
yield timed_data
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
# 一定期間のデータを集約するクラス
|
266
|
+
class AbstractAggregator < Aggregator
|
267
|
+
def initialize( scale )
|
268
|
+
super
|
269
|
+
@period = JIJI::Util.parse_scale(scale)
|
270
|
+
@next = nil
|
271
|
+
end
|
272
|
+
# データを受け取り、集約したデータがある場合、それを引数としてブロックを実行する。
|
273
|
+
def next( timed_data )
|
274
|
+
now = timed_data.time
|
275
|
+
unless @next
|
276
|
+
@next = Time.at(((now.to_i / @period)+1) * @period )
|
277
|
+
@start = Time.at(@next.to_i-@period)
|
278
|
+
end
|
279
|
+
aggregate( timed_data )
|
280
|
+
if now >= @next
|
281
|
+
@end = @next
|
282
|
+
yield aggregated
|
283
|
+
@start = @next
|
284
|
+
@end = nil
|
285
|
+
@next += @period while @next <= now
|
286
|
+
end
|
287
|
+
end
|
288
|
+
def flush( time )
|
289
|
+
@end = time
|
290
|
+
yield aggregated
|
291
|
+
@start = @next
|
292
|
+
@end = nil
|
293
|
+
@next += @period while @next <= time
|
294
|
+
end
|
295
|
+
def aggregate( timed_data )
|
296
|
+
end
|
297
|
+
def aggregated
|
298
|
+
end
|
299
|
+
def next_date
|
300
|
+
@next
|
301
|
+
end
|
302
|
+
attr_reader :start
|
303
|
+
end
|
304
|
+
|
305
|
+
# 平均を取るAggregator
|
306
|
+
class AvgAggregator < AbstractAggregator
|
307
|
+
def aggregate( timed_data )
|
308
|
+
@values = [] unless @values
|
309
|
+
timed_data.values.each_index {|i|
|
310
|
+
@values[i] = [] unless @values[i]
|
311
|
+
@values[i] << timed_data.values[i]
|
312
|
+
}
|
313
|
+
end
|
314
|
+
def aggregated
|
315
|
+
avgs = @values.map{|vs|
|
316
|
+
vs.inject(0){|t,v| t+=v }/vs.length
|
317
|
+
}
|
318
|
+
@values = []
|
319
|
+
BasicTimedData.new(avgs + [@start.to_i, @end.to_i], @end)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
# 最後の値を返すAggregator
|
324
|
+
class LastAggregator < AbstractAggregator
|
325
|
+
def aggregate( timed_data )
|
326
|
+
@values = timed_data.values
|
327
|
+
end
|
328
|
+
def aggregated
|
329
|
+
BasicTimedData.new( @values + [@start.to_i, @end.to_i], @end)
|
330
|
+
end
|
331
|
+
end
|
332
|
+
|
333
|
+
end
|
334
|
+
end
|