示例#1
0
        void InitializeGuiBackendFromXml()
        {
            var catalogFilePath = Settings.Default.CatalogFilePath;

            if (!CsvHelper.IsAbsolutePath(catalogFilePath))
            {
                catalogFilePath = Path.Combine(Misc.AssemblyPath, catalogFilePath);
            }

            XmlHandler.ReadCatalogue(catalogFilePath);

            foreach (var product in XmlHandler.Catalogue)
            {
                cbProduct.Items.Add(product.Name);
            }
        }
示例#2
0
        void btnStart_Click(object sender, EventArgs e)
        {
            stopPressed      = false;
            btnPause.Enabled = false;

            if (!uctlLotData.AreInputControlsValid())
            {
                return;
            }

            lotInfo      = uctlLotData.LotInfo;
            lotInfo.Date = DateTime.Now.ToString("yyyy-MM-dd");

            netWeight            = lotInfo.Package.NetWeight;
            measurementTolerance = (netWeight * Settings.Default.MeasurementTollerace) / 100;
            zeroThreshold        = (netWeight * Settings.Default.ZeroThreshold) / 100;

            // for each LOT save logs in separate files. (If a log file was already created for a lot reuse it)
            if (CsvHelper.LogAlreadyPresent(lotInfo.Id, logFolderPath, ref logFilePath))
            {
                DialogResult result = MessageBox.Show("Pentru lotul selectat exista deja masuratori. Noile masuratori se vor adauga celor existente. Doriti sa Continuati?", "Continuare Lot", MessageBoxButtons.YesNo);
                if (result != DialogResult.Yes)
                {
                    return;
                }

                log.ChangeLoggingFile(logFilePath);
                lotInfo.AppendToLot = true;

                log.Info("Button Start Clicked" + Environment.NewLine);
                log.Info("### Lot " + lotInfo.Id + " Resumed on " + lotInfo.Date + " ###");
            }
            else
            {
                logFilePath = logFolderPath + DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss") + "_" + lotInfo.Id + ".log";
                log.ChangeLoggingFile(logFilePath);
                lotInfo.AppendToLot = false;

                log.Info("Button Start Clicked" + Environment.NewLine);
                LogLotInfo(lotInfo);
            }

            var CSVOutputFolderPath = Path.Combine(Misc.AssemblyPath, Settings.Default.CSVOutputPath);

            csvHelper = new CsvHelper();
            csvHelper.PrepareOutputFile(CSVOutputFolderPath, lotInfo);

            readPort?.Dispose();
            readPort = new MySerialReader(Measurements, zeroThreshold);

            // Code for Start Reading in a new Thread
            //readThread?.Abort();
            //readThread = new Thread(new ThreadStart(ReadThread));
            //readThread.Start();

            Thread.Sleep(100);

            if (simulationEnabled)
            {
                writePort?.Dispose();
                writeThread?.Abort();
                writeThread = new Thread(WriteThread);
                writeThread.Start();
            }

            btnStart.Enabled   = false;
            btnPause.Enabled   = true;
            btnStopLot.Enabled = true;

            uctlLotData.DisableInputControls();
        }
示例#3
0
        private void btnImport_Click(object sender, System.EventArgs e)
        {
            var outputFolderPath      = Settings.Default.DataImporterOutputPath;
            var outputFilePath        = "";
            var startMeasurementIndex = 1;

            if (!uctlLotData.AreInputControlsValid())
            {
                return;
            }

            var inputFilePath = txtFileName.Text;

            if (string.IsNullOrEmpty(inputFilePath))
            {
                MessageBox.Show("Nu s-a specificat un fisier cu date de intrare!", "Date Incorecte", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            try
            {
                var lotInfo = uctlLotData.LotInfo;

                var intermediateFilePath = Path.GetDirectoryName(inputFilePath) + "\\temp_.bak";

                if (CsvHelper.OutputAlreadyPresent(lotInfo.Id, outputFolderPath, ref outputFilePath))
                {
                    var result = MessageBox.Show("Pentru lotul selectat exista deja masuratori. Noile masuratori se vor adauga celor existente. Doriti sa Continuati?", "Continuare Lot", MessageBoxButtons.YesNo);
                    if (result != DialogResult.Yes)
                    {
                        return;
                    }

                    lotInfo.AppendToLot = true;
                }

                if (lotInfo.AppendToLot)
                {
                    var lastMeasurementIndex = CsvHelper.GetLastMeasurementIndex(outputFilePath);
                    startMeasurementIndex = Int32.Parse(lastMeasurementIndex) + 1;
                }
                else
                {
                    outputFilePath = CsvHelper.CalculateOutputFilePath(outputFolderPath, DateTime.Now, lotInfo.Id);
                    CsvHelper.InitializeOutputFileContents(outputFilePath, lotInfo.MakeMeasurementFileHeader());
                }

                Misc.MakeTemporaryFileWithStandardizedContents(inputFilePath, intermediateFilePath, lotInfo.Date, startMeasurementIndex);
                Misc.AppendOneFileToAnother(intermediateFilePath, outputFilePath);

                MessageBox.Show("Datele au fost importate in fisierul: " + Environment.NewLine + Environment.NewLine +
                                outputFilePath, "Conversie Terminata", MessageBoxButtons.OK, MessageBoxIcon.None);

                File.Delete(intermediateFilePath);
            }
            catch (Exception ex)
            {
            }
            finally
            {
                uctlLotData.InitializeInputControls();
                uctlLotData.EnableInputControls();
                txtFileName.Text     = "";
                dateTimePicker.Value = DateTime.Now;
            }
        }