using ConfigOperator;
using RealtimeData;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Test;

internal class ConfigConverter
{
    public void Convert(string basePath)
    {
        if (string.IsNullOrEmpty(basePath))
            return;
        string localBase =Path.Combine( System.Environment.CurrentDirectory,"Settings");


        Hardwares hardwares = new();
        HardwareFileLoader hardwareFileLoader = new(hardwares);
        hardwareFileLoader.Load(Path.Combine(basePath, "Hardwares"));
        hardwareFileLoader.Save(Path.Combine(localBase, "Hardwares"));

        HardwareAddress hardwareAddress = new HardwareAddress();
        AddressFileLoader addressFileLoader = new(hardwareAddress);
        addressFileLoader.LoadPLC(Path.Combine(basePath, "PLCIOList"), Path.Combine(basePath, "PLCIOList", "PLCChannel"));
        addressFileLoader.SavePLC(Path.Combine(localBase, "PLCIOList"), Path.Combine(localBase, "PLCIOList", "PLCChannel"));
        addressFileLoader.Load(Path.Combine(basePath, "IOList"));
        addressFileLoader.Save(Path.Combine(localBase, "IOList"));

    }
}
