Exemplo n.º 1
0
        public static void Main(string[] args)
        {
            var arguments = Arguments.arguments(args, jStrings("markets", "start", "end", "out", "calculator", "interval"));
            var names     = split(",", arguments.@string("markets"));
            var symbols   = list(STO.symbols(names));

            if (arguments.containsKey("calculator"))
            {
                var calculator = Type.GetType(arguments.@string("calculator"));
                each(symbols, symbol => symbol.overrideSlippageCalculator(calculator));
            }
            var start   = arguments.get("start", "");
            var end     = arguments.get("end", "");
            var outFile = new QFile(arguments.@string("out"));
            var range   = new Range(isEmpty(start) ? null : Dates.date(start), isEmpty(end) ? null : Dates.date(end));
            var loader  = new SystemDbBarLoader(Interval.lookup(arguments.@string("interval")), symbols, dictionary(symbols, s => range));
            var csv     = new Csv();
            var columns = list("date");

            columns.AddRange(convert(symbols, s => s.name));
            csv.addHeader(jList(columns));
            for (var i = 0; i < loader.numDates(); i++)
            {
                var time      = loader.date(i);
                var record    = list(ymdHuman(time));
                var slippages = loader.currentSlippages(time);
                each(symbols, s => record.Add(slippages.ContainsKey(s) ? slippages[s].ToString("N12") : "NA"));
                csv.add(jList(record));
            }
            csv.overwrite(outFile);
        }
Exemplo n.º 2
0
        static QFile hamsterfyMetricsFile(int id, QFile metricsFile)
        {
            var hamster = hamsterMetricsFile(id, metricsFile);

            info("starting write to hamster db: " + hamster);
            var db = new Database();

            db.Create(hamster.path());
            var metricCsv       = new CsvStreamer(metricsFile, true);
            var fileMetricNames = rest(list <string>(metricCsv.header()));
            var runs            = new List <int>();

            eachUntilNull(() => metricCsv.next(), jRecord => {
                var record = list <string>(jRecord);
                var run    = int.Parse(first(record));
                runs.Add(run);
                var doubles = array(convert(rest(record), s => STOMetricsWriter.fromMetricCsv(s)));
                var bytes   = new byte[doubles.Length * 8];
                Buffer.BlockCopy(doubles, 0, bytes, 0, bytes.Length);
                db.Insert(runKey(run), bytes);
            });
            db.Insert(METRICS_KEY, serialize(list(fileMetricNames)));
            db.Insert(RUNS_KEY, serialize(runs));
            insertMetricSortedRuns(db);
            db.Close();
            info("done hamster write");
            return(hamster);
        }
Exemplo n.º 3
0
        public override bool TransferFile(string path)
        {
            // K1xxx 表示零件层信息 ->QFile
            // K2xxx 表示参数层信息 ->QCharacteristic
            // K0xxx 表示测量数据 -> QDataItem
            QFile qf = new QFile();

            qf[1001] = "excel[0][1]";

            QCharacteristic qc = new QCharacteristic();

            qc[2001] = "k2001";

            qf.Charactericstics.Add(qc);


            QDataItem dataItem = new QDataItem();

            dataItem.SetValue("excel[x][y]");
            dataItem.date  = DateTime.Parse("2018-1-1 15:00:00");
            dataItem[0006] = "";

            qc.data.Add(dataItem);



            qf.ToDMode();

            qf.SaveToFile("d:\\abcd.dfq");

            return(true);
        }
Exemplo n.º 4
0
        public static QFile hamsterMetricsFile(int id, QFile metricsFile)
        {
            var result = new QDirectory(@"C:\tempMetricFiles\hamster").file(new [] { "" + id, "Metrics", metricsFile.name().Replace(".csv", ".ham") });

            result.ensurePath();
            return(result);
        }
Exemplo n.º 5
0
        public bool SaveDFQ(QFile qf, string path)
        {
            if (File.Exists(path) && AddTimeToNew)
            {
                path = Funs.AppendTimeToFileName(path);
            }

            try
            {
                if (qf.SaveToFile(path))
                {
                    AddSuccessedFile(path);
                }
                else
                {
                    AddFailedFile(path, "保存失败");
                    return(false);
                }
            }
            catch (Exception e1)
            {
                AddFailedFile(path, e1.Message);
                return(false);
            }
            return(true);
        }
