Subversion Repositories HomeAutomation

Rev

Rev 1606 | Rev 1939 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed

Rev 1606 Rev 1642
Line 74... Line 74...
74
            }
74
            }
75
            else
75
            else
76
            {
76
            {
77
                line += "??";
77
                line += "??";
78
            }
78
            }
-
 
79
        }
-
 
80
       
-
 
81
        line += " " + payload->GetCommandName() + " ";
-
 
82
       
-
 
83
        while (line.length() < 20)
-
 
84
        {
-
 
85
            line += " ";
-
 
86
        }
-
 
87
       
-
 
88
        if (payload->GetClassName() == "nmt")
-
 
89
        {
-
 
90
            line += "-";
-
 
91
        }
79
           
92
        else
-
 
93
        {
80
            line += " " + payload->GetClassName();
94
            line += payload->GetClassName();
81
            line += "_" + payload->GetModuleName();
95
            line += "_" + payload->GetModuleName();
82
            line += ":" + boost::lexical_cast<std::string>(payload->GetId());
96
            line += ":" + boost::lexical_cast<std::string>(payload->GetId());
83
        }
97
        }
-
 
98
       
-
 
99
        while (line.length() < 40)
-
 
100
        {
-
 
101
            line += " ";
-
 
102
        }
84
       
103
       
85
        line += " CMD=" + payload->GetCommandName() + " ";
104
        while (line.length() < 20)
-
 
105
        {
-
 
106
            line += " ";
-
 
107
        }
86
       
108
       
87
        type::StringMap variables = payload->GetVariables();
109
        common::StringMap variables = payload->GetVariables();
88
       
110
       
89
        for (type::StringMap::iterator it = variables.begin(); it != variables.end(); it++)
111
        for (common::StringMap::iterator it = variables.begin(); it != variables.end(); it++)
90
        {
112
        {
91
            if (it->second != "")
113
            if (it->second != "")
92
            {
114
            {
93
                line += " " + it->first + "=" + it->second;
115
                line += " " + it->first + "=" + it->second;
94
            }
116
            }
95
        }
117
        }
96
       
118
       
97
        line += "\n";
119
        line += "\n";
98
       
120
       
99
        net::Manager::Instance()->SendToAll(this->server_id_, type::Byteset(line));
121
        net::Manager::Instance()->SendToAll(this->server_id_, common::Byteset(line));
100
    }
122
    }
101
}
123
}
102
 
124
 
103
void Monitor::SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, type::Byteset data)
125
void Monitor::SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, common::Byteset data)
104
{
126
{
105
    if (server_id != this->server_id_)
127
    if (server_id != this->server_id_)
106
    {
128
    {
107
        return;
129
        return;
108
    }
130
    }
Line 132... Line 154...
132
        LOG.Info("Client " + boost::lexical_cast<std::string>(client_id) + " has disconnected.");
154
        LOG.Info("Client " + boost::lexical_cast<std::string>(client_id) + " has disconnected.");
133
    }
155
    }
134
    else if (client_state == net::CLIENT_STATE_CONNECTED)
156
    else if (client_state == net::CLIENT_STATE_CONNECTED)
135
    {
157
    {
136
        LOG.Info("Client " + boost::lexical_cast<std::string>(client_id) + " has connected.");
158
        LOG.Info("Client " + boost::lexical_cast<std::string>(client_id) + " has connected.");
137
        net::Manager::Instance()->SendTo(client_id, type::Byteset("Welcome to Atom CAN monitoring\n"));
159
        net::Manager::Instance()->SendTo(client_id, common::Byteset("Welcome to Atom CAN monitoring\n"));
138
    }
160
    }
139
    else
161
    else
140
    {
162
    {
141
        LOG.Debug("Got state: " + boost::lexical_cast<std::string>((int)client_state));
163
        LOG.Debug("Got state: " + boost::lexical_cast<std::string>((int)client_state));
142
    }
164
    }