コード例 #1
0
        public static string StateToString(ChannelState state)
        {
            var stateStr = state.ToString();
            var temp     = "CS_" + char.ToUpper(stateStr[0]);

            for (var i = 1; i < stateStr.Length; i++)
            {
                if (char.IsUpper(stateStr[i]))
                {
                    temp += stateStr[i] + "_";
                }
                else
                {
                    temp += char.ToUpper(stateStr[i]);
                }
            }

            return(temp);
        }
コード例 #2
0
            void IChannelListener.OnStateChange(ChannelState state)
            {
                Log(dnp3conn.name + " - Channel State: " + state.ToString());
                if (state == ChannelState.OPEN)
                {
                    dnp3conn.isConnected = true;
                }
                else
                {
                    dnp3conn.isConnected = false;
                }

                if (state == ChannelState.CLOSED)
                {
                    // Ivalidate points on connection if disconnected
                    var Client     = ConnectMongoClient(JSConfig);
                    var DB         = Client.GetDatabase(JSConfig.mongoDatabaseName);
                    var collection = DB.GetCollection <rtData>(RealtimeDataCollectionName);
                    foreach (DNP3_connection srv in DNP3conns)
                    {
                        if (srv.channel == dnp3conn.channel) // all connections on the same channel
                        {
                            srv.isConnected = dnp3conn.isConnected;
                            if (dnp3conn.isConnected == false)
                            {
                                // update as invalid
                                Log("Invalidating points on connection " + srv.protocolConnectionNumber);
                                var filter =
                                    new BsonDocument(new BsonDocument("protocolSourceConnectionNumber",
                                                                      srv.protocolConnectionNumber));
                                var update =
                                    new BsonDocument("$set", new BsonDocument {
                                    { "invalid", true },
                                    { "timeTag", BsonValue.Create(DateTime.Now) },
                                });
                                var res = collection.UpdateManyAsync(filter, update);
                            }
                        }
                    }
                }
            }
コード例 #3
0
        string ChannelStateToString(ChannelState state)
        {
            switch (state)
            {
            case ChannelState.Idle:
                return("Idle");

            case ChannelState.Connecting:
                return("Connecting");

            case ChannelState.Ready:
                return("Ready");

            case ChannelState.TransientFailure:
                return("TransientFailure");

            case ChannelState.Shutdown:
                return("Shutdown");

            default:
                return(state.ToString());
            }
        }
コード例 #4
0
        public static string StateToString(ChannelState state)
        {
            var stateStr = state.ToString();
            var temp = "CS_" + char.ToUpper(stateStr[0]);
            for (var i = 1; i < stateStr.Length; i++)
            {
                if (char.IsUpper(stateStr[i]))
                    temp += stateStr[i] + "_";
                else
                    temp += char.ToUpper(stateStr[i]);
            }

            return temp;
        }