Example #1
0
    // Start is called before the first frame update
    void Start()
    {
        bool        couldReadHeader = DataHeader.TryReadHeader("Configuration.json", out DataHeader header);
        IDataSource dataSource      = null;

        if (!couldReadHeader)
        {
            File.Create("Configuration.json");
            header            = new DataHeader();
            header.Delimeter  = ";";
            header.DeltaTime  = .1f;
            header.DataPoints = new DataPointDefinition[2];
            for (int i = 0; i < header.DataPoints.Length; i++)
            {
                header.DataPoints[i]   = new DataPointDefinition();
                header.DataPoints[i].X = i;
            }
            dataSource = new NetworkDataSource(3015, header);
        }
        else
        {
            switch (header.SourceType)
            {
            case DataSourceType.FILE:
                dataSource = new FakeDataSource(header.SourceLocation);
                break;

            case DataSourceType.NETWORK:
                dataSource = new NetworkDataSource(3015, header);
                break;

            case DataSourceType.SERIAL:
                dataSource = new SerialDataSource(string.IsNullOrEmpty(header.SourceLocation) ? "Com3" : header.SourceLocation);
                break;
            }
        }
        //Sets up both the fake data source and the real data from the ardiuno
        //fakeSource = new FakeDataSource("CLT Composite Beams Board1 2by10 Panel 1.ASC", 200);
        //serialDataSource = new SerialDataSource("Com3", new string[] {
        //"DASYLab - V 11.00.00",
        //"Worksheet name: 6by10beamlayout",
        //"Recording date: 7 / 1 / 2016,  4:52:39 PM",
        //"Block length: 2",
        //"Delta: 1.0 sec.",
        //"Number of channels: 3",
        //"Date;Measurement time[hh:mm:ss];voltage [V];voltage2 [V]; volage3 [V];"});

        MainCollection = new Parser(dataSource);
        MainCollection.start();
    }