Exemplo n.º 6
0
 public FilePersistedTextBox(QFile storage)
 {
     this.storage = storage;
     if (storage.exists())
     {
         Text = storage.text();
     }
 }
Exemplo n.º 7
0
        public static void readFromS3(int id, string name, int number, string path)
        {
            var data = (byte[])key(id, name, number).read(5000);
            var file = new QFile(path);

            file.ensurePath();
            file.overwrite(data);
        }
Exemplo n.º 8
0
 public void TestFileConstructorNotThrowingAnException()
 {
     using (var f = new QFile(_testFilePath2.FullName))
     {
         using (new QFileInfo(f))
         {
         }
     }
 }
Exemplo n.º 9
0
        void addPoints(string fileName)
        {
            var        csv = new QFile(fileName).csv();
            Collection c   = csv.records();

            foreach (var record in O.list <List>(c))
            {
                addPoint(Double.Parse(O.the(O.list <string>(record))));
            }
        }
Exemplo n.º 10
0
        public virtual QFile Transfer(string path)
        {
            QFile qf;

            try
            {
                qf = new QFile();
                Thread.Sleep(500);
            }
            catch
            {
                qf = null;
            }
            return(qf);
        }
Exemplo n.º 11
0
        public static void writeOneToCsv(QFile file, int runNumber, Dictionary <string, double> metrics)
        {
            var values = "" + runNumber;

            if (!file.exists())
            {
                var header = "run," + join(",", metrics.Keys);
                each(metrics.Keys, k => values += "," + metrics[k]);
                file.create(header + "\n" + values + "\n");
            }
            else
            {
                each(list <string>(file.csvHeader()), k => values += k.Equals("run") ? "" : "," + (metrics.ContainsKey(k) ? "" + metrics[k] : ""));
                file.append(values + "\n");
            }
        }
Exemplo n.º 12
0
        private QFile getQFile(List <QFile> qfs, string k1001, string k1002)
        {
            for (int i = 0; i < qfs.Count; i++)
            {
                if (qfs[i][1001].ToString() == k1001 && qfs[i][1002].ToString() == k1002)
                {
                    return(qfs[i]);
                }
            }
            QFile qf = new QFile();

            qfs.Add(qf);
            qf[1001] = k1001;
            qf[1002] = k1002;

            return(qf);
        }
Exemplo n.º 13
0
        public override bool TransferFile(string path)
        {
            List <string[]> data = readData(path);

            initIndices(data[0]);
            List <List <string[]> > models = groupModels(data);

            // check correctness (same type colF) of models
            if (!verify(models))
            {
                LogList.Add(new Classes.TransLog(path, "无输出", "输入格式错误。", Classes.LogType.Fail, "同一检测点多种不同数据类型。"));
                return(false);
            }


            List <QCharacteristic> qchs = new List <QCharacteristic>();

            for (int i = 0; i < models.Count; i++)
            {
                qchs.AddRange(ProcessModel(models[i]));
            }

            QFile qf = new QFile();

            qf[1001] = data[1][B].Split('_')[0];

            // merge characters that have the same K2001 and K2002。
            for (int i = 0; i < qchs.Count; i++)
            {
                int pos = indexOf(qf.Charactericstics, qchs[i]);
                if (pos < 0)
                {
                    qf.Charactericstics.Add(qchs[i]);
                }
                else
                {
                    qf.Charactericstics[i].data.AddRange(qchs[i].data);
                }
            }

            qf.ToDMode();
            Thread.Sleep(1000);

            return(SaveDfq(qf, path, qf[1001].ToString()));
        }
Exemplo n.º 14
0
        /// <summary>
        /// 将转换好的DFQ文件进行保存。
        /// </summary>
        /// <param name="qf">需要保存的DFQ数据。</param>
        /// <param name="outfile">输出的DFQ文件。</param>
        /// <returns></returns>
        public bool SaveDfqByInDir(QFile qf, string outfile)
        {
            switch (pd.KeepOutFolderStructType)
            {
            case 0:
                SaveDfq(qf, outfile);
                break;

            case 1:
                outfile = FileHelper.GetOutFolder(CurrentInFile,
                                                  currentInputPath.Type == 0 ? "" : currentInputPath.path,
                                                  pd.OutputFolder);
                SaveDfq(qf, outfile);
                break;
            }

            return(SaveDfq(qf, outfile));
        }
Exemplo n.º 15
0
        public override void DealFile(string path)
        {
            try
            {
                DataTable dt = ImportFormExcel(path).Tables[0];
                QFile     qf = new QFile();

                string lineno = dt.Rows[0][2].ToString().Trim();
                string tmp    = dt.Rows[0][3].ToString().Trim();


                for (int i = 4; i < dt.Columns.Count; i++)
                {
                    QParamter p = new QParamter();
                    p[2001] = (i - 3).ToString();
                    p[2002] = dt.Columns[i].Caption.Trim();                    // dt.Rows[0][i].ToString().Trim();
                    p[2024] = tmp;

                    Console.Write(dt.Columns[i].Caption);
                }



                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    if (dt.Rows[i][0].ToString().Length < 10)
                    {
                        break;
                    }


                    for (int j = 0; j < dt.Columns.Count; j++)
                    {
                        Console.WriteLine("{0}, {1}: {2}", i, j, dt.Rows[i][j].ToString().Trim());
                    }
                }
            }
            catch (Exception e1)
            {
                AddFailedFile(path, e1.Message);
            }
        }
Exemplo n.º 16
0
        public override void DealFile(string path)
        {
            try
            {
                if (!CheckExt(path))
                {
                    return;
                }

                QFile  qf       = transfer(path);
                string filename = Path.GetFileNameWithoutExtension(path);
                string dfqpath  = OutputFolder + "\\" + filename + ".DFQ";

                SaveDFQ(qf, dfqpath);
            }
            catch (Exception e1)
            {
                AddFailedFile(path, e1.Message);
            }
        }
Exemplo n.º 17
0
        static void startProcesses(Fields fields)
        {
            var nProcs  = fields.integer("numProcs");
            var mainDir = fields.text("mainDir");
            var command = fields.text("command");

            Environment.SetEnvironmentVariable("MAIN", mainDir);
            O.zeroTo(nProcs, i => {
                LogC.info("starting " + mainDir + " " + command + " -serverIndex " + i);
                try {
                    var exe = new QFile(mainDir + @"\dotNET\QRun\bin\Release\QRun.exe");
                    Bomb.unless(exe.exists(), () => "no exe found at " + exe.path());
                    var process = Process.Start(exe.path(), command + " -serverIndex " + i);
                    processes.get(mainDir + command).Add(process);
                } catch (Exception e) {
                    LogC.err("failure to launch!", e);
                    throw Bomb.toss("failure to launch!", e);
                }
            });
        }
Exemplo n.º 18
0
    public static int Main(string[] args)
    {
        Q_INIT_RESOURCE("simpletreemodel");

        new QApplication(args);

        QFile file = new QFile(":/default.txt");

        file.Open((int)QIODevice.OpenModeFlag.ReadOnly);
        TreeModel model = new TreeModel(file.ReadAll().ConstData());

        file.Close();

        QTreeView view = new QTreeView();

        view.SetModel(model);
        view.WindowTitle = "Simple Tree Model";
        view.Show();
        return(QApplication.Exec());
    }
