Beispiel #1
0
 public System.Collections.Generic.Dictionary <int, System.Collections.Generic.List <int> > TurnOffDeviceOutlets()
 {
     this.devMap.Clear();
     foreach (DevSnmpConfig current in this.devsnmpconfigs)
     {
         this.cfg     = DevAccessCfg.GetInstance();
         this.snmpCfg = current;
         this.sc      = this.cfg.getSnmpConfig(this.snmpCfg);
         this.mc      = this.cfg.getDeviceModelConfig(this.snmpCfg.modelName, this.snmpCfg.fmwareVer);
         if (this.mc.switchable == 2)
         {
             this.se = new DefaultSnmpExecutor(new SnmpConfiger(this.sc, this.mc));
             bool flag = this.se.TurnOffOutlets();
             if (flag)
             {
                 for (int i = 1; i <= this.mc.portNum; i++)
                 {
                     current.groupOutlets.Add(i);
                 }
                 this.devMap.Add(current.devID, current.groupOutlets);
             }
         }
     }
     return(this.devMap);
 }
Beispiel #2
0
 public AbstractSnmpSession(SnmpConfig config)
 {
     if (config == null)
     {
         throw new System.ArgumentNullException("SnmpConfig is null");
     }
     this.config = config;
 }
Beispiel #3
0
 public DevAccessAPI(DevSnmpConfig snmpSettings)
 {
     this.cfg     = DevAccessCfg.GetInstance();
     this.snmpCfg = snmpSettings;
     this.sc      = this.cfg.getSnmpConfig(this.snmpCfg);
     this.mc      = this.cfg.getDeviceModelConfig(this.snmpCfg.modelName, this.snmpCfg.fmwareVer);
     this.se      = new DefaultSnmpExecutor(new SnmpConfiger(this.sc, this.mc));
 }
 public static SnmpSession CreateSession(SnmpConfig config)
 {
     if (config is SnmpV3Config)
     {
         return(new SnmpV3Session((SnmpV3Config)config));
     }
     if (config is SnmpV2Config)
     {
         return(new SnmpV2Session((SnmpV2Config)config));
     }
     return(new SnmpV1Session((SnmpV1Config)config));
 }
Beispiel #5
0
 public SnmpConfiger(SnmpConfig snmpConfig, DevModelConfig modelCfg)
 {
     this.snmpConfig     = snmpConfig;
     this.modelConfig    = modelCfg;
     this.portnumber     = modelCfg.portNum;
     this.deviceModel    = modelCfg.modelName;
     this.switchable     = modelCfg.switchable;
     this.sensornumber   = modelCfg.sensorNum;
     this.banknumber     = modelCfg.bankNum;
     this.linenumber     = modelCfg.lineNum;
     this.perportreading = modelCfg.perportreading;
     this.perbankreading = modelCfg.perbankReading;
     this.perdoorreading = modelCfg.doorReading;
 }
Beispiel #6
0
 public SnmpConfiger(SnmpConfig snmpConfig, DevModelConfig modelCfg, string devMac, int devID, DevRealConfig realCfg)
 {
     this.snmpConfig     = snmpConfig;
     this.modelConfig    = modelCfg;
     this.deviceModel    = modelCfg.modelName;
     this.switchable     = modelCfg.switchable;
     this.realConfig     = realCfg;
     this.portnumber     = realCfg.portNum;
     this.banknumber     = realCfg.bankNum;
     this.linenumber     = realCfg.lineNum;
     this.sensornumber   = realCfg.sensorNum;
     this.perdoorreading = realCfg.contactNum;
     this.perportreading = modelCfg.perportreading;
     this.perbankreading = modelCfg.perbankReading;
     this.deviceMac      = devMac;
     this.deviceID       = devID;
 }
Beispiel #7
0
        public SnmpConfig getSnmpConfig(DevSnmpConfig snmpCfg)
        {
            SnmpConfig snmpConfig = null;

            switch (snmpCfg.snmpVer)
            {
            case 0:
                snmpConfig = new SnmpV1Config(snmpCfg.devIP);
                ((SnmpV1Config)snmpConfig).Community = snmpCfg.userName;
                ((SnmpV1Config)snmpConfig).Retry     = snmpCfg.retry;
                ((SnmpV1Config)snmpConfig).Port      = snmpCfg.devPort;
                ((SnmpV1Config)snmpConfig).Timeout   = snmpCfg.timeout;
                break;

            case 1:
                snmpConfig = new SnmpV2Config(snmpCfg.devIP);
                ((SnmpV2Config)snmpConfig).Community = snmpCfg.userName;
                ((SnmpV2Config)snmpConfig).Retry     = snmpCfg.retry;
                ((SnmpV2Config)snmpConfig).Port      = snmpCfg.devPort;
                ((SnmpV2Config)snmpConfig).Timeout   = snmpCfg.timeout;
                break;

            case 3:
                snmpConfig         = new SnmpV3Config(snmpCfg.devIP);
                snmpConfig.Retry   = snmpCfg.retry;
                snmpConfig.Timeout = snmpCfg.timeout;
                snmpConfig.Port    = snmpCfg.devPort;
                ((SnmpV3Config)snmpConfig).Authentication = (Authentication)System.Enum.Parse(typeof(Authentication), snmpCfg.authType);
                ((SnmpV3Config)snmpConfig).AuthSecret     = snmpCfg.authPSW;
                ((SnmpV3Config)snmpConfig).Privacy        = (Privacy)System.Enum.Parse(typeof(Privacy), snmpCfg.privType);
                ((SnmpV3Config)snmpConfig).PrivacySecret  = snmpCfg.privPSW;
                ((SnmpV3Config)snmpConfig).UserName       = snmpCfg.userName;
                break;
            }
            return(snmpConfig);
        }
Beispiel #8
0
 public DevDiscoverAPI(DevSnmpConfig snmpSettings)
 {
     this.cfg     = DevAccessCfg.GetInstance();
     this.snmpCfg = snmpSettings;
     this.sc      = this.cfg.getSnmpConfig(this.snmpCfg);
 }
Beispiel #9
0
 public SnmpConfiger(SnmpConfig snmpConfig) : this(snmpConfig, 1)
 {
 }
Beispiel #10
0
 public SnmpConfiger(SnmpConfig snmpConfig, int portNums)
 {
     this.snmpConfig = snmpConfig;
     this.portnumber = portNums;
 }