コード例 #1
0
 /// <summary>
 /// Initial CANSetting by preloaded dictionary<string, List<object>>
 /// </summary>
 /// <param name="SettingFile">settings of program</param>
 /// <param name="RootName">the root name in the file, it contains the expected module setting</param>
 public CANComm(string SettingFile, string RootName)
 {
     try
     {
         if (true == File.Exists(SettingFile))
         {
             Dictionary <string, List <object> > dictSetting = base.LoadSetting(this, SettingFile, RootName);
             if (dictSetting != null && dictSetting.Count == 0)
             {
                 throw new Exception(string.Format("[{0}] - can't find setting of this module or setting count of this module is 0. {1}", this.GetType().Name, this.GetType().Name));
             }
             else
             {
                 Setting = new CANSetting(dictSetting);
             }
         }
         else
         {
             throw new Exception(string.Format("[{0}] - setting file does not exist", this.GetType().Name));
         }
     }
     catch (Exception ex)
     {
         if (ex.Message.IndexOf(this.GetType().Name) == -1)
         {
             throw ex;
         }
         else
         {
             throw new Exception(string.Format("[{0}] - failed at open or parse setting file.{1}", this.GetType().Name, ex.Message));
         }
     }
 }
コード例 #2
0
 public CANComm(UInt16 deviceType, UInt16 deviceID, UInt16 channel, UInt16 accCode, UInt32 accMask, byte filter, byte mode, string baudRate, bool swapBitOrder = false, bool swapByteOrder = false)
 {
     Setting = new CANSetting(deviceType, deviceID, channel, accCode, accMask, filter, mode, baudRate, swapBitOrder, swapByteOrder);
 }
コード例 #3
0
 /// <summary>
 /// Initial instance with settings from file.
 /// </summary>
 /// <param name="settingFile">setting file name</param>
 public CANComm(string settingFile)
 {
     Setting = new CANSetting(settingFile);
 }