static void Main(string[] args)
        {
            Options arguments = Parser.Default.ParseArguments <Options>(args).MapResult(options => options, _ => null);
            Logger  logger    = new Logger(true, arguments.LogFile != null ? arguments.LogFile : null);

            logger.Log("Started");

            // Server

            logger.Log($"Connecting to server {arguments.ServerName}");
            PIServer piServer = PIUtil.GetPIServer(arguments.ServerName);

            logger.Log($"Connecting to system {arguments.SystemName}");
            PISystem piSystem = AFUtil.GetPISystem(arguments.SystemName);

            logger.Log("Connected");

            // Database

            logger.Log($"Listing tags");
            PIUtil.WriteTags(piServer, arguments.TagOutputFile);

            logger.Log("Finished - press Enter to close terminal");
            logger.Close();
            Console.ReadLine();
        }
Beispiel #2
0
        static void Main(string[] args)
        {

            Options arguments = Parser.Default.ParseArguments<Options>(args).MapResult(options => options, _ => null);
            Logger logger = new Logger(true, arguments.LogFile != null ? arguments.LogFile : null);

            logger.Log("Started");

            // Server

            logger.Log($"Connecting to server {arguments.ServerName}");
            PIServer piServer = PIUtil.GetPIServer(arguments.ServerName);

            logger.Log($"Connecting to system {arguments.SystemName}");
            PISystem piSystem = AFUtil.GetPISystem(arguments.SystemName);

            logger.Log("Connected");

            logger.Log($"Listing databases: system {arguments.SystemName}");
            AFUtil.WriteDatabases(piSystem, arguments.DatabaseOutputFile);

            // Database

            if (arguments.DatabaseName != null)
            {
                AFDatabase database = AFUtil.GetDatabase(piSystem, arguments.DatabaseName);

                logger.Log($"Listing attributes for database {database.Name}");
                AFUtil.WriteAttributes(database, arguments.AttributeOutputFile);
            }
            else
            {
                var outputFileExtension = Path.GetExtension(arguments.AttributeOutputFile);
                var outputFileName = Path.ChangeExtension(arguments.AttributeOutputFile, null);

                AFDatabases databases = piSystem.Databases;
                Parallel.ForEach(
                    databases,
                    new ParallelOptions { MaxDegreeOfParallelism = arguments.NumParallelTasks },
                    (AFDatabase database) =>
                    {
                        logger.Log($"Listing attributes: database {database.Name}");
                        AFUtil.WriteAttributes(database, $"{outputFileName} {database.Name}{outputFileExtension}");
                    });
            }
            
            logger.Log("Finished - press Enter to close terminal");
            logger.Close();
            Console.ReadLine();
        }
Beispiel #3
0
 public static void Print(AFArray arr, string name, int precision = 4)
 {
     Internal.VERIFY(AFUtil.af_print_array_gen(name, arr._ptr, precision));
 }
Beispiel #4
0
 public static void Print(AFArray arr)
 {
     Internal.VERIFY(AFUtil.af_print_array(arr._ptr));
 }
        static void Main(string[] args)
        {
            Options arguments = Parser.Default.ParseArguments <Options>(args).MapResult(options => options, _ => null);
            Logger  logger    = new Logger(true, arguments.LogFile != null ? arguments.LogFile : null);

            logger.Log("Started");

            // Server

            logger.Log($"Connecting to server {arguments.ServerName}");
            PIServer piServer = PIUtil.GetPIServer(arguments.ServerName);

            logger.Log($"Connecting to system {arguments.SystemName}");
            PISystem piSystem = AFUtil.GetPISystem(arguments.SystemName);

            logger.Log("Connected");

            // Tags

            logger.Log($"Reading tags from {arguments.InputFile}");

            List <AbstractRetrievePoints> tagClasses = null;

            switch (arguments.InputType)
            {
            case "RecordedTag":
                tagClasses = MainFunctions.LoadTagClassesRecorded(
                    arguments.InputFile,
                    arguments.OutputDirectory,
                    arguments.TimeResolution,
                    arguments.NumYears,
                    arguments.PageSize,
                    piServer,
                    piSystem,
                    arguments.NumParallelTasks,
                    logger);
                break;

            case "InterpolatedTag":
                tagClasses = MainFunctions.LoadTagClassesInterpolated(
                    arguments.InputFile,
                    arguments.OutputDirectory,
                    arguments.TimeResolution,
                    arguments.NumYears,
                    arguments.PageSize,
                    piServer,
                    piSystem,
                    arguments.NumParallelTasks,
                    logger);
                break;

            case "RecordedAttribute":
                tagClasses = MainFunctions.LoadAttributeClassesRecorded(
                    arguments.InputFile,
                    arguments.OutputDirectory,
                    arguments.TimeResolution,
                    arguments.NumYears,
                    arguments.PageSize,
                    piServer,
                    piSystem,
                    AFUtil.GetDatabase(piSystem, arguments.DatabaseName),
                    arguments.NumParallelTasks,
                    logger);
                break;

            case "InterpolatedAttribute":
                tagClasses = MainFunctions.LoadAttributeClassesInterpolated(
                    arguments.InputFile,
                    arguments.OutputDirectory,
                    arguments.TimeResolution,
                    arguments.NumYears,
                    arguments.PageSize,
                    piServer,
                    piSystem,
                    AFUtil.GetDatabase(piSystem, arguments.DatabaseName),
                    arguments.NumParallelTasks,
                    logger);
                break;

            default:
                break;
            }
            logger.Log($"Tags read");

            logger.Log($"Reading tag data from {arguments.ServerName}, numParallelTasks = {arguments.NumParallelTasks}");
            MainFunctions.DoStuffParallelForeach(tagClasses, arguments.NumParallelTasks, logger);
            logger.Log($"Data read");

            logger.Log("Finished - press Enter to close terminal");
            logger.Close();
            Console.ReadLine();
        }