예제 #1
0
        private void BuildButton_Click(object sender, EventArgs e)
        {
            if (CheckCellsEmpty())
            {
                return;
            }

            List <double> listMonitorParameters = new List <double>()
            {
                Convert.ToDouble(StandHeightTextBox.Text),
                Convert.ToDouble(StandDiameterTextBox.Text),
                Convert.ToDouble(LegHeightTextBox.Text),
                Convert.ToDouble(LegWidthTextBox.Text),
                Convert.ToDouble(LegThiknessTextBox.Text),
                Convert.ToDouble(ScreenHeightTextBox.Text),
                Convert.ToDouble(ScreenWidthTextBox.Text),
                Convert.ToDouble(ScreenThiknessTextBox.Text),
            };

            _monitorParameters = new MonitorParameters(listMonitorParameters);
            if (_monitorParameters.StandParam == null ||
                _monitorParameters.LegParam == null ||
                _monitorParameters.ScreenParam == null)
            {
                return;
            }

            _inventorAPI    = new InventorAPI();
            _monitorManager = new MonitorManager(_inventorAPI, _monitorParameters);
            _monitorManager.CreateMonitor(BackCheckBox.Checked);
        }
예제 #2
0
        public void PositiveTestConstructor()
        {
            List <double> monitorParametersList = new List <double>()
            {
                15,
                200,
                50,
                60,
                20,
                330,
                550,
                30
            };

            MonitorParameters monitorParameters = new MonitorParameters(monitorParametersList);

            Assert.AreEqual(monitorParameters.StandParam.Height, 15);
            Assert.AreEqual(monitorParameters.StandParam.Diameter, 200);
            Assert.AreEqual(monitorParameters.LegParam.Height, 50);
            Assert.AreEqual(monitorParameters.LegParam.Width, 60);
            Assert.AreEqual(monitorParameters.LegParam.Thikness, 20);
            Assert.AreEqual(monitorParameters.ScreenParam.Height, 330);
            Assert.AreEqual(monitorParameters.ScreenParam.Width, 550);
            Assert.AreEqual(monitorParameters.ScreenParam.Thikness, 30);
        }
 /// <summary>
 /// Class constructor
 /// </summary>
 /// <param name="api">Wrapper API Inventor</param>
 /// <param name="modelParameters">Monitor parameters</param>
 public MonitorManager(InventorAPI api, MonitorParameters modelParameters)
 {
     _api             = api;
     _modelParameters = modelParameters;
     _objCollection   = _api.InventorApplication.TransientObjects.
                        CreateObjectCollection();
 }
예제 #4
0
        public void PositiveInfinityTestConstructor()
        {
            List <double> monitorParametersList = new List <double>()
            {
                double.PositiveInfinity,
                double.PositiveInfinity,
                double.PositiveInfinity,
                double.PositiveInfinity,
                double.PositiveInfinity,
                double.PositiveInfinity,
                double.PositiveInfinity,
                double.PositiveInfinity
            };

            Assert.Throws <NullReferenceException>(() =>
                                                   { MonitorParameters monitorParameters = new MonitorParameters(monitorParametersList); });
        }
예제 #5
0
        public void NanNTestConstructor()
        {
            List <double> monitorParametersList = new List <double>()
            {
                double.NaN,
                double.NaN,
                double.NaN,
                double.NaN,
                double.NaN,
                double.NaN,
                double.NaN,
                double.NaN
            };

            Assert.Throws <NullReferenceException>(() =>
                                                   { MonitorParameters monitorParameters = new MonitorParameters(monitorParametersList); });
        }
예제 #6
0
        public void Start()
        {
            int  n = 0;
            bool createBackFlag = true;

            while (true)
            {
                InventorAPI inventorAPI = new InventorAPI();

                List <double> listMonitorParameters = new List <double>()
                {
                    10, 160, 40, 50, 15, 172, 400, 30
                };

                MonitorParameters monitorParameters = new MonitorParameters(listMonitorParameters);

                MonitorManager monitorManager = new MonitorManager(inventorAPI,
                                                                   monitorParameters);

                var processes = Process.GetProcessesByName(Path.GetFileNameWithoutExtension("Inventor.exe"));
                var process   = processes.First();

                // При первой итерации проинициализировать объекты, отвечающие за фиксирование нагрузки
                if (n == 0)
                {
                    _ramCounter = new PerformanceCounter("Process", "Working Set", process.ProcessName);
                    _cpuCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total");
                }

                //_cpuCounter.NextValue();

                monitorManager.CreateMonitor(createBackFlag);

                var ram = _ramCounter.NextValue();
                var cpu = Math.Round(_cpuCounter.NextValue());

                _writer.Write($"{n}. ");
                _writer.Write($"RAM: {Math.Round(ram / 1024 / 1024)} MB");
                _writer.Write($"\tCPU: {cpu} %");
                _writer.Write(Environment.NewLine);
                _writer.Flush();
                n += 1;
            }
        }