Advertisement
Guest User

ModBusMap

a guest
Jan 22nd, 2018
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. public ModBusMaps()
  2.         {
  3.             try
  4.             {
  5.                 var path = Path.Combine(Folders.App, "drivers", "modbus", "maps");
  6.                 FileInfo[] info = new DirectoryInfo(path).GetFiles($"*{mapSuffix}.json");
  7.                 maps = new Dictionary<string, ModbusMap>();
  8.                 foreach (FileInfo tmp in info)
  9.                 {
  10.                     try
  11.                     {
  12.                         ModbusMap Map = new ModbusMap(tmp);
  13.                         maps.Add(getMapName(tmp.FullName), Map);
  14.                     }
  15.                     catch(Exception ex)
  16.                     {
  17.                         log.Error($"Unable to read ModBus map: {tmp.Name}{Environment.NewLine}Exception: {ex.Message}");
  18.                     }
  19.                 }
  20.                 maps.Keys.ForEach(n => log.Debug($"Loaded: {n}"));
  21.                
  22.                 /*maps = new DirectoryInfo(path)
  23.                     .GetFiles($"*{mapSuffix}.json")
  24.                     .Select(file => new
  25.                     {
  26.                         Name = getMapName(file.FullName),
  27.                         Map = new ModbusMap(file)
  28.                     })
  29.                     .ToDictionary(map => map.Name, map => map.Map);
  30.  
  31.                 maps.Keys.ForEach(n => log.Debug($"Loaded: {n}"));*/
  32.             }
  33.             catch(Exception ex)
  34.             {
  35.                 log.Error($"Unable to read ModBus maps: {ex}");
  36.             }
  37.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement