Exemple #1
0
        private static void station_join(string station, string content)
        {
            if (String.IsNullOrEmpty(content))
            {
                return;
            }
            StationConfig cfg;

            try
            {
                cfg = JsonConvert.DeserializeObject <StationConfig>(content);
            }
            catch (Exception e)
            {
                LogRecorder.Exception(e);
                return;
            }
            cfg.State = StationState.Run;
            if (StationProgram.Configs.ContainsKey(station))
            {
                StationProgram.Configs[station] = cfg;
            }
            else
            {
                StationProgram.Configs.Add(station, cfg);
            }
            if (StationProgram.Stations.ContainsKey(station))
            {
                StationProgram.Stations[station].Config = cfg;
                StationProgram.WriteLine($"{station} is join");
                StationEvent?.Invoke(cfg, new StationEventArgument("station_join", cfg));
                ZeroStation.Run(StationProgram.Stations[station]);
            }
        }
Exemple #2
0
        private static void station_install(string station, string content)
        {
            if (String.IsNullOrEmpty(content))
            {
                return;
            }
            StationConfig cfg;

            try
            {
                cfg = JsonConvert.DeserializeObject <StationConfig>(content);
            }
            catch (Exception e)
            {
                LogRecorder.Exception(e);
                return;
            }
            cfg.State = StationState.None;
            if (StationProgram.Configs.ContainsKey(station))
            {
                StationProgram.Configs[station] = cfg;
            }
            else
            {
                StationProgram.Configs.Add(station, cfg);
            }
            StationEvent?.Invoke(cfg, new StationEventArgument("station_install", cfg));
        }
Exemple #3
0
        public override IItemModelAdapter <IEventModel> CreateDeepCopyOfItemModel(IItemModelAdapter <IEventModel> model)
        {
            StationEvent stationEvent = (StationEvent)model.DataModel;
            var          deepCopy     = stationEvent.Copy();
            var          newModel     = new ItemModelAdapterForPassive <IEventModel>(deepCopy);

            return(newModel);
        }
Exemple #4
0
        public override IEventModel CreateNewDataModel()
        {
            Station nwStation = new Station(0, 0, "Unknown", DateTime.Now, null, "Unknown");
            //nwStation.Save();
            StationEvent nwStationEvent = new StationEvent(nwStation);

            return(nwStationEvent);
        }
Exemple #5
0
 private static void system_stop(string content)
 {
     StationEvent?.Invoke(null, new StationEventArgument("system_stop", null));
     StationProgram.WriteLine(content);
     foreach (var sta in StationProgram.Stations.Values)
     {
         StationProgram.WriteLine($"Close {sta.StationName}");
         sta.Close();
         StationEvent?.Invoke(sta, new StationEventArgument("station_closing", sta.Config));
     }
     StationProgram.Configs.Clear();
 }
Exemple #6
0
        private static void system_start(string content)
        {
            StationProgram.WriteLine(content);
            StationProgram.Configs.Clear();

            StationEvent?.Invoke(null, new StationEventArgument("system_start", null));
            foreach (var sta in StationProgram.Stations.Values)
            {
                StationProgram.WriteLine($"Restart {sta.StationName}");
                ZeroStation.Run(sta);
                StationEvent?.Invoke(sta, new StationEventArgument("station_join", sta.Config));
            }
        }
Exemple #7
0
        private static void station_left(string station)
        {
            if (StationProgram.Configs.TryGetValue(station, out var cfg))
            {
                cfg.State = StationState.Closed;
            }
            if (StationProgram.Stations.ContainsKey(station))
            {
                StationProgram.WriteLine($"{station} is left");
                StationProgram.Stations[station].Close();
            }

            StationEvent?.Invoke(cfg, new StationEventArgument("station_left", cfg));
        }
Exemple #8
0
        private static void station_resume(string station, string content)
        {
            if (StationProgram.Configs.TryGetValue(station, out var cfg))
            {
                cfg.State = StationState.Run;
            }
            if (StationProgram.Stations.ContainsKey(station))
            {
                StationProgram.WriteLine($"{station} is resume");
                ZeroStation.Run(StationProgram.Stations[station]);
            }

            StationEvent?.Invoke(cfg, new StationEventArgument("station_resume", cfg));
        }