Exemplo n.º 19
0
        public unsafe static void Main()
        {
            // Create a new QApplication object
            //QApp = QApp.CreateQApp();

            var argc = 0;

            new QApplication(ref argc, null);

            // QtUiTools is a smaller runtime, but requires manual compilation of the dll on the end users machine
            // Dim loader As New QtUiTools.QUiLoader()
            var loader = new QtDesigner.QFormBuilder();

            // Load the widget from a ui file
            var file1 = new QFile("testform1.ui");

            file1.Open(QIODevice.OpenModeFlag.ReadOnly);
            // error shows up in QtCore.OnEvent
            var widg1 = loader.Load(file1);

            file1.Close();

            widg1.ObjectName = "Simple example";
            widg1.Show();

            // TODO missing QObject.findChild QBoject.findChildren
            // This might be because the function calls in C++ use templates (generics) to specify the type
            //QWidget.QtQFindChildHelper(widg1, "pushButton", )

            // Looks like we'll need to re-implement our own findchild / find children method
            // using QWidget.Qt_qFindChild_helper
            // see C:\Qt\Qt5.7.0\5.7\Src\qtbase\src\corelib\kernel\qobject.h
            var test1 = findChild <QPushButton>(widg1, "pushbutton");

            //var test2 = getChildren(widg1);


            // Run the QApplication Process
            QApplication.Exec();
        }
Exemplo n.º 20
0
        private void LoadDefine(string path)
        {
            try
            {
                string content = "";
                using (StreamReader sr = new StreamReader(path, Encoding.Default))
                {
                    content = sr.ReadToEnd();
                }

                QFile     qf = new QFile();
                QParamter p  = new QParamter();

                string[] data = content.Split(';');
                foreach (var item in data)
                {
                    string[] dt = item.Split(',');
                    for (int i = 0; i < names.Length; i++)
                    {
                        if (names[i] == dt[0])
                        {
                            p[keys[i]] = dt[1];
                            break;
                        }
                    }
                }

                p.id = 1;
                qf.pramters.Add(p);
                qf.Tag = Path.GetFileNameWithoutExtension(path);

                qfs.Add(qf);
            }
            catch (Exception d1)
            {
                AddLog(path, d1.Message);
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 将一个qf保存至outfile. 其中outfile为完整路径。
        /// </summary>
        /// <param name="qf"></param>
        /// <param name="outfile"></param>
        /// <returns></returns>
        public bool SaveDfq(QFile qf, string outfile)
        {
            outfile = ProcessOutputFileNameIfRepeated(outfile);

            string outdir = Path.GetDirectoryName(outfile);

            if (!Directory.Exists(outdir))
            {
                Directory.CreateDirectory(outdir);
            }

            TransLog log = null;

            try
            {
                if (qf.SaveToFile(outfile))
                {
                    LastOutputDfqFile = outfile;
                    log = new TransLog(CurrentInFile, outfile, "保存成功", LogType.Success);
                }
                else
                {
                    LastOutputDfqFile = null;
                    log = new TransLog(CurrentInFile, outfile, "保存失败,原因路径不存在,或者没有写入权限。", LogType.Fail);
                }
            }
            catch (Exception ex)
            {
                log = new TransLog(CurrentInFile, outfile, "保存失败,原因:" + ex.Message, LogType.Fail);
            }
            if (log.LogType != LogType.Success)
            {
                LogList.Add(log);
            }

            return(log.LogType == LogType.Success);
        }
Exemplo n.º 22
0
        static void hamsterfyParametersFile(int id, QFile paramsFile)
        {
            var hamster = hamsterParametersFile(id, paramsFile);

            info("starting write to hamster db: " + hamster);
            var db = new Database();

            db.Create(hamster.path());
            var paramCsv       = new CsvStreamer(paramsFile, true);
            var fileParamNames = rest(list <string>(paramCsv.header()));
            var runs           = new List <int>();

            eachUntilNull(() => paramCsv.next(), jRecord => {
                var record = list <string>(jRecord);
                var run    = int.Parse(first(record));
                runs.Add(run);
                db.Insert(runKey(run), serialize(list(rest(record))));
            });
            db.Insert(PARAMS_KEY, serialize(list(fileParamNames)));
            db.Insert(RUNS_KEY, serialize(runs));
            insertParameterSortedRuns(db);
            db.Close();
            info("done hamster write");
        }
Exemplo n.º 23
0
        /// <summary>
        /// 根据文件名保存qf。其中filename不包括路径。
        /// </summary>
        /// <param name="qf"></param>
        /// <param name="filename"></param>
        public void SaveDfqByFilename(QFile qf, string filename)
        {
            // replace illegal characters in filename with '_'
            string illegals = "\\/:?\"<>|";

            for (int i = 0; i < illegals.Length; i++)
            {
                filename = filename.Replace(illegals[i], '_');
            }

            switch (pd.KeepOutFolderStructType)
            {
            case 0:
                SaveDfq(qf, pd.OutputFolder + "\\" + filename);
                break;

            case 1:
                string inroot  = currentInputPath.Type == 0 ? "" : currentInputPath.path;
                string indir   = Path.GetDirectoryName(CurrentInFile);
                string outfile = FileHelper.GetOutFolder(indir + "\\" + filename, inroot, pd.OutputFolder);
                SaveDfq(qf, outfile);
                break;
            }
        }
Exemplo n.º 24
0
        public void testStoWorks()
        {
            LogC.setOut("testStoWorks", @"C:\logs\localCloud.log", false);
            LogC.useJavaLog = true;
            const int systemId = 178114;

            var curveFile = new QFile(@"V:\Market Systems\General Market Systems\Benchmark\20080923\CurvesBin\Benchmark_1.0_daily_RE.TEST.TY.1C/run_678.bin");

            curveFile.deleteIfExists();
            var testQueue = new Queue("TEST.LocalCloud");

            O.timerManager().isInterceptingTimersForTest = true;
            O.freezeNow("2009/06/22 03:00:00");
            O.timerManager().intercept("2009/06/22 03:00:00", "heartbeat");
            O.timerManager().intercept("2009/06/22 03:00:03", "second heartbeat");
            var server = new STOServer(systemId, 2);
            var fired  = false;

            server.heart.subscribe(fields => {
                fired = true;
                AreEqual(fields.get("Hostname"), O.hostname());
                AreEqual(fields.get("ServerIndex"), 2);
            });
            server.subscribe(testQueue);
            server.heart.initiate();
            IsFalse(fired);
            O.timerManager().runTimers("2009/06/22 03:00:00");
            O.wait(() => fired);
            MetricResults metrics = null;

            O.timerManager().intercept("2009/06/22 03:00:00", "client heartbeat");
            new STOClient(SystemDetailsTable.DETAILS.details(systemId), testQueue).metrics(678, results => metrics = results);
            O.wait(100, 1000, () => metrics != null);
            AreEqual(-1953125.00, metrics["RE.TEST.TY.1C"]["QNetProfit"]);
            curveFile.requireExists();
        }
Exemplo n.º 25
0
        public override bool TransferFile(string infile)
        {
            QCatalog  qlog   = QCatalog.GetCatlog(@"Z:\Projects\QTransducer\2017年\2017_10_重庆_Nemak\20180112_Problems");
            COMReader reader = new COMReader(infile);

            /************ 内容检测,有空不转换 **************/
            // 检测内容:Date (D4)/Time(D7)/Order(F4)/ Operator(B10)/ CMM(D10)/Part NO(F7)/Product(F10)
            if (reader.GetCell("D5").Trim().Length == 0 || reader.GetCell("D8").Trim().Length == 0 ||
                reader.GetCell("F5").Trim().Length == 0 || reader.GetCell("B11").Trim().Length == 0 ||
                reader.GetCell("D11").Trim().Length == 0 || reader.GetCell("F8").Trim().Length == 0 ||
                reader.GetCell("F11").Trim().Length == 0)
            {
                LogList.Add(new Classes.TransLog(infile, "无", "表头有空值,无法转换。",
                                                 Classes.LogType.Fail, "根据需求,以下表头禁止为空:Date /time/order/ operator/ CMM/Part NO/Product。"));
                return(false);
            }



            /************ 从Excel文件读取标题K域 **************/
            string K1001 = reader.GetCell("B8");
            string K0008 = reader.GetCell("B11");

            double   days = double.Parse(reader.GetCell("D5"));
            double   time = double.Parse(reader.GetCell("D8"));
            DateTime dt   = new DateTime(1900, 1, 1).AddDays(-2).AddDays(days + time);

            string K0012 = reader.GetCell("D11");

            string K0061 = reader.GetCell("F5");
            string K0014 = reader.GetCell("F8");
            string K1002 = reader.GetCell("F11");

            // 年份(2位)_天数(3位)_班次(1位)_设备号(1位)_当日序列号(3位)_设备累计序列号(7位)_工件状态(1位)
            string K0006 = null;
            string K0007 = null;
            string K0010 = null;

            try
            {
                K0006 = K0014.Substring(0, 5); // K0007: 截取班次(1位).
                K0007 = K0014.Substring(5, 1); // K0007: 截取班次(1位).
                K0010 = K0014.Substring(6, 1); // K0010: 截取设备号(1位)
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            /************ K值模板 **************/
            QFile qf = new QFile();

            qf[1001] = K1001;
            qf[1002] = K1002;

            QDataItem qdi = new QDataItem();

            if (K0006 != null)
            {
                qdi[0006] = K0006;
            }
            if (K0007 != null)
            {
                qdi[0007] = qlog.GetCatalogPIDString("K4252", K0007);
            }
            qdi[0008] = qlog.GetCatalogPIDString("K4092", K0008);
            if (K0010 != null)
            {
                qdi[0010] = qlog.GetCatalogPIDString("K4062", K0010);
            }
            qdi[0012] = qlog.GetCatalogPIDString("K4072", K0012);
            qdi[0014] = K0014;
            qdi[0061] = qlog.GetCatalogPIDString("K4272", K0061);

            // The first row of data. If it is not fixed, modify this variable.
            int firstRow = 13;
            int lastRow  = reader.GetRowCount();

            for (int i = firstRow; i < reader.GetRowCount(); i++)
            {
                // Characteristic	Actual	Nominal	Upper Tol	Lower Tol	Deviation
                // K2002, K0001, K2101, K2113, K2112
                string K2002 = reader.GetCell(i, 0);
                string K0001 = reader.GetCell(i, 1);
                string K2101 = reader.GetCell(i, 2);
                string K2113 = reader.GetCell(i, 3);
                string K2112 = reader.GetCell(i, 4);

                if (K2002 == null || K2002.Trim().Length == 0)
                {
                    break;  // 根据20180112 问题 第2条 修改。
                }
                QCharacteristic qc = new QCharacteristic();
                qc[2001] = qf.Charactericstics.Count + 1;
                qc[2002] = K2002;
                qc[2022] = "8";
                qc[2101] = K2101;
                qc[2112] = K2112;
                qc[2113] = K2113;
                qc[2120] = 1;
                qc[2121] = 1;
                qc[2142] = "mm";
                qc[8500] = 5;
                qc[8501] = 0;

                QDataItem di = qdi.Clone();
                di.SetValue(K0001);
                di.date = dt; // DateTime.Now; // 根据20180112 问题 第3条 修改。
                qc.data.Add(di);

                qf.Charactericstics.Add(qc);
            }

            qf.ToDMode();

            bool result = SaveDfq(qf, string.Format("{0}\\{1}_{2}.dfq",
                                                    pd.GetOutDirectory(infile),                  // output directory
                                                    K0014,                                       // filename from all info.
                                                    DateTimeHelper.ToFullString(DateTime.Now))); // time stamp.

            Thread.Sleep(1000);

            return(result);
        }
Exemplo n.º 26
0
        public override bool TransferFile(string path)
        {
            IniAccess ia          = new IniAccess("userconfig.ini");
            string    catalogfile = ia.ReadValue("catalog");
            QCatalog  catalog     = QCatalog.GetCatlog(File.Exists(catalogfile) ? catalogfile : "catalog.dfd");


            Workbook wb = new Workbook();

            wb.LoadFromFile(path);
            Worksheet sheet = wb.Worksheets[0];

            QFile qf = new QFile();

            qf[1001] = sheet[3, 2].Value;
            qf[1053] = sheet[3, 4].Value;
            qf[1086] = sheet[3, 5].Value;
            qf[1110] = sheet[3, 6].Value; // 1100 -> 1110
            qf[1101] = sheet[2, 1].Value;
            qf[1102] = sheet[3, 1].Value;

            int rowid = 5;

            while (true)
            {
                if (isEmpty(sheet, rowid))
                {
                    break;
                }

                QCharacteristic qc = new QCharacteristic();
                qf.Charactericstics.Add(qc);
                string pid = sheet[rowid, 1].Value != null ? sheet[rowid, 1].Value.ToString() : "";
                qc[2001] = pid.Replace('(', ' ').Replace(')', ' ').Trim();
                qc[2002] = sheet[rowid, 2].Value;
                qc[2005] = sheet[rowid, 13].Value.Contains("是") ? 4 : 1; // 不包括是时为 1 还是0 ,文档中有错误。
                qc[2022] = 4;
                qc[2101] = sheet[rowid, 3].Value;
                qc[2113] = sheet[rowid, 4].Value;
                qc[2112] = sheet[rowid, 5].Value;
                qc[2120] = 1;
                qc[2121] = 1;
                qc[2142] = "mm";
                qc[8500] = 5;
                qc[8501] = 0;



                QDataItem di = new QDataItem();
                di.SetValue(sheet[rowid, 6].Value);
                di.date  = sheet[3, 10].DateTimeValue;
                di[0006] = sheet[3, 3].Value;
                di[0008] = catalog.getCatalogPID("K4093", sheet[3, 11].Value);
                di[0010] = catalog.getCatalogPID("K4063", sheet[rowid, 11].Value);
                di[0011] = sheet[rowid, 10].Value;
                di[0012] = catalog.getCatalogPID("K4072", sheet[rowid, 10].Value);
                di[0061] = catalog.getCatalogPID("K4273", sheet[3, 7].Value);
                qc.data.Add(di);

                // Console.WriteLine("{0}, {0}, {0}, {0}", di[0008], di[0010], di[0012], di[0061]);

                rowid++;
            }

            qf.ToDMode();

            SaveDfqByFilename(qf, Path.GetFileNameWithoutExtension(path) + ".dfq");

            return(base.TransferFile(path));
        }
Exemplo n.º 27
0
 public void TestFileConstructorNotThrowingAnException()
 {
     var f = new QFile(_testFilePath2.FullName);
     var q = new QFileInfo(f);
 }
Exemplo n.º 28
0
        public override bool TransferFile(string infile)
        {
            COMReader reader = new COMReader(infile);

            string   K1900 = reader.GetCell("B5"); //
            string   K1041 = reader.GetCell("B8"); //
            string   K0008 = reader.GetCell("B11");
            double   days  = double.Parse(reader.GetCell("D5"));
            double   time  = double.Parse(reader.GetCell("D8"));
            DateTime K0004 = new DateTime(1900, 1, 1).AddDays(-2).AddDays(days + time);
            string   K0012 = reader.GetCell("D11");
            string   K1001 = reader.GetCell("F8");//
            string   K0014 = reader.GetCell("F11");

            QCatalog qlog = getCatlog();

            int startRow = 13;
            int endRow   = reader.GetRowCount();
            // A: char, B: Actual, C: Nominal, D: Upper Tol;  E: Lower Tol; F: Deviation

            QFile qf = new QFile();

            qf[1001] = K1001;
            qf[1041] = K1041;
            qf[1900] = K1900;

            for (int i = startRow; i < endRow; i++)
            {
                // Characteristic	Actual	Nominal	Upper Tol	Lower Tol	Deviation
                // K2002, K0001, K2101, K2113, K2112
                string K2002 = reader.GetCell(i, 0);
                string K0001 = reader.GetCell(i, 1);
                string K2101 = reader.GetCell(i, 2);
                string K2113 = reader.GetCell(i, 3);
                string K2112 = reader.GetCell(i, 4);

                QCharacteristic qc = new QCharacteristic();
                qc[2001] = qf.Charactericstics.Count + 1;
                qc[2002] = K2002;
                qc[2022] = "8";
                qc[2101] = K2101;
                qc[2112] = K2112;
                qc[2113] = K2113;
                qc[2120] = 1;
                qc[2121] = 1;
                qc[2142] = "mm";
                qc[8500] = 5;
                qc[8501] = 0;

                QDataItem di = new QDataItem();
                di.date = K0004;
                di.SetValue(K0001);
                di[0008] = qlog.getCatalogPID("K4093", K0008);
                di[0012] = qlog.getCatalogPID("K4073", K0012);
                di[0014] = K0014;
                qc.data.Add(di);

                qf.Charactericstics.Add(qc);
            }

            qf.ToDMode();

            return(SaveDfq(qf, string.Format("{0}\\{1}_{2}.dfq",
                                             pd.GetOutDirectory(infile),                   // output directory
                                             K1001,                                        // filename from all info.
                                             DateTimeHelper.ToFullString(DateTime.Now)))); // time stamp.
        }
Exemplo n.º 29
0
 public Parameters(string systemClassName, QFile file) : this(systemClassName) {
     var csv = file.csv(true);
     zeroTo(csv.count(), i => Add(csv.value("name", i), csv.value("value", i)));
 }
Exemplo n.º 30
0
 public void TestFileConstructorNotThrowingAnException()
 {
     var f = new QFile(_testFilePath2.FullName);
     var q = new QFileInfo(f);
 }
Exemplo n.º 31
0
        public override bool TransferFile(string infile)
        {
            QCatalog  qlog   = QCatalog.GetCatlog();
            COMReader reader = new COMReader(infile);

            double   days    = double.Parse(reader.GetCell("D5"));
            double   time    = double.Parse(reader.GetCell("F5"));
            DateTime dt      = new DateTime(1900, 1, 1).AddDays(-2).AddDays(days + time);
            string   allinfo = reader.GetCell("B8");
            string   K1001   = allinfo.Split('_')[1]; // modified
            string   K1002   = reader.GetCell("F8");  // modified
            string   K0006   = allinfo.Split('_')[0]; // modified
            string   K0007   = reader.GetCell("B11"); // modified
            string   K0008   = reader.GetCell("D8");  // modified
            string   K0010   = reader.GetCell("F11");
            string   K0012   = reader.GetCell("D11");
            string   K0061   = allinfo.Split('_')[2];

            QDataItem qdi = new QDataItem();

            qdi[0006] = K0006;                                    // modified
            qdi[0007] = qlog.GetCatalogPIDString("K4092", K0007); // modified
            qdi[0008] = K0008;                                    // modified
            qdi[0010] = qlog.GetCatalogPIDString("K4062", K0010);
            qdi[0012] = qlog.GetCatalogPIDString("K4072", K0012);
            qdi[0061] = qlog.GetCatalogPIDString("K4272", K0061);

            // The first row of data. If it is not fixed, modify this variable.
            int   startrow = 13;
            QFile qf       = new QFile();

            qf[1001] = K1001; // modified
            qf[1002] = K1002; // modified


            for (int i = startrow; i < reader.GetRowCount(); i++)
            {
                // Characteristic	Actual	Nominal	Upper Tol	Lower Tol	Deviation
                // K2002, K0001, K2101, K2113, K2112
                string K2002 = reader.GetCell(i, 0);
                string K0001 = reader.GetCell(i, 1);
                string K2101 = reader.GetCell(i, 2);
                string K2113 = reader.GetCell(i, 3);
                string K2112 = reader.GetCell(i, 4);

                QCharacteristic qc = new QCharacteristic();
                qc[2001] = qf.Charactericstics.Count + 1;
                qc[2002] = K2002;
                qc[2022] = "8";
                qc[2101] = K2101;
                qc[2112] = K2112;
                qc[2113] = K2113;
                qc[2120] = 1;
                qc[2121] = 1;
                qc[2142] = "mm";
                qc[8500] = 5;
                qc[8501] = 0;

                QDataItem di = qdi.Clone();
                di.SetValue(K0001);
                qc.data.Add(di);

                qf.Charactericstics.Add(qc);
            }

            qf.ToDMode();

            return(SaveDfq(qf, string.Format("{0}\\{1}_{2}.dfq",
                                             pd.GetOutDirectory(infile),                   // output directory
                                             allinfo,                                      // filename from all info.
                                             DateTimeHelper.ToFullString(DateTime.Now)))); // time stamp.
        }
Exemplo n.º 32
0
 public void TestFileConstructorNotThrowingAnException()
 {
     using (var f = new QFile(_testFilePath2.FullName))
     {
         using (new QFileInfo(f))
         {
         }
     }
 }