Beispiel #1
0
        public void UpdateSwitchSettings(
            string forAlliance,
            string lhsAlliance,
            string rhsAlliance,
            string ipAddress
            )
        {
            Alliance alliance = Alliance.Parse(forAlliance);

            switch (alliance.Is)
            {
            case Alliance.Red:
            {
                _redSwitchSettings = new SwitchSettings(lhsAlliance, rhsAlliance, forAlliance, ipAddress);
                break;
            }

            case Alliance.Blue:
            {
                _blueSwitchSettings = new SwitchSettings(lhsAlliance, rhsAlliance, forAlliance, ipAddress);
                break;
            }
            }
            lock (_padlock)
            {
                _updatesRemaining -= 1;
            }
        }
Beispiel #2
0
 public Switch(SwitchSettings switchSettings)
 {
     Alliance               = switchSettings.Alliance;
     LHSPlate               = new Plate(switchSettings.LHSAlliance, false); // TODO: Read current state
     RHSPlate               = new Plate(switchSettings.RHSAlliance, false); // TODO: Read current state
     httpClient             = new HttpClient();
     httpClient.BaseAddress = new Uri($"http://{switchSettings.IP.ToString()}:80/");
     httpClient.DefaultRequestHeaders.Accept.Clear();
     httpClient.DefaultRequestHeaders.Accept.Add(
         new MediaTypeWithQualityHeaderValue("application/x-www-form-urlencoded"));
     LHSPlate.Owned   += Plate_Owned;
     RHSPlate.Owned   += Plate_Owned;
     LHSPlate.Unowned += Plate_Unowned;
     RHSPlate.Unowned += Plate_Unowned;
 }