Пример #1
0
        public UserJsonParameters_Loader(string json_full_filename)
        //load_defaults_from_kadina_json
        {
            string log_prefix = "TradeLink.AppKit::UserJsonParameters::load_defaults_from_kadina_json(): ";

            // check if kadina.json file exist
            if (json_full_filename != "")
            {
                json_file_exist = System.IO.File.Exists(json_full_filename);

                //debug(log_prefix + "checking if json_file_exist = " + json_file_exist);
                if (json_file_exist)
                {
                    // read file
                    //debug(log_prefix + " reading json config file");
                    json_as_str = System.IO.File.ReadAllText(@json_full_filename);
                    //debug(log_prefix + " read " + json_as_str.Length + " bytes");

                    // parse file (todo: add error check)
                    //debug(log_prefix + " parsing json");
                    //var deserializedProduct = JsonConvert.DeserializeObject<user_json_parameters>(json_as_str);
                    user_json_parameters = JsonConvert.DeserializeObject <UserJsonParameters>(json_as_str);
                }
            }
        }
        public kadinamain()
        {
            //TrackEnabled = Util.TrackUsage();
            //Program = PROGRAM;



            string[] args = MyGlobals.args;

            bool show_help = false;
            int repeat = 1;

            var p = new OptionSet() {
            { "k|kadina-config=", "response json configuration file",
              v => kadina_config = v },
            { "r|response-config=", "response json configuration file",
              v => response_config = v },
            { "m|kadina-mode=", "use --kadina-mode=script to run without gui and close kadina after resutls",
              v => kadina_mode = v },
            { "z|zrepeat=", 
                "the number of {TIMES} to repeat the greeting.\n" + 
                    "this must be an integer.",
              (int v) => repeat = v },
            { "v", "increase debug message verbosity",
              v => { if (v != null) ++verbosity; } },
            { "h|help",  "show this message and exit", 
              v => show_help = v != null },
        };

            List<string> extra;
            try
            {
                extra = p.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("greet: ");
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `greet --help' for more information.");
                return;
            }

            if (show_help)
            {
                ShowHelp(p);
                return;
            }







            _dps = "N" + _dp;
            SimBroker.UseBidAskFills = Properties.Settings.Default.UseBidAskFills;
            InitializeComponent();
            Text += " " + Util.TLVersion();
            initgrids();
            debugControl1.NewCreateTicketEvent += new DebugDelegate(debugControl1_NewCreateTicketEvent);
            sizetabs();
            restorerecentfiles();
            restorerecentlibs();
            restoreskins();
            FormClosing += new FormClosingEventHandler(kadinamain_FormClosing);
            Resize += new EventHandler(kadinamain_Resize);
            bw.DoWork += new DoWorkEventHandler(Play);
            bw.WorkerReportsProgress = false;
            bw.WorkerSupportsCancellation = true;
            bw.RunWorkerCompleted += new RunWorkerCompletedEventHandler(PlayComplete);

            bw2.DoWork += new DoWorkEventHandler(bw2_DoWork);
            bw2.RunWorkerAsync();
            debug(Util.TLSIdentity());
            debug(RunTracker.CountNewGetPrettyRuns(PROGRAM, Util.PROGRAM));
            // grid errors
            dg.DataError += new DataGridViewDataErrorEventHandler(dg_DataError);
            ig.DataError += new DataGridViewDataErrorEventHandler(ig_DataError);
            fg.DataError += new DataGridViewDataErrorEventHandler(fg_DataError);
            og.DataError += new DataGridViewDataErrorEventHandler(og_DataError);
            pg.DataError += new DataGridViewDataErrorEventHandler(pg_DataError);

            statusStrip1.BackColor = Color.White;
            statusStrip2.BackColor = Color.White;

            ////////////////////////////////////////////////////////////
            // dimon: stick this line into the end of "public kadinamain()" 
            // it will load our defaults from external json file
            user_json_parameters_loader = new UserJsonParameters_Loader(kadina_config);
            user_json_parameters = user_json_parameters_loader.user_json_parameters;
            c.user_json_parameters = user_json_parameters;

            // pass some params to ChartControl() here
            if (user_json_parameters_loader.json_file_exist)
            {
                foreach (string tick in user_json_parameters.tick_files)
                    loadfile(tick);

                if (user_json_parameters.response_dll.Length > 0)
                    loadfile(user_json_parameters.response_dll);

                // only if response dll & class were set we can analyze/do play
                if (user_json_parameters.response_class.Length > 0)
                {
                    // load response class herer
                    switch (user_json_parameters.play_to)
                    {
                        case "one_sec":
                            playto(PlayTo.OneSec);
                            break;
                        case "thirty_sec":
                            playto(PlayTo.ThirtySec);
                            break;
                        case "one_min":
                            playto(PlayTo.OneMin);
                            break;
                        case "five_min":
                            playto(PlayTo.FiveMin);
                            break;
                        case "ten_min":
                            playto(PlayTo.TenMin);
                            break;
                        case "half_hour":
                            playto(PlayTo.HalfHour);
                            break;
                        case "hour":
                            playto(PlayTo.Hour);
                            break;
                        case "two_hours":
                            playto(PlayTo.TwoHour);
                            break;
                        case "four_hours":
                            playto(PlayTo.FourHour);
                            break;
                        case "custom":
                            playto(PlayTo.Custom);
                            break;
                        case "end":
                            playto(PlayTo.End);
                            break;
                    }
                }
            }
        }
Пример #3
0
        public UserJsonParameters_Loader(string json_full_filename)
        //load_defaults_from_kadina_json
        {
            string log_prefix = "TradeLink.AppKit::UserJsonParameters::load_defaults_from_kadina_json(): ";

            // check if kadina.json file exist
            if (json_full_filename != "")
            {
                json_file_exist = System.IO.File.Exists(json_full_filename);

                //debug(log_prefix + "checking if json_file_exist = " + json_file_exist);
                if (json_file_exist)
                {
                    // read file
                    //debug(log_prefix + " reading json config file");
                    json_as_str = System.IO.File.ReadAllText(@json_full_filename);
                    //debug(log_prefix + " read " + json_as_str.Length + " bytes");

                    // parse file (todo: add error check)
                    //debug(log_prefix + " parsing json");
                    //var deserializedProduct = JsonConvert.DeserializeObject<user_json_parameters>(json_as_str);
                    user_json_parameters = JsonConvert.DeserializeObject<UserJsonParameters>(json_as_str);
                }
            }
        }