Beispiel #1
0
        private VM_SciChartOsciloscope(VM_UC_Main.VM_UC_Main uc_main, int NodeId = 127)
        {
            //Create an instance of a ini file parser
            var parser = new FileIniDataParser();

            string pathString = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Redler";

            if (!System.IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Redler\\Charts\\"))
            {
                // Create the subfolder. You can verify in File Explorer that you have this
                // structure in the C: drive.
                //    Local Disk (C:)
                //        Top-Level Folder
                //            SubFolder
                System.IO.Directory.CreateDirectory(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\Redler\\Charts\\");
            }
            IniData data;

            try
            {
                if (!System.IO.File.Exists(pathString + "\\MotorController.ini"))
                {
                    // Create the subfolder. You can verify in File Explorer that you have this
                    // structure in the C: drive.
                    //    Local Disk (C:)
                    //        Top-Level Folder
                    //            SubFolder
                    System.IO.Directory.CreateDirectory(pathString);
                    StreamWriter sw = System.IO.File.CreateText(pathString + "\\MotorController.ini");
                    pathString += "\\MotorController.ini";
                    // This load the INI file, reads the data contained in the fail,
                    // and parses that data
                    //data = parser.ReadFile("C:\\Users\\Joseph\\Documents\\Redler\\MotorController.ini");

                    sw.WriteLine("[GraphAdvanced]");
                    sw.WriteLine("Multiply = 1");
                    sw.WriteLine("Multiply2 = 1");
                    sw.WriteLine("UnderSample = 1");
                    sw.WriteLine("RefreshTime = 1");

                    sw.Close();

                    _multiply     = 1;
                    _multiply2    = 1;
                    _under_sample = 1;
                    _refreshTime  = 50;
                    INIFilePath   = pathString;
                }
            }
            catch { }
            try
            {
                data          = parser.ReadFile(pathString + "\\MotorController.ini");
                _multiply     = float.Parse(data["GraphAdvanced"]["Multiply"]);
                _multiply2    = float.Parse(data["GraphAdvanced"]["Multiply2"]);
                _under_sample = int.Parse(data["GraphAdvanced"]["UnderSample"]);
                if (_under_sample < 1)
                {
                    _under_sample = 1;
                }
                _refreshTime = int.Parse(data["GraphAdvanced"]["RefreshTime"]);
                INIFilePath  = pathString + "\\MotorController.ini";
            }
            catch { }


            VM_UC_Main = uc_main;
            //RefreshTime = 55;


            // For chart data setup, see  OnExampleEnter(), which is called by the SciChart Examples Suite
            CAN_Common.AddEventHandler(
                new Tuple <int, int>(Utils.MakeKey("AD", 0), NodeId),
                pck =>
            {
                //int temp = Utils.getPacketInt(pck);
                //Multiply = temp;
                Multiply = _multiply;    // pck.getPacketFloat();
            });
            //Multiply = 189;
            // _multiply = PersistFloat.GetValue(Consts.PERSIST_VARIABLES.MULTIPLY);
            //prepareDataReceiver();
            OnExampleEnter();
            CAN_Common.AddEventHandler(new Tuple <int, int>(Utils.MakeKey("FT", 1), NodeId), dataReceivedFT1);
            PlotTime = 1000;
            Thread.Sleep(100);
            PlotTime *= 2;
            init_DATA_RUNTIME();
        }
Beispiel #2
0
        private void AddEventHandler(int key, Action <byte[]> action)
        {
            Tuple <int, int> tup = new Tuple <int, int>(key, NodeId);

            CAN_Common.AddEventHandler(tup, action);
        }