You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bluesky-commits@incubator.apache.org by pi...@apache.org on 2009/11/30 11:44:54 UTC
svn commit: r885383 [18/18] - in /incubator/bluesky/trunk/RealClass: DTU/
DTU/autom4te.cache/ DTU/src/ DTU/src/.deps/ Teacher/src/
Added: incubator/bluesky/trunk/RealClass/DTU/src/language_test.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/language_test.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/language_test.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/language_test.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,254 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+#ifndef _LANGUAGE_TEST_H_
+#define _LANGUAGE_TEST_H_
+
+#define LANGUAGE_EN
+
+// Main Frame windows title
+extern char * p_mainframe_WinTitle;
+
+//Toolbar---->menu start
+extern char * p_Toolbar_Menu_Start;
+//Toolbar---->menu start---->type select
+extern char * p_Toolbar_Menu_Start_Type;
+//Toolbar---->menu start---->logon Tserver
+extern char * p_Toolbar_Menu_Start_Logon;
+//Toolbar---->menu start---->logout Tserver
+extern char * p_Toolbar_Menu_Start_Logout;
+//Toolbar---->menu start---->exit system
+extern char * p_Toolbar_Menu_Start_Exit;
+//Toolbar---->settings
+extern char * p_Toolbar_Setting;
+//Toolbar---->settings---->set parameters
+extern char * p_Toolbar_Setting_SetPara;
+//Toolbar---->Class options
+extern char * p_Toolbar_ClassOption;
+//Toolbar---->Class options---->join class
+extern char * p_Toolbar_ClassOption_Join;
+//Toolbar---->Class options---->quit class
+extern char * p_Toolbar_ClassOption_Quit;
+//Toolbar---->Help
+extern char * p_Toolbar_Help;
+//
+//
+//
+// Toolbar
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Graphic buttons
+//
+//
+//Graphic buttons---->set parameters
+extern char * p_GraphButt_SetPara;
+//Graphic buttons---->type select
+extern char * p_GraphButt_TypeSel;
+//Graphic buttons---->logon Tserver
+extern char * p_GraphButt_Logon;
+//Graphic buttons---->logout Tserver
+extern char * p_GraphButt_Logout;
+//Graphic buttons---->join class
+extern char * p_GraphButt_JoinClass;
+//Graphic buttons---->quit class
+extern char * p_GraphButt_QuitClass;
+//
+//
+//
+// Graphic buttons
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Table
+//
+// Transmit Node List
+//
+//
+//
+//Transmit Node List members---->Transmit Node ID
+extern char * p_TranNodeListMem_ID;
+//Transmit Node List members---->Transmit Node IP
+extern char * p_TranNodeListMem_IP;
+//Transmit Node List members---->Teacher screen port
+extern char * p_TranNodeListMem_TeacherScrPort;
+//Transmit Node List members---->Teacher video port
+extern char * p_TranNodeListMem_TeacherVideoPort;
+//Transmit Node List members---->Teacher audio port
+extern char * p_TranNodeListMem_TeacherAudioPort;
+//Transmit Node List members---->Students video port
+extern char * p_TranNodeListMem_StuVideoPort;
+//Transmit Node List members---->Students audio port
+extern char * p_TranNodeListMem_StuAudioPort;
+//Transmit Node List Buttons---->Refresh list
+extern char * p_TranNodeList_Butt_Refresh;
+//Transmit Node List Title
+extern char * p_TranNodeList_Title;
+//
+//
+//
+// Transmit Node List
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Table
+//
+// Transmit State List
+//
+//
+//
+//Transmit State List---->lable class name
+extern char * p_TranStateList_labClassName;
+//Transmit State List---->lable teacher name
+extern char * p_TranStateList_labTeacherName;
+//Transmit State List members---->Port ID
+extern char * p_TranStateListMem_PortID;
+//Transmit State List members---->Port Number
+extern char * p_TranStateListMem_PortNum;
+//Transmit State List members---->Instant bandwidth
+extern char * p_TranStateListMem_InsBW;
+//Transmit State List members---->Average bandwidth
+extern char * p_TranStateListMem_AvgBW;
+//Transmit State List members---->Transmit channel number
+extern char * p_TranStateListMem_ChNum;
+//Transmit State List members---->Data packets number
+extern char * p_TranStateListMem_PacketNum;
+//Transmit State List members---->Data packets size
+extern char * p_TranStateListMem_PacketSize;
+//Transmit State List---->Table title
+extern char * p_TranStateList_TabTitle;
+//
+//
+//
+// Transmit State List
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Table
+//
+// MCU System Log
+//
+//
+//
+//MCU System Log---->Buttons---->Clear
+extern char * p_McuSysLog_Butt_Clr;
+//MCU System Log---->Table Title
+extern char * p_McuSysLog_TabTitle;
+//
+//
+//
+// MCU System Log
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Dialog
+//
+// MCU Set Parameter
+//
+//
+//
+//MCU Set Parameter Dialog---->windows title
+extern char * p_McuSetPara_WinTitle;
+//MCU Set Parameter Dialog---->Lable---->class server address
+extern char * p_McuSetPara_Lable_ClassServerIP;
+//MCU Set Parameter Dialog---->Lable---->class server port
+extern char * p_McuSetPara_Lable_ClassServerPort;
+//MCU Set Parameter Dialog---->Lable---->mcu server address
+extern char * p_McuSetPara_Lable_McuServerIP;
+//MCU Set Parameter Dialog---->Lable---->mcu server send port
+extern char * p_McuSetPara_Lable_McuServerSendPort;
+//MCU Set Parameter Dialog---->Button comments---->For professional user only
+extern char * p_McuSetPara_ButtComm_Advanced;
+//MCU Set Parameter Dialog---->Buttons---->Advanced
+extern char * p_McuSetPara_Butt_Advanced;
+//MCU Set Parameter Dialog---->Buttons---->Cancel
+extern char * p_McuSetPara_Butt_Cancel;
+//MCU Set Parameter Dialog---->Buttons---->OK
+extern char * p_McuSetPara_Butt_OK;
+//
+//
+//
+// MCU Set Parameter
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Dialog
+//
+// MCU Type Select
+//
+//
+//
+//Mcu Type Select Dialog---->windows title
+extern char * p_McuTypeSel_WinTitle;
+//Mcu Type Select Dialog---->radio label---->main mcu
+extern char * p_McuTypeSel_RadioLab_MainMcu;
+//Mcu Type Select Dialog---->radio label---->assist mcu
+extern char * p_McuTypeSel_RadioLab_AssistMcu;
+//Mcu Type Select Dialog---->Buttons---->cancel
+extern char * p_McuTypeSel_Button_Cancel;
+//Mcu Type Select Dialog---->Buttons---->OK
+extern char * p_McuTypeSel_Button_OK;
+//
+//
+//
+// MCU Type Select
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Dialog
+//
+// MCU User login
+//
+//
+//
+//MCU User Logon Dialog---->windows title
+extern char * p_McuUserLogon_WinTitle;
+//MCU User Logon Dialog---->Label---->User name
+extern char * p_McuUserLogon_Label_UserName;
+//MCU User Logon Dialog---->Label---->Password
+extern char * p_McuUserLogon_Label_Password;
+//MCU User Login Dialog---->Buttons---->Cancel
+extern char * p_McuUserLogon_Button_Cancel;
+//MCU User Login Dialog---->Buttons---->OK
+extern char * p_McuUserLogon_Button_OK;
+//
+//
+//
+// MCU User login
+/////////////////////////////////////////////////////////
+/////////////////////////////////////////////////////////
+//
+// Dialog
+//
+// Class Select
+//
+//
+//
+//Class Select Dialog---->windows title
+extern char * p_ClassSel_WinTitle;
+//Class Select---->Class list memeber---->Class ID
+extern char * p_ClassSel_ClasslistMem_ClassID;
+//Class Select---->Class list memeber---->Class Name
+extern char * p_ClassSel_ClasslistMem_ClassName;
+//Class Select---->Class list memeber---->Teacher Name
+extern char * p_ClassSel_ClasslistMem_TecherName;
+//Class Select---->Buttons---->Refresh class list
+extern char * p_ClassSel_Butt_Refresh;
+//Class Select---->Buttons---->Cancel
+extern char * p_ClassSel_Butt_Cancel;
+//Class Select---->Buttons---->OK Join
+extern char * p_ClassSel_Butt_OKJoin;
+#endif
Added: incubator/bluesky/trunk/RealClass/DTU/src/mcu_para.conf
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/mcu_para.conf?rev=885383&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/bluesky/trunk/RealClass/DTU/src/mcu_para.conf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/bluesky/trunk/RealClass/DTU/src/mcu_setpara.conf
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/mcu_setpara.conf?rev=885383&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/bluesky/trunk/RealClass/DTU/src/mcu_setpara.conf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/bluesky/trunk/RealClass/DTU/src/mcu_userpara.conf
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/mcu_userpara.conf?rev=885383&view=auto
==============================================================================
Binary file - no diff available.
Propchange: incubator/bluesky/trunk/RealClass/DTU/src/mcu_userpara.conf
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: incubator/bluesky/trunk/RealClass/DTU/src/mcumessage.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/mcumessage.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/mcumessage.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/mcumessage.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,316 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+#include "stdafx.h"
+
+#ifndef MCUMESSAGE_H
+#define MCUMESSAGE_H
+
+#define MAXLENGTH 200 //also should modify macro defined in interface.h
+
+//æ¥æ¶åéæ¶æ¯ç»æ
+struct CRCLMSG
+{
+ DWORD rclType;//æ¶æ¯ç±»å
+ DWORD msglen;//æ¶æ¯å
容é¿åº¦s
+ char msg[10000];//æ¶æ¯å
容
+};
+
+//ç»å
客æ·ä¿¡æ¯ç»æ
+struct CClientInfo
+{
+ DWORD ClientID;
+ char ClienName[MAXLENGTH]; //[16];
+ DWORD IsFocus; //0表示æ£å¨äº¤äºï¼1没æ交äº
+};
+
+//ç»ä¿¡æ¯
+struct CGroupInfo
+{
+ DWORD GroupID; //ç»ID
+ char GroupName[128]; //ç»çå称
+ char TeacherName[MAXLENGTH];//[16]; //æå¸å称
+};
+
+
+
+//以ä¸å
æ¬å
·ä½æ¶æ¯
+
+//MCUç»éæ¶æ¯
+//ID : 5010
+struct CRCLMCULogin
+{
+ char MCUName[MAXLENGTH];//[16]; //MCUç¨æ·å
+ char MCUPass[16];//[16]; //MCUå£ä»¤
+ char MCUIP[16]; //MCUæ¬æºè·å¾çIP å
¬ç½IPå°å
+ char MCUPIP[16];//MCUæ¬æºè·å¾çIP ä¸ç½IPå°å
+ DWORD TAPort; //é³é¢ç«¯å£ï¼MCUæ¥æ¶ç¨ï¼ä»¥ä¸å
+ DWORD TVPort; //è§é¢ç«¯å£
+ DWORD TSPort; //å±å¹ç«¯å£
+ DWORD CAPort; //ç¦ç¹é³é¢ç«¯å£
+ DWORD CVPort; //ç¦ç¹è§é¢ç«¯å£
+};
+
+//ååºæ¶æ¯
+//ID : 5011
+struct CRCLMCULoginR
+{
+ DWORD ResponseType;
+ DWORD MCUID; //MCU ID
+};
+
+
+//è¾
MCUç»éæ¶æ¯
+//ID : 5060
+struct CRLCSeMCULogin
+{
+ char MCUName[MAXLENGTH]; //[16];
+ char MCUPass[16];//[16];
+ char MCULocalIP[16];
+ DWORD TAPort; //é³é¢ç«¯å£ï¼MCUæ¥æ¶ç¨ï¼ä»¥ä¸å
+ DWORD TVPort; //è§é¢ç«¯å£
+ DWORD TSPort; //å±å¹ç«¯å£
+ DWORD CAPort; //ç¦ç¹é³é¢ç«¯å£
+ DWORD CVPort; //ç¦ç¹è§é¢ç«¯å£
+};
+
+//ååºæ¶æ¯
+//ID : 5061
+struct CRCLSeMCULoginR
+{
+ DWORD ResponseType;
+ DWORD MCUID;
+ DWORD MCUType; //0:å¤ç½ 1:å
ç½
+};
+
+
+///////////////////////////端ç¹éåºæ¶æ¯///////////////////////////////////
+
+//MCUéåºæ¶æ¯
+//ID : 5040
+struct CRCLMCULogout
+{
+ DWORD MCUID;
+};
+
+//è¾
MCUéåºæ¶æ¯
+//ID : 5070
+struct CRCLSeMCULogout
+{
+ DWORD MCUID;
+};
+
+
+
+
+
+//////////////////////////////////////////////////////////////////////////
+///////////////////////////ç»æä½æ¶æ¯/////////////////////////////////////
+
+//æ课端å建ç»æ¶æ¯
+//ååºæ¶æ¯Bï¼ç»MCUï¼å 为åªæMCUåå¨æå¯ä»¥å建ç»
+//ID : 10002
+struct CRCLCreateGroupRMCU
+{
+ DWORD GroupID;
+ DWORD TeacherID; //æå¸ID
+ char TeacherIP[16]; //æå¸çIPï¼è¦ç»æå¸ç¦ç¹è§é³é¢
+ DWORD CAPort; //é³é¢ç«¯å£
+ DWORD CVPort; //è§é¢ç«¯å£
+ char GroupName[128]; //æ¹ç»å称
+};
+
+
+//æ课端离å¼ç»æ¶æ¯ï¼è¯¥ç»æåå°±åºå
¨é¨éåº
+//ååºæ¶æ¯Bï¼ç»MCU
+//ID : 10012
+struct CRCLDestroyGroupRClient
+{
+ DWORD GroupID; //åæ¢è½¬å
+};
+
+
+//ç»å
客æ·ä¿¡æ¯ç»æ
+
+//ååºæ¶æ¯Cï¼ç»ä¸»MCUè¿ååç»éæ¥ç¹çä¿¡æ¯
+//ID : 10023
+struct CRCLClientJoinInGroupRMCU
+{
+ //DWORD ClientID;
+ char ClientIP[16]; //å¬è¯¾ç«¯IPæSemcuIP
+ //å¬è¯¾ç«¯æè¾
MCUç5路端å£
+
+ DWORD TAPort;
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+
+
+ CClientInfo ClientInfo;
+ //DWORD IfSeMCU;
+ DWORD ClientType; //0:å
¬ç½ 1ï¼å
ç½
+};
+
+//ååºæ¶æ¯Dï¼ç»è¾
MCUè¿ååç»éçå
ç½å¬è¯¾ç«¯çä¿¡æ¯
+//ID : 10024
+struct CRCLClientJoinInGroupRSeMCU
+{
+ DWORD ClientID;
+ char ClientIP[16];
+ //åå¬è¯¾ç«¯5路端å£
+ DWORD TAPort;
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+
+};
+
+//客æ·ç¦»å¼ç»æ¶æ¯
+//ååºæ¶æ¯Cï¼ç»MCU 10032
+//ID : 10033
+struct CRCLClientLeaveGroupRAll
+{
+ CClientInfo ClientInfo; //离å¼ç¨æ·çä¿¡æ¯
+};
+
+
+//MCU离å¼ç»æ¶æ¯
+//ID : 10040
+struct CRCLMCULeaveGroup
+{
+ DWORD MCUID; //MCU ID
+ DWORD GroupID; //ç»ID
+};
+
+//ååºæ¶æ¯
+//ID : 10041
+struct CRCLMCULeaveGroupR
+{
+ DWORD ResponseType;
+};
+
+//è¾
MCUè·å¾å½åç»ä¿¡æ¯
+//ID : 10060
+struct CRCLSeMCUGetGroupInfo
+{
+ DWORD SeMCUID;
+};
+
+//ååºæ¶æ¯
+//ID : 10061
+struct CRCLSeMCUGetGroupInfoR
+{
+ DWORD ResponseType;
+ DWORD GroupCount;
+ CGroupInfo GroupList[10];
+};
+
+//è¾
MCUå å
¥ç»æ¶æ¯
+//ID : 10070
+struct CRCLSeMCUJoinGroup
+{
+ DWORD SeMCUID;
+ DWORD GroupID;
+};
+
+//ååºæ¶æ¯A
+//ID : 10071
+struct CRCLSeMCUJoinGroupR
+{
+ DWORD ResponseType;
+ DWORD GroupID;//ä¹è¿åç»ID
+ char MCUIP[16];//主MCUçIPå°å
+// char SeMCUIP[16];//è¾
MCUçIPå°å
+ DWORD TAPort; //主MCUçæ°æ®æ¥æ¶ç«¯å£
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+
+// DWORD IfSeMCU;
+
+};
+
+//ååºæ¶æ¯Bï¼åç»ä¸»MCU
+//ID : 10072
+struct CRCLSeMCUJoinGroupRToMCU
+{
+ DWORD SeMCUID;//è¾
MCUçID
+ char SeMCUIP[16];//è¾
MCUçIP
+ DWORD SeMCUType;//è¾
MCUçç±»åï¼0:å
¬ç½ 1:å
ç½
+ DWORD TAPort;//è¾
MCUçæ°æ®æ¥æ¶ç«¯å£
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+};
+
+//seMCU离å¼ç»æ¶æ¯
+//ID : 10080
+struct CRCLSeMCULeaveGroup
+{
+ DWORD SeMCUID;
+ DWORD GroupID;
+};
+
+//ååºæ¶æ¯A
+//ID : 10081
+struct CRCLSeMCULeaveGroupR
+{
+ DWORD ResponseType;
+};
+
+//ååºæ¶æ¯Cï¼åéç»ä¸»MCUï¼éç¥å
¶åæ¢ç»è¾
MCU转å
+//ID : 10083
+struct CRCLSeMCULeaveGroupRToMCU
+{
+ DWORD SeMCUID;
+};
+
+/////////////////////////ç»å
æä½æ¶æ¯/////////////////////////////////////
+
+//ååºæ¶æ¯ åéç¦ç¹ä¿¡æ¯ç»MCUåæå¸
+//ID : 1012
+struct CRCLClientApplyFocusRToTM
+{
+ DWORD FocusClientID;
+};
+
+//ååºæ¶æ¯ åéæ¤éç¦ç¹æ¶æ¯ç»MCUåTeacher
+//ID : 1022
+struct CRCLClientDestroyFocusRToTM
+{
+ DWORD FocusClientID;
+};
+
+//æ课端æå®ç¦ç¹æ¶æ¯
+//ååºæ¶æ¯ éç¥MCUåæå®ç客æ·ç«¯æ为ç¦ç¹
+struct CRCLTeacherAllowClientFocusRToMS
+{
+ DWORD ClientID;
+};
+
+//æ课端å¥å¤ºç¦ç¹æ¶æ¯
+//ååºæ¶æ¯ éç¥MCUåç¦ç¹å¦çæ¤éç¦ç¹
+//ID : 1062
+struct CRCLTeacherCancelClientFocusRToMS
+{
+ DWORD ClientID;
+};
+
+#endif
Added: incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.cpp?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.cpp (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.cpp Mon Nov 30 11:44:51 2009
@@ -0,0 +1,129 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+// CSingleComm.cpp: implementation of the CSingleComm class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "asyncsocketex.h"
+#include "singlecomm.h"
+
+#define SOCKETMUTEX_LOCK {\
+ socketmutex.Lock(); \
+ }
+
+
+#define SOCKETMUTEX_UNLOCK { \
+ socketmutex.Unlock();}
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CSingleComm::CSingleComm()
+{
+
+ m_socket = 0;
+}
+
+CSingleComm::~CSingleComm()
+{
+
+ m_socket = 0;
+}
+
+bool CSingleComm::Init()
+{
+ if(!CTCPComm::Init())
+ return false;
+
+ if (!socketmutex.IsInitialized())
+ {
+ if (socketmutex.Init() < 0)
+ return false;
+ }
+
+ return true;
+}
+
+int CSingleComm::OnPollThreadError(int status)
+{
+
+ return -1;
+}
+
+int CSingleComm::Poll()
+{
+ int nRes;
+ SOCKETMUTEX_LOCK
+
+ if(m_socket == 0){
+ SOCKETMUTEX_UNLOCK
+ return 0;
+ }
+
+ nRes = m_socket->Poll();
+ if(nRes < 0){
+ SOCKETMUTEX_UNLOCK
+ return nRes;
+ }
+
+ m_socket->SetStatus(nRes);
+
+ SOCKETMUTEX_UNLOCK
+ return nRes;
+}
+
+int CSingleComm::PolledSocket()
+{
+
+ SOCKETMUTEX_LOCK
+
+ if(m_socket == 0){
+ SOCKETMUTEX_UNLOCK
+ return 0;
+ }
+
+ m_socket->OnEvent();
+
+ SOCKETMUTEX_UNLOCK
+ return 1;
+}
+
+
+void CSingleComm::Attach(CAsyncSocketEx* socket)
+{
+ SOCKETMUTEX_LOCK
+
+ m_socket = socket;
+ SOCKETMUTEX_UNLOCK
+}
+
+CAsyncSocketEx* CSingleComm::Detach()
+{
+ SOCKETMUTEX_LOCK
+ CAsyncSocketEx* p = m_socket;
+ m_socket = 0;
+ SOCKETMUTEX_UNLOCK
+ return p;
+}
+
+void CSingleComm::OnPollThreadStep()
+{
+ //¸øÖ÷Ï̷߳ÃÎÊ socketµÄʱ¼ä.
+// printf("\nCListenComm sleep(1)");
+ usleep(200000);
+}
Added: incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/singlecomm.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,47 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+// CSingleComm.h: interface for the CSingleComm class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(SINGLECOMM_H)
+#define SINGLECOMM_H
+
+#include <jmutex.h>
+#include "tcpcomm.h"
+
+class CSingleComm : public CTCPComm
+{
+public:
+ CAsyncSocketEx* Detach();
+ void Attach(CAsyncSocketEx* socket);
+ CSingleComm();
+ virtual ~CSingleComm();
+ virtual bool Init();
+
+protected:
+ virtual void OnPollThreadStep();
+ virtual int OnPollThreadError(int status);
+ virtual int PolledSocket();
+ virtual int Poll() ;
+
+private:
+ JMutex socketmutex;
+ CAsyncSocketEx* m_socket;
+};
+
+#endif // !defined(SINGLECOMM_H)
Added: incubator/bluesky/trunk/RealClass/DTU/src/stdafx.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/stdafx.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/stdafx.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/stdafx.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,57 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+
+// stdafx.h : include file for standard system include files,
+// or project specific include files that are used frequently, but
+// are changed infrequently
+//
+
+#if !defined(STDAFX_H_LINUX)
+#define STDAFX_H_LINUX
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <sys/ioctl.h>
+ #include <net/if.h>
+ #include <string.h>
+ #include <netdb.h>
+ #include <unistd.h>
+ #include <stdio.h>
+
+
+ #define RTPSOCKERR -1
+
+
+
+// #define FALSE false
+// #define TRUE true
+ #define INVALID_SOCKET 0
+ #define SOCKET_ERROR RTPSOCKERR
+
+ #define IOCTL ioctl
+ #define CLOSESOCKET(x) close(x);
+
+ typedef int SOCKET;
+ typedef sockaddr SOCKADDR;
+ typedef struct sockaddr_in SOCKADDR_IN;
+ typedef bool BOOL;
+ typedef unsigned int UINT;
+ typedef const char* LPCTSTR;
+ typedef char* LPSTR;
+ typedef unsigned long DWORD;
+ typedef struct hostent HOSTENT, *LPHOSTENT;
+#endif // !defined(STDAFX_H_LINUX)
Added: incubator/bluesky/trunk/RealClass/DTU/src/support.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/support.cpp?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/support.cpp (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/support.cpp Mon Nov 30 11:44:51 2009
@@ -0,0 +1,116 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <string.h>
+#include <stdio.h>
+
+#include <gtk/gtk.h>
+
+#include "support.h"
+
+
+static GList *pixmaps_directories = NULL;
+
+/* Use this function to set the directory containing installed pixmaps. */
+void
+add_pixmap_directory (const gchar *directory)
+{
+ pixmaps_directories = g_list_prepend (pixmaps_directories,
+ g_strdup (directory));
+}
+
+/* This is an internally used function to find pixmap files. */
+static gchar*
+find_pixmap_file (const gchar *filename)
+{
+ GList *elem;
+
+ /* We step through each of the pixmaps directory to find it. */
+ elem = pixmaps_directories;
+ while (elem)
+ {
+ gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
+ G_DIR_SEPARATOR_S, filename);
+ if (g_file_test (pathname, G_FILE_TEST_EXISTS))
+ return pathname;
+ g_free (pathname);
+ elem = elem->next;
+ }
+ return NULL;
+}
+
+/* This is an internally used function to create pixmaps. */
+GtkWidget*
+create_pixmap (GtkWidget *widget,
+ const gchar *filename)
+{
+ gchar *pathname = NULL;
+ GtkWidget *pixmap;
+
+ if (!filename || !filename[0])
+ return gtk_image_new ();
+
+ pathname = find_pixmap_file (filename);
+
+ if (!pathname)
+ {
+ g_warning ("Couldn't find pixmap file: %s", filename);
+ return gtk_image_new ();
+ }
+
+ pixmap = gtk_image_new_from_file (pathname);
+ g_free (pathname);
+ return pixmap;
+}
+
+/* This is an internally used function to create pixmaps. */
+GdkPixbuf*
+create_pixbuf (const gchar *filename)
+{
+ gchar *pathname = NULL;
+ GdkPixbuf *pixbuf;
+ GError *error = NULL;
+
+ if (!filename || !filename[0])
+ return NULL;
+
+ pathname = find_pixmap_file (filename);
+
+ if (!pathname)
+ {
+ g_warning ("Couldn't find pixmap file: %s", filename);
+ return NULL;
+ }
+
+ pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
+ if (!pixbuf)
+ {
+ fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
+ pathname, error->message);
+ g_error_free (error);
+ }
+ g_free (pathname);
+ return pixbuf;
+}
+
+
Added: incubator/bluesky/trunk/RealClass/DTU/src/support.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/support.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/support.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/support.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,37 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <gtk/gtk.h>
+
+/* Use this function to set the directory containing installed pixmaps. */
+void add_pixmap_directory (const gchar *directory);
+
+
+/*
+ * Private Functions.
+ */
+
+/* This is used to create the pixmaps used in the interface. */
+GtkWidget* create_pixmap (GtkWidget *widget,
+ const gchar *filename);
+
+/* This is used to create the pixbufs used in the interface. */
+GdkPixbuf* create_pixbuf (const gchar *filename);
+
Added: incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.cpp?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.cpp (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.cpp Mon Nov 30 11:44:51 2009
@@ -0,0 +1,86 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+// TCPComm.cpp: implementation of the CTCPComm class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#include "stdafx.h"
+#include "asyncsocketex.h"
+#include "tcpcomm.h"
+#include "tcppollthread.h"
+
+//////////////////////////////////////////////////////////////////////
+// Construction/Destruction
+//////////////////////////////////////////////////////////////////////
+
+CTCPComm::CTCPComm()
+{
+
+ m_pThread = 0;
+}
+
+CTCPComm::~CTCPComm()
+{
+
+}
+
+
+int CTCPComm::OnPollThreadError(int status)
+{
+ return -1;
+}
+
+bool CTCPComm::Init()
+{
+
+ if(m_pThread){
+ m_pThread->Stop();
+ return true;
+ }
+
+ m_pThread = new CTCPPollThread(this);
+
+ if(m_pThread)
+ return true;
+
+ return false;
+}
+
+int CTCPComm::Start()
+{
+ if(m_pThread == 0){
+ return -1;
+ }
+ return m_pThread->Start();
+}
+
+bool CTCPComm::IsPolling()
+{
+ if(m_pThread == 0){
+ return false;
+ }
+ return m_pThread->IsRunning();
+}
+
+
+void CTCPComm::Stop()
+{
+ if(m_pThread){
+ m_pThread->Stop();
+ }
+
+}
Added: incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/tcpcomm.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,48 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+// TCPComm.h: interface for the CTCPComm class.
+//
+//////////////////////////////////////////////////////////////////////
+
+#if !defined(TCPCOMM_H)
+#define TCPCOMM_H
+
+class CTCPPollThread;
+class CTCPComm
+{
+ friend class CTCPPollThread;
+public:
+ void Stop();
+ bool IsPolling();
+ int Start();
+ virtual bool Init();
+ CTCPComm();
+ virtual ~CTCPComm();
+
+protected:
+ virtual void OnPollThreadStep() = 0;
+ virtual int OnPollThreadError(int status);
+ virtual int PolledSocket() = 0;
+ virtual int Poll() = 0;
+
+
+
+private:
+ CTCPPollThread *m_pThread;
+};
+
+#endif // !defined(TCPCOMM_H)
Added: incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.cpp?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.cpp (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.cpp Mon Nov 30 11:44:51 2009
@@ -0,0 +1,98 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+
+#include "tcppollthread.h"
+#include "tcpcomm.h"
+
+CTCPPollThread::CTCPPollThread(CTCPComm* pcomm)
+{
+ m_pcomm = pcomm;
+ stop = false;
+}
+
+CTCPPollThread::~CTCPPollThread()
+{
+ Stop();
+}
+
+int CTCPPollThread::Start()
+{
+ if (JThread::IsRunning())
+ return -1;
+
+ if (!stopmutex.IsInitialized())
+ {
+ if (stopmutex.Init() < 0)
+ return -1;
+ }
+ stop = false;
+ if (JThread::Start() < 0)
+ return -1;
+ return 0;
+}
+
+void CTCPPollThread::Stop()
+{
+ if (!IsRunning())
+ return;
+
+ stopmutex.Lock();
+ stop = true;
+ stopmutex.Unlock();
+
+
+ if (JThread::IsRunning())
+ {
+ JThread::Kill();
+ }
+ stop = false;
+}
+
+void *CTCPPollThread::Thread()
+{
+ JThread::ThreadStarted();
+
+ int status;
+ bool stopthread;
+
+ stopmutex.Lock();
+ stopthread = stop;
+ stopmutex.Unlock();
+ while (!stopthread)
+ {
+// struct timeval tv = {0, 50000};
+ status = m_pcomm->Poll();
+ if(status < 0 ){
+ stopthread = 0;
+ m_pcomm->OnPollThreadError(status);
+ }
+ else{
+ status = m_pcomm->PolledSocket();
+ if(status < 0){
+ stopthread = true;
+ m_pcomm->OnPollThreadError(status);
+ }
+ else{
+ m_pcomm->OnPollThreadStep();
+ stopmutex.Lock();
+ stopthread = stop;
+ stopmutex.Unlock();
+ }
+ }
+ }
+ return 0;
+}
Added: incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/tcppollthread.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,46 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+
+#ifndef CTCPPOLLTHREAD_H
+
+#define CTCPPOLLTHREAD_H
+
+
+
+
+#include "jthread.h"
+#include "jmutex.h"
+
+class CTCPComm;
+class CTCPPollThread : private JThread
+{
+ friend class CTCPComm;
+public:
+ CTCPPollThread(CTCPComm* pcomm);
+ ~CTCPPollThread();
+ int Start();
+ void Stop();
+private:
+ void *Thread();
+
+ bool stop;
+ JMutex stopmutex;
+ CTCPComm *m_pcomm;
+};
+
+
+#endif // CTCPPOLLTHREAD_H
Added: incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.cpp
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.cpp?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.cpp (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.cpp Mon Nov 30 11:44:51 2009
@@ -0,0 +1,1065 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+#include <gtk/gtk.h>
+#include "ts_communicate.h"
+#include "interface.h"
+#include "dtunit.h"
+
+
+
+extern GtkWidget *group_clist; //define in interface.cpp
+extern GtkWidget *transfer_clist; //转åèç¹ä¿¡æ¯å表
+
+extern GtkWidget *class_name_entry; //æ´æ°è¯¾å ååæå¸å
+extern GtkWidget *teacher_name_entry;
+
+//extern GtkTextBuffer *log_buffer; //é对logçtextviewè¿è¡æä½
+//extern GtkTextIter log_end;
+
+extern void text_buffer_insert(const char *c_chContent); //define in callback.cpp
+
+struct des_client_para_mcu des_temp[200]; //åæ¾ç¤ºå表ä¸æå
¥å¼ï¼ä¿åçå
¨å±æ°ç»
+int des_temp_pos=0; //ä¿å以æå
¥çæ°é
+
+CRCLClientJoinInGroupRSeMCU SeMCU_des_temp[200]; //åè¾
MCUæ¾ç¤ºå表ä¸æå
¥å¼ï¼ä¿åçå
¨å±æ°ç»
+int SeMCU_des_temp_pos=0; //ä¿å以æå
¥çæ°é
+
+extern int add_udp_destination(char *ip_addr,int port,int which_port); //below define in dtufunction.cpp
+extern int remove_udp_destination(char *ip_addr,int port,int which_port);
+extern int clear_udp_destination();
+
+
+extern CDTUnit dtu; //basic transmit unit
+
+struct group_list semcu_grouplist;
+
+//LISTCLIENTDES::iterator i1;
+//LISTSEMCUDES::iterator i2;
+
+//MCU connect with TServer
+
+MCU_TS_communicate::MCU_TS_communicate()
+{
+ // may do something about MCU_Group
+
+
+}
+
+MCU_TS_communicate::~MCU_TS_communicate()
+{
+
+}
+
+
+int MCU_TS_communicate::establish_connect(LPCTSTR ts_IP,UINT ts_Port,UINT nSocketPort) //å¨MCUä¸å»ºç«socket线ç¨
+{
+ if( MCU_socket.Create(nSocketPort)!=true)
+ {
+ printf("Create socket failed!/n");
+ return -1;
+ }
+
+ if( MCU_socket.Connect(ts_IP,ts_Port)!=true)
+ {
+ perror("connet error!");
+ return -1;
+ }
+
+ MCU_socket_thread.Attach(&MCU_socket);
+
+ if( MCU_socket_thread.Init()!=true)
+ {
+ printf("Fail to initilize thread!/n");
+ return -1;
+ }
+ MCU_socket_thread.Start();
+ //printf("good!\n");
+ return 0;
+
+ //CAsyncSocketEx.connect(/**/);
+}
+
+
+
+int MCU_TS_communicate::send_mes(CRCLMSG mes,int mes_length) //å课å æå¡ä¸å¿åéæ¶æ¯
+{
+ //CAsyncSocketEx.send(/**/);
+
+ if( MCU_socket.Send(&mes,mes_length)==-1 )
+ {
+ perror("Send failed here!");
+ return -1;
+ }
+ return 0;
+}
+
+int MCU_TS_communicate::close_socket(int nHow)
+{
+ if( MCU_socket.ShutDown(nHow)==false)
+ {
+ perror("close socket error!");
+ return -1;
+ }
+ else
+ return 0;
+}
+
+
+///////////////////////// Main MCU ////////////////////////////
+
+MaMCU_TS_communicate::MaMCU_TS_communicate()
+{
+ // may do something about MCU_Group
+ /*if(!mcu_clist_mutex.IsInitialized()){
+ if(!mcu_clist_mutex.Init()){
+ perror("\nmcu_clist_mutex Init error\n");
+ }
+ }
+
+ if(!access_clist_mutex.IsInitialized()){
+ if(!access_clist_mutex.Init()){
+ perror("\naccess_clist_mutex Init error\n");
+ }
+ }*/
+ mcu_clist_mutex.Init();
+ access_clist_mutex.Init();
+
+}
+
+MaMCU_TS_communicate::~MaMCU_TS_communicate()
+{
+
+}
+
+int MaMCU_TS_communicate::refresh_clist() //ä¿å转åå表ï¼ä¾¿äºæ¸
é¤
+{
+ char *insert_row[200][7];
+ char temp_insert[200][6][16];
+
+ LISTCLIENTDES::iterator i1;
+ struct des_client_para_mcu *client_temp;
+
+ struct des_semuc_para_mcu *semcu_temp;
+ LISTSEMCUDES::iterator i2;
+
+ access_clist_mutex.Lock();
+ mcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+
+ //mcu_clist_mutex.Lock();
+ gtk_clist_clear(GTK_CLIST(transfer_clist));
+ //gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Unlock();
+
+ sprintf(temp_insert[0][0],"%d",MCU_Group.GroupID);
+ memset(temp_insert[0][1],0,1);
+ memset(temp_insert[0][2],0,1);
+ memset(temp_insert[0][3],0,1);
+ sprintf(temp_insert[0][4],"%d",MCU_Group.CVPort);
+ sprintf(temp_insert[0][5],"%d",MCU_Group.CAPort);
+
+ insert_row[0][0]=temp_insert[0][0];
+ insert_row[0][1]=MCU_Group.TeacherIP;
+ insert_row[0][2]=temp_insert[0][1];
+ insert_row[0][3]=temp_insert[0][2];
+ insert_row[0][4]=temp_insert[0][3];
+ insert_row[0][5]=temp_insert[0][4];
+ insert_row[0][6]=temp_insert[0][5];
+
+
+ //gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Lock();
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row[0]);
+ //gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Unlock();
+
+ int i;
+
+ for(i=1,i1=client_des.begin(); i1!= client_des.end(); ++i1,i++)
+ {
+ client_temp=*i1;
+
+ sprintf(temp_insert[i][0],"%d",client_temp->ClientInfo.ClientID);
+ sprintf(temp_insert[i][1],"%d",client_temp->TSPort);
+ sprintf(temp_insert[i][2],"%d",client_temp->TVPort);
+ sprintf(temp_insert[i][3],"%d",client_temp->TAPort);
+ sprintf(temp_insert[i][4],"%d",client_temp->CVPort);
+ sprintf(temp_insert[i][5],"%d",client_temp->CAPort);
+
+ insert_row[i][0]=temp_insert[i][0];
+ insert_row[i][1]=client_temp->des_ip;
+ insert_row[i][2]=temp_insert[i][1];
+ insert_row[i][3]=temp_insert[i][2];
+ insert_row[i][4]=temp_insert[i][3];
+ insert_row[i][5]=temp_insert[i][4];
+ insert_row[i][6]=temp_insert[i][5];
+
+ //gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Lock();
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row[i]);
+ //gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Unlock();
+ }
+
+
+ for(i2=mcu_des.begin(); i2!= mcu_des.end(); ++i2)
+ {
+ semcu_temp=*i2;
+
+ sprintf(temp_insert[i][0],"%d",semcu_temp->des_id);
+ sprintf(temp_insert[i][1],"%d",semcu_temp->TSPort);
+ sprintf(temp_insert[i][2],"%d",semcu_temp->TVPort);
+ sprintf(temp_insert[i][3],"%d",semcu_temp->TAPort);
+ sprintf(temp_insert[i][4],"%d",semcu_temp->CVPort);
+ sprintf(temp_insert[i][5],"%d",semcu_temp->CAPort);
+
+ insert_row[i][0]=temp_insert[i][0];
+ insert_row[i][1]=semcu_temp->des_ip;
+ insert_row[i][2]=temp_insert[i][1];
+ insert_row[i][3]=temp_insert[i][2];
+ insert_row[i][4]=temp_insert[i][3];
+ insert_row[i][5]=temp_insert[i][4];
+ insert_row[i][6]=temp_insert[i][5];
+
+ //gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Lock();
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row[i]);
+ //gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ //mcu_clist_mutex.Unlock();
+
+ }
+
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ mcu_clist_mutex.Unlock();
+ access_clist_mutex.Unlock();
+
+ return 0;
+}
+
+int MaMCU_TS_communicate::recevie_msg(char *buf,int buf_length ) //æ¥æ¶è¯¾å æå¡ä¸å¿æ¶æ¯å¹¶å¤ç
+{
+ CRCLMSG * receive_str;
+ receive_str=(CRCLMSG *) buf;
+
+ switch(receive_str->rclType)
+ {
+ case 5011:
+ //主MCUç»å½åååºæ¶æ¯
+ CRCLMCULoginR *loginReceive;
+ loginReceive=(CRCLMCULoginR *) receive_str->msg;
+ //printf("Resp_Type %d\n",loginReceive->ResponseType);
+ if(loginReceive->ResponseType!=0) //maybe modify
+ {
+ perror("login failed!");
+ //text_buffer_insert("Error:mcu join error from server\n");
+ text_buffer_insert("Error:DTU join error from server\n");
+ return -1;
+ }
+
+ MCU_ID=loginReceive->MCUID;
+ //printf("MCU_id %d\n",MCU_ID);
+ //text_buffer_insert("mcu login OK!!!!\n\n");
+ text_buffer_insert("DTU login OK!!!!\n\n");
+
+ break;
+
+ case 10002:
+ //æ课端å建ç»æ¶æ¯ç»MCUï¼å 为åªæMCUåå¨æå¯ä»¥å建ç»
+ //CRCLCreateGroupRMCU MCU_ceateG;
+ MCU_Group=* (CRCLCreateGroupRMCU *) receive_str->msg;
+ //printf("Teacher IP ********%s\n",MCU_Group.TeacherIP);
+ //printf("Teacher CAPort********%d\n",MCU_Group.CAPort);
+ //printf("Teacher CVPort********%d\n",MCU_Group.CVPort);
+
+
+ add_udp_destination(MCU_Group.TeacherIP,MCU_Group.CAPort,4);
+ add_udp_destination(MCU_Group.TeacherIP,MCU_Group.CVPort,3);
+
+ char temp_teacherID[10];
+ sprintf(temp_teacherID,"%d",MCU_Group.TeacherID);
+
+ gtk_entry_set_text(GTK_ENTRY(teacher_name_entry),temp_teacherID);
+ gtk_entry_set_text(GTK_ENTRY(class_name_entry),MCU_Group.GroupName);
+
+ char *insert_r[7];
+ char temp_i[6][16];
+
+ sprintf(temp_i[0],"%d",MCU_Group.TeacherID);
+ strcpy(temp_i[1],"");
+ strcpy(temp_i[2],"");
+ strcpy(temp_i[3],"");
+ sprintf(temp_i[4],"%d",MCU_Group.CVPort);
+ sprintf(temp_i[5],"%d",MCU_Group.CAPort);
+
+ insert_r[0]=temp_i[0];
+ insert_r[1]=MCU_Group.TeacherIP;
+ insert_r[2]=temp_i[1];
+ insert_r[3]=temp_i[2];
+ insert_r[4]=temp_i[3];
+ insert_r[5]=temp_i[4];
+ insert_r[6]=temp_i[5];
+
+
+ mcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ gtk_clist_clear(GTK_CLIST(transfer_clist));
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ mcu_clist_mutex.Unlock();
+
+
+ mcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_r);
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ mcu_clist_mutex.Unlock();
+
+ //text_buffer_insert("with mcu,teacher create class sucess! \n\n");
+ text_buffer_insert("with DTU,teacher create class sucess! \n\n");
+
+ refresh_transfer_clist_button_set(0);
+ break;
+
+ case 10012:
+ //æ课端离å¼ç»æ¶æ¯ï¼è¯¥ç»æåå°±åºå
¨é¨éåº,ååºæ¶æ¯ç»MCU
+ CRCLDestroyGroupRClient *MCU_destroyG;
+ MCU_destroyG=(CRCLDestroyGroupRClient *) receive_str->msg;
+
+ clear_udp_destination( );
+
+ text_buffer_insert("teacher stop class sucess! \n\n");
+
+ memset(&MCU_Group,0,sizeof(MCU_Group));
+
+
+ mcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ gtk_clist_clear(GTK_CLIST(transfer_clist));
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ mcu_clist_mutex.Unlock();
+
+ refresh_transfer_clist_button_set(1);
+
+ /***********maybe modify***************/
+ break;
+
+ case 10023:
+ {
+ //ååºæ¶æ¯ï¼ç»ä¸»MCUè¿ååç»éclientæ¥ç¹çä¿¡æ¯
+ CRCLClientJoinInGroupRMCU *MCU_add_client_Join;
+ MCU_add_client_Join= (CRCLClientJoinInGroupRMCU *) receive_str->msg;
+
+ if(MCU_add_client_Join->ClientType==0)
+ {
+ add_udp_destination(MCU_add_client_Join->ClientIP,MCU_add_client_Join->TAPort,2);
+ add_udp_destination(MCU_add_client_Join->ClientIP,MCU_add_client_Join->TVPort,1);
+ add_udp_destination(MCU_add_client_Join->ClientIP,MCU_add_client_Join->TSPort,0);
+ add_udp_destination(MCU_add_client_Join->ClientIP,MCU_add_client_Join->CAPort,4);
+ add_udp_destination(MCU_add_client_Join->ClientIP,MCU_add_client_Join->CVPort,3);
+
+ //以ä¸è®°å½ä¸ä¿¡æ¯ï¼ä¾¿äºå é¤
+ //struct des_client_para_mcu des_temp; //modify define as global var
+ des_temp[des_temp_pos].ClientInfo.ClientID=MCU_add_client_Join->ClientInfo.ClientID;
+ strcpy(des_temp[des_temp_pos].ClientInfo.ClienName,MCU_add_client_Join->ClientInfo.ClienName);
+ des_temp[des_temp_pos].ClientInfo.IsFocus=MCU_add_client_Join->ClientInfo.IsFocus;
+
+ strcpy(des_temp[des_temp_pos].des_ip,MCU_add_client_Join->ClientIP);
+ des_temp[des_temp_pos].TAPort=MCU_add_client_Join->TAPort;
+ des_temp[des_temp_pos].TVPort=MCU_add_client_Join->TVPort;
+ des_temp[des_temp_pos].TSPort=MCU_add_client_Join->TSPort;
+ des_temp[des_temp_pos].CAPort=MCU_add_client_Join->CAPort;
+ des_temp[des_temp_pos].CVPort=MCU_add_client_Join->CVPort;
+
+ access_clist_mutex.Lock();
+ client_des.insert(client_des.end(),&des_temp[des_temp_pos]);
+ access_clist_mutex.Unlock();
+
+ des_temp_pos++;
+ //æå
¥å°tarnsrfer_clistä¸
+
+ char *insert_row[7];
+ char temp_insert[6][16];
+
+ sprintf(temp_insert[0],"%d",MCU_add_client_Join->ClientInfo.ClientID);
+ sprintf(temp_insert[1],"%d",MCU_add_client_Join->TSPort);
+ sprintf(temp_insert[2],"%d",MCU_add_client_Join->TVPort);
+ sprintf(temp_insert[3],"%d",MCU_add_client_Join->TAPort);
+ sprintf(temp_insert[4],"%d",MCU_add_client_Join->CVPort);
+ sprintf(temp_insert[5],"%d",MCU_add_client_Join->CAPort);
+
+ insert_row[0]=temp_insert[0];
+ insert_row[1]=MCU_add_client_Join->ClientIP;
+ insert_row[2]=temp_insert[1];
+ insert_row[3]=temp_insert[2];
+ insert_row[4]=temp_insert[3];
+ insert_row[5]=temp_insert[4];
+ insert_row[6]=temp_insert[5];
+
+
+ mcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row);
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ mcu_clist_mutex.Unlock();
+
+ }
+
+ else
+ {
+ //é对穿é代çéè¦åäºäºæ
+ }
+
+ text_buffer_insert("a client join this group success! \n\n");
+ /*****************modify here****************/
+ }
+ break;
+
+ case 10032:
+ {
+ //客æ·ç¦»å¼ç»æ¶æ¯,ååºæ¶æ¯ç»MCU
+ CRCLClientLeaveGroupRAll *leave_client;
+ leave_client=(CRCLClientLeaveGroupRAll *) receive_str->msg;
+
+ struct des_client_para_mcu *remove_client; //以ä¸å é¤éåºå¬è¯¾ç«¯è½¬åå°å
+ LISTCLIENTDES::iterator i1;
+
+
+ access_clist_mutex.Lock();
+ for(i1=client_des.begin(); i1!= client_des.end(); ++i1)
+ {
+ remove_client=*i1;
+ if( (remove_client->ClientInfo.ClientID)==(leave_client->ClientInfo.ClientID) )
+ {
+ remove_udp_destination(remove_client->des_ip,remove_client->TAPort,2);
+ remove_udp_destination(remove_client->des_ip,remove_client->TVPort,1);
+ remove_udp_destination(remove_client->des_ip,remove_client->TSPort,0);
+ remove_udp_destination(remove_client->des_ip,remove_client->CAPort,4);
+ remove_udp_destination(remove_client->des_ip,remove_client->CVPort,3);
+
+
+
+ client_des.erase(i1); //å é¤ælistä¸ä¸é¡¹
+
+
+
+ //æ¤å¤åºå½å é¤clistä¸æ¾ç¤ºçä¸è¡
+
+
+ break;
+ }
+ }
+ access_clist_mutex.Unlock();
+
+
+ refresh_clist();
+ text_buffer_insert("a client leave this group success! \n\n");
+ }
+
+ break;
+
+ case 10041:
+ //MCU离å¼ç»ååºæ¶æ¯
+ CRCLMCULeaveGroupR *MCU_leaveG;
+ MCU_leaveG=(CRCLMCULeaveGroupR *) receive_str->msg;
+
+ if(MCU_leaveG->ResponseType!=1) //maybe modify here
+ {
+ perror("Leave Group error!");
+ return -1;
+ }
+
+ clear_udp_destination( );
+
+ gtk_entry_set_text(GTK_ENTRY(class_name_entry),"");
+ gtk_entry_set_text(GTK_ENTRY(teacher_name_entry),"");
+
+ //text_buffer_insert("mcu leave class success! \n\n");
+ text_buffer_insert("DTU leave class success! \n\n");
+ break;
+
+ case 10072:
+ {
+ //è¾
MCUå å
¥ç»ååºæ¶æ¯ï¼åç»ä¸»MCU
+ CRCLSeMCUJoinGroupRToMCU *MCU_add_SeMCU_Join;
+ MCU_add_SeMCU_Join=(CRCLSeMCUJoinGroupRToMCU *) receive_str->msg;
+
+ if(MCU_add_SeMCU_Join->SeMCUType==0)
+ {
+ add_udp_destination(MCU_add_SeMCU_Join->SeMCUIP,MCU_add_SeMCU_Join->TAPort,2);
+ add_udp_destination(MCU_add_SeMCU_Join->SeMCUIP,MCU_add_SeMCU_Join->TVPort,1);
+ add_udp_destination(MCU_add_SeMCU_Join->SeMCUIP,MCU_add_SeMCU_Join->TSPort,0);
+ add_udp_destination(MCU_add_SeMCU_Join->SeMCUIP,MCU_add_SeMCU_Join->CAPort,4);
+ add_udp_destination(MCU_add_SeMCU_Join->SeMCUIP,MCU_add_SeMCU_Join->CVPort,3);
+
+ //以ä¸è®°å½ä¸ä¿¡æ¯ï¼ä¾¿äºå é¤
+ struct des_semuc_para_mcu des_temp;
+ des_temp.des_id=MCU_add_SeMCU_Join->SeMCUID;
+ strcpy(des_temp.des_ip,MCU_add_SeMCU_Join->SeMCUIP);
+ des_temp.TAPort=MCU_add_SeMCU_Join->TAPort;
+ des_temp.TVPort=MCU_add_SeMCU_Join->TVPort;
+ des_temp.TSPort=MCU_add_SeMCU_Join->TSPort;
+ des_temp.CAPort=MCU_add_SeMCU_Join->CAPort;
+ des_temp.CVPort=MCU_add_SeMCU_Join->CVPort;
+
+
+ access_clist_mutex.Lock();
+ mcu_des.insert(mcu_des.end(),&des_temp);
+ access_clist_mutex.Unlock();
+
+ //æå
¥å°tarnsrfer_clistä¸
+
+ char *insert_row2[7];
+ char temp_insert2[6][16];
+
+ sprintf(temp_insert2[0],"%d",des_temp.des_id);
+ sprintf(temp_insert2[1],"%d",des_temp.TSPort);
+ sprintf(temp_insert2[2],"%d",des_temp.TVPort);
+ sprintf(temp_insert2[3],"%d",des_temp.TAPort);
+ sprintf(temp_insert2[4],"%d",des_temp.CVPort);
+ sprintf(temp_insert2[5],"%d",des_temp.CAPort);
+
+ insert_row2[0]=temp_insert2[0];
+ insert_row2[1]=des_temp.des_ip;
+ insert_row2[2]=temp_insert2[1];
+ insert_row2[3]=temp_insert2[2];
+ insert_row2[4]=temp_insert2[3];
+ insert_row2[5]=temp_insert2[4];
+ insert_row2[6]=temp_insert2[5];
+
+ mcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row2);
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ mcu_clist_mutex.Unlock();
+
+
+ }
+
+ else
+ {
+ //é对穿é代çéè¦åäºäºæ
+
+ //below add semcu_id to MCU.
+ struct CDTUPort::NATDATA natdata;
+ natdata.SeMCUID=MCU_add_SeMCU_Join->SeMCUID;
+
+ printf("init uid is %d\n",natdata.SeMCUID);
+ dtu.add_waitList(natdata); //define dtufunction.cpp
+ //ok,set nat_info over
+ }
+
+ //text_buffer_insert("a semcu join the mcu success! \n\n");
+ text_buffer_insert("An assistant DTU join the mcu success! \n\n");
+ break;
+ }
+ case 10083:
+ {
+ //SeMCU离å¼ç»,ååºæ¶æ¯ç»ä¸»MCUï¼éç¥å
¶åæ¢ç»è¾
MCU转å
+ CRCLSeMCULeaveGroupRToMCU *MCU_del_SeMCU;
+ MCU_del_SeMCU=(CRCLSeMCULeaveGroupRToMCU *) receive_str->msg;
+
+ struct des_semuc_para_mcu *remove_semcu; //以ä¸å é¤éåºå¬è¯¾ç«¯è½¬åå°å
+ LISTSEMCUDES::iterator i2;
+
+ access_clist_mutex.Lock();
+ for(i2=mcu_des.begin(); i2!= mcu_des.end(); ++i2)
+ {
+ remove_semcu=*i2;
+ if( (remove_semcu->des_id)==(MCU_del_SeMCU->SeMCUID) )
+ {
+ remove_udp_destination(remove_semcu->des_ip,remove_semcu->TAPort,2);
+ remove_udp_destination(remove_semcu->des_ip,remove_semcu->TVPort,1);
+ remove_udp_destination(remove_semcu->des_ip,remove_semcu->TSPort,0);
+ remove_udp_destination(remove_semcu->des_ip,remove_semcu->CAPort,4);
+ remove_udp_destination(remove_semcu->des_ip,remove_semcu->CVPort,3);
+
+
+ mcu_des.erase(i2); //å é¤ælistä¸ä¸é¡¹
+
+
+
+ //æ¤å¤åºå½å é¤clistä¸æ¾ç¤ºçä¸è¡
+
+ //refresh_clist();
+
+ break;
+ }
+ }
+ access_clist_mutex.Unlock();
+
+ refresh_clist();
+
+ //text_buffer_insert("a semcu leave the mcu success! \n\n");
+ text_buffer_insert("An assistant DTU leave the mcu success! \n\n");
+ }
+
+
+ break;
+
+
+ case 1012:
+ //åéç¦ç¹ä¿¡æ¯ç»MCU
+ CRCLClientApplyFocusRToTM *client_FocusR;
+ client_FocusR=(CRCLClientApplyFocusRToTM *) receive_str->msg;
+
+
+ /***************add here****************/
+ break;
+
+ case 1022:
+ //åéæ¤éç¦ç¹æ¶æ¯ç»MCU
+ CRCLClientDestroyFocusRToTM *clent_remove_FocuseR;
+ clent_remove_FocuseR=(CRCLClientDestroyFocusRToTM *) receive_str->msg;
+
+ /********************add here**************/
+ break;
+
+ case 1052: //???????
+ //æ课端æå®ç¦ç¹æ¶æ¯,ååºæ¶æ¯éç¥MCUæå®ç客æ·ç«¯æ为ç¦ç¹
+ CRCLTeacherAllowClientFocusRToMS *Teacher_Allow;
+ Teacher_Allow=(CRCLTeacherAllowClientFocusRToMS *) receive_str->msg;
+
+ /********************add here****************/
+ break;
+
+ case 1062:
+ //æ课端å¥å¤ºç¦ç¹,ååºæ¶æ¯ éç¥MCUåç¦ç¹å¦çæ¤éç¦ç¹
+ CRCLTeacherCancelClientFocusRToMS *Teacher_Cancel;
+ Teacher_Cancel=(CRCLTeacherCancelClientFocusRToMS *) receive_str->msg;
+
+ /**********************add here*******************/
+ break;
+
+ default:
+
+ break;
+ }
+
+ return 0;
+
+}
+
+DWORD MaMCU_TS_communicate::get_mcuid()
+{
+ return MCU_ID;
+}
+
+DWORD MaMCU_TS_communicate::get_mcugroupid()
+{
+ return MCU_Group.GroupID;
+}
+
+
+
+/************************below belong to SeMcu***********************/
+
+
+
+SeMCU_TS_communicate::SeMCU_TS_communicate()
+{
+ SeMCUType = 0;
+
+/* if(!semcu_clist_mutex.IsInitialized()){
+ if(!semcu_clist_mutex.Init()){
+ perror("\nsemcu_clist_mutex Init error\n");
+ }
+ }
+ if(!se_access_clist_mutex.IsInitialized()){
+ if(!se_access_clist_mutex.Init()){
+ perror("\nse_access_clist_mutex Init error\n");
+ }
+ }
+*/
+ semcu_clist_mutex.Init();
+ se_access_clist_mutex.Init();
+ semcu_group_clist_mutex.Init();
+
+}
+
+SeMCU_TS_communicate::~SeMCU_TS_communicate()
+{
+
+}
+
+int SeMCU_TS_communicate::refresh_clist()
+{
+ char *insert_row[200][7];
+ char temp_insert[200][6][16];
+
+ LISTCLIENTDESSEMCU::iterator i1;
+ struct CRCLClientJoinInGroupRSeMCU *client_temp;
+
+ se_access_clist_mutex.Lock();
+ semcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+
+ gtk_clist_clear(GTK_CLIST(transfer_clist));
+ //gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ //semcu_clist_mutex.Unlock();
+
+ int i;
+
+ for(i=0,i1=semcu_client_des.begin(); i1!= semcu_client_des.end(); ++i1,i++)
+ {
+ client_temp=*i1;
+
+ sprintf(temp_insert[i][0],"%d",client_temp->ClientID);
+ sprintf(temp_insert[i][1],"%d",client_temp->TSPort);
+ sprintf(temp_insert[i][2],"%d",client_temp->TVPort);
+ sprintf(temp_insert[i][3],"%d",client_temp->TAPort);
+ sprintf(temp_insert[i][4],"%d",client_temp->CVPort);
+ sprintf(temp_insert[i][5],"%d",client_temp->CAPort);
+
+ insert_row[i][0]=temp_insert[i][0];
+ insert_row[i][1]=client_temp->ClientIP;
+ insert_row[i][2]=temp_insert[i][1];
+ insert_row[i][3]=temp_insert[i][2];
+ insert_row[i][4]=temp_insert[i][3];
+ insert_row[i][5]=temp_insert[i][4];
+ insert_row[i][6]=temp_insert[i][5];
+
+ //gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ //semcu_clist_mutex.Lock();
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row[i]);
+ //gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ //semcu_clist_mutex.Unlock();
+ }
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ semcu_clist_mutex.Unlock();
+ se_access_clist_mutex.Unlock();
+
+ return 0;
+}
+
+int SeMCU_TS_communicate::recevie_msg(char *buf,int buf_length)
+{
+ CRCLMSG * receive_str;
+ receive_str=(CRCLMSG *) buf;
+
+ int i;
+
+ switch(receive_str->rclType)
+ {
+ case 5061:
+ //è¾
MCUç»å½åååºæ¶æ¯
+ CRCLSeMCULoginR *loginReceive_semcu;
+ loginReceive_semcu=(CRCLSeMCULoginR *) receive_str->msg;
+ //printf("Resp_Type %d\n",loginReceive_semcu->ResponseType);
+ if(loginReceive_semcu->ResponseType!=0) //maybe modify
+ {
+ perror("login failed!");
+ //text_buffer_insert("Error:semcu login error from server!\n");
+ text_buffer_insert("Error:assistant DTU login error from server!\n");
+ return -1;
+ }
+
+ SeMCUID=loginReceive_semcu->MCUID;
+ SeMCUType=loginReceive_semcu->MCUType;
+
+ //text_buffer_insert("semcu login success! \n\n");
+ text_buffer_insert("Assistant DTU login success! \n\n");
+ //printf("MCU_id %d\n",MCU_ID);
+
+ /*
+ //以ä¸semcuè¦åé请æ±è·å¾ç»ä¿¡æ¯æ¶æ¯
+ CRCLMSG send_mes;
+ CRCLSeMCUGetGroupInfo semcu_requese_group;
+ semcu_requese_group.SeMCUID=SeMCUID;
+
+ send_mes.rclType=10060;
+ send_mes.msglen=sizeof(semcu_requese_group);
+ memcpy(send_mes.msg,&semcu_requese_group,sizeof(semcu_requese_group) );
+
+ if(MCU_TS_communicate::send_mes(send_mes,(send_mes.msglen+8))<0)
+ {
+ perror("send requese group info failed!");
+ return -1;
+ }*/
+
+ break;
+
+ case 10012:
+ //æ课端离å¼ç»æ¶æ¯ï¼è¯¥ç»æåå°±åºå
¨é¨éåº ååºæ¶æ¯ï¼ç»è¾
MCU
+ CRCLDestroyGroupRClient *SeMCU_destroyG;
+ SeMCU_destroyG=(CRCLDestroyGroupRClient *) receive_str->msg;
+
+ //add here
+ clear_udp_destination( );
+
+ //text_buffer_insert("semcu leave group success! \n\n");
+ text_buffer_insert("Assistant DTU leave group success! \n\n");
+ break;
+
+ case 10024:
+ {
+ //ç»è¾
MCUè¿ååç»éçå
ç½å¬è¯¾ç«¯çä¿¡æ¯
+ CRCLClientJoinInGroupRSeMCU *SeMCU_join_client;
+ SeMCU_join_client=(CRCLClientJoinInGroupRSeMCU *) receive_str->msg;
+
+ add_udp_destination(SeMCU_join_client->ClientIP,SeMCU_join_client->TAPort,2);
+ add_udp_destination(SeMCU_join_client->ClientIP,SeMCU_join_client->TVPort,1);
+ add_udp_destination(SeMCU_join_client->ClientIP,SeMCU_join_client->TSPort,0);
+ add_udp_destination(SeMCU_join_client->ClientIP,SeMCU_join_client->CAPort,4);
+ add_udp_destination(SeMCU_join_client->ClientIP,SeMCU_join_client->CVPort,3);
+
+ //以ä¸è®°å½ä¸ä¿¡æ¯ï¼ä¾¿äºå é¤
+
+
+
+ SeMCU_des_temp[SeMCU_des_temp_pos].ClientID=SeMCU_join_client->ClientID;
+ strcpy(SeMCU_des_temp[SeMCU_des_temp_pos].ClientIP,SeMCU_join_client->ClientIP);
+ SeMCU_des_temp[SeMCU_des_temp_pos].TAPort=SeMCU_join_client->TAPort;
+ SeMCU_des_temp[SeMCU_des_temp_pos].TVPort=SeMCU_join_client->TVPort;
+ SeMCU_des_temp[SeMCU_des_temp_pos].TSPort=SeMCU_join_client->TSPort;
+ SeMCU_des_temp[SeMCU_des_temp_pos].CAPort=SeMCU_join_client->CAPort;
+ SeMCU_des_temp[SeMCU_des_temp_pos].CVPort=SeMCU_join_client->CVPort;
+
+ se_access_clist_mutex.Lock();
+ semcu_client_des.insert(semcu_client_des.end(),&SeMCU_des_temp[SeMCU_des_temp_pos]);
+ se_access_clist_mutex.Unlock();
+
+ SeMCU_des_temp_pos++;
+
+ //æå
¥å°tarnsrfer_clistä¸
+
+ char *insert_row[7];
+ char temp_insert[6][16];
+
+ sprintf(temp_insert[0],"%d",SeMCU_join_client->ClientID);
+ sprintf(temp_insert[1],"%d",SeMCU_join_client->TSPort);
+ sprintf(temp_insert[2],"%d",SeMCU_join_client->TVPort);
+ sprintf(temp_insert[3],"%d",SeMCU_join_client->TAPort);
+ sprintf(temp_insert[4],"%d",SeMCU_join_client->CVPort);
+ sprintf(temp_insert[5],"%d",SeMCU_join_client->CAPort);
+
+ insert_row[0]=temp_insert[0];
+ insert_row[1]=SeMCU_join_client->ClientIP;
+ insert_row[2]=temp_insert[1];
+ insert_row[3]=temp_insert[2];
+ insert_row[4]=temp_insert[3];
+ insert_row[5]=temp_insert[4];
+ insert_row[6]=temp_insert[5];
+
+ semcu_clist_mutex.Lock();
+ gtk_clist_freeze( GTK_CLIST(transfer_clist) );
+ gtk_clist_append(GTK_CLIST(transfer_clist),insert_row);
+ gtk_clist_thaw( GTK_CLIST(transfer_clist) );
+ semcu_clist_mutex.Unlock();
+
+ text_buffer_insert("a client join group success! \n\n");
+ break;
+ }
+ case 10033:
+ {
+ //客æ·ç¦»å¼ç»æ¶æ¯,ååºæ¶æ¯ç»MCU
+ CRCLClientLeaveGroupRAll *leave_client_semcu;
+ leave_client_semcu=(CRCLClientLeaveGroupRAll *) receive_str->msg;
+
+ struct CRCLClientJoinInGroupRSeMCU *remove_client; //以ä¸å é¤éåºå¬è¯¾ç«¯è½¬åå°å
+ LISTCLIENTDESSEMCU::iterator i1;
+
+ se_access_clist_mutex.Lock();
+ for(i1=semcu_client_des.begin(); i1!= semcu_client_des.end(); ++i1)
+ {
+ remove_client=*i1;
+ if( (remove_client->ClientID)==(leave_client_semcu->ClientInfo.ClientID) )
+ {
+ remove_udp_destination(remove_client->ClientIP,remove_client->TAPort,2);
+ remove_udp_destination(remove_client->ClientIP,remove_client->TVPort,1);
+ remove_udp_destination(remove_client->ClientIP,remove_client->TSPort,0);
+ remove_udp_destination(remove_client->ClientIP,remove_client->CAPort,4);
+ remove_udp_destination(remove_client->ClientIP,remove_client->CVPort,3);
+
+
+ semcu_client_des.erase(i1); //å é¤ælistä¸ä¸é¡¹
+
+
+ //æ¤å¤åºå½å é¤clistä¸æ¾ç¤ºçä¸è¡
+
+ //refresh_clist();
+
+ break;
+ }
+
+
+ }
+
+ se_access_clist_mutex.Unlock();
+
+ refresh_clist();
+ text_buffer_insert("a client leave group success! \n\n");
+ }
+
+
+ break;
+
+ case 10061:
+ {
+ //è¾
MCUè·å¾å½åç»ä¿¡æ¯,ååºæ¶æ¯
+ CRCLSeMCUGetGroupInfoR *semcu_get_groupinfo;
+ semcu_get_groupinfo=(CRCLSeMCUGetGroupInfoR *) receive_str->msg;
+
+ //printf("response type is %d\n",semcu_get_groupinfo->ResponseType);
+ //printf("group count is %d\n",semcu_get_groupinfo->GroupCount);
+ //printf("get group name is %s\n",semcu_get_groupinfo->GroupList[0].GroupName);
+
+ if(semcu_get_groupinfo->ResponseType!=0)
+ {
+ //perror("SeMCU get group info error!");
+ perror("Assistant DTU get group info error!");
+ return -1;
+ }
+
+ semcu_grouplist.GroupCount=semcu_get_groupinfo->GroupCount; //none:0
+ //int i;
+
+ for(i=0;i<semcu_get_groupinfo->GroupCount;i++)
+ {
+ semcu_grouplist.GroupList[i].GroupID=semcu_get_groupinfo->GroupList[i].GroupID;
+ //printf("get group id is %d\n",semcu_grouplist.GroupList[i].GroupID);
+ strcpy(semcu_grouplist.GroupList[i].GroupName,semcu_get_groupinfo->GroupList[i].GroupName);
+ //printf("get group name is %s\n",semcu_grouplist.GroupList[i].GroupName);
+ strcpy(semcu_grouplist.GroupList[i].TeacherName,semcu_get_groupinfo->GroupList[i].TeacherName);
+ //printf("get teacher name is %s\n",semcu_grouplist.GroupList[i].TeacherName);
+ }
+
+
+ //以ä¸å·æ°group_clistçæ¾ç¤ºå
容
+
+ gchar *new_row[3];
+ gchar temp_id[5];
+ semcu_group_clist_mutex.Lock();
+ gtk_clist_freeze(GTK_CLIST(group_clist));
+
+ gtk_clist_clear(GTK_CLIST(group_clist));
+ //gtk_clist_thaw(GTK_CLIST(group_clist));
+
+ for(i=0;i<semcu_get_groupinfo->GroupCount;i++)
+ {
+
+ sprintf(temp_id,"%d",semcu_grouplist.GroupList[i].GroupID);
+ //printf("show id is %s\n",temp_id);
+
+ new_row[0]=temp_id;
+ new_row[1]=semcu_grouplist.GroupList[i].GroupName;
+ new_row[2]=semcu_grouplist.GroupList[i].TeacherName;
+
+ //printf("new_row1 is %s \n",new_row[1]);
+ //printf("new_row2 is %s\n",new_row[2]);
+ //strcpy(new_row[1],semcu_grouplist.GroupList[i].GroupName);
+ //gtk_clist_set_text(GTK_CLIST(group_clist),i,1,temp_GroupName);
+ //strcpy(new_row[2],semcu_grouplist.GroupList[i].TeacherName);
+ //gtk_clist_freeze(GTK_CLIST(group_clist));
+ gtk_clist_append(GTK_CLIST(group_clist),new_row);
+ //gtk_clist_thaw(GTK_CLIST(group_clist));
+ }
+ gtk_clist_thaw(GTK_CLIST(group_clist));
+ semcu_group_clist_mutex.Unlock();
+
+ }
+ break;
+
+ case 10071:
+ //è¾
MCUå å
¥ååºç»æ¶æ¯
+ CRCLSeMCUJoinGroupR *semcu_join_Group;
+ semcu_join_Group=(CRCLSeMCUJoinGroupR *) receive_str->msg;
+
+ //printf("semcu receive response is %d\n",semcu_join_Group->ResponseType);
+ printf("Assistant DTU receive response is %d\n",semcu_join_Group->ResponseType);
+ if(semcu_join_Group->ResponseType!=0)
+ {
+ //printf("semcu receive response is %d\n",semcu_join_Group->ResponseType);
+ //perror("SeMCU join in group error!");
+ perror("Assistant DTU join in group error!");
+ return -1;
+ }
+
+ group_info.GroupID=semcu_join_Group->GroupID;
+ strcpy(group_info.MCUIP,semcu_join_Group->MCUIP);
+ group_info.TAPort=semcu_join_Group->TAPort;
+ group_info.TVPort=semcu_join_Group->TVPort;
+ group_info.TSPort=semcu_join_Group->TSPort;
+ group_info.CAPort=semcu_join_Group->CAPort;
+ group_info.CVPort=semcu_join_Group->CVPort;
+
+ joingroup_set(0);
+
+ for(i=0;i<semcu_grouplist.GroupCount;i++)
+ {
+ if(semcu_grouplist.GroupList[i].GroupID==semcu_join_Group->GroupID)
+ {
+ gtk_entry_set_text(GTK_ENTRY(class_name_entry),semcu_grouplist.GroupList[i].GroupName);
+ gtk_entry_set_text(GTK_ENTRY(teacher_name_entry),semcu_grouplist.GroupList[i].TeacherName);
+ }
+ }
+
+ //below set nat_info of Main MCU to SeMCU.
+ struct CDTUPort::NATDATA natdata;
+ natdata.SeMCUID=SeMCUID;
+
+ dtu.set_NATInf(*semcu_join_Group, natdata); //define dtufunction.cpp
+ //ok,set nat_info over
+
+ //text_buffer_insert("semcu join group success! \n\n");
+ text_buffer_insert("Assistant DTU join group success! \n\n");
+
+ /*char mssss[1000];
+ strcpy(mssss,semcu_join_Group->MCUIP);
+ strcat(mssss,semcu_join_Group->TAPort);
+ strcat(mssss,semcu_join_Group->TVPort);
+ strcat(mssss,semcu_join_Group->TSPort);
+ strcat(mssss,semcu_join_Group->CAPort);
+ strcat(mssss,semcu_join_Group->CVPort);
+ gtk_text_buffer_insert(log_buffer,&log_end,mssss,-1);
+ */
+ /**éè¦å å
¥è·å¾ç»ä¿¡æ¯åè¦å å
¥çç»æ¯å¦å¹é
代ç **/
+
+ break;
+
+ case 10081:
+ //seMCU离å¼ç»ååºæ¶æ¯
+ CRCLSeMCULeaveGroupR *semcu_leave_R;
+ semcu_leave_R=(CRCLSeMCULeaveGroupR *) receive_str->msg;
+
+ if(semcu_leave_R->ResponseType!=0)
+ {
+ //perror("SeMCU leave errror!");
+ perror("Assistant DTU leave errror!");
+ return -1;
+ }
+
+ //add here
+ clear_udp_destination( );
+
+ gtk_entry_set_text(GTK_ENTRY(class_name_entry),"");
+ gtk_entry_set_text(GTK_ENTRY(teacher_name_entry),"");
+
+ //text_buffer_insert("semcu leave group success! \n\n");
+ text_buffer_insert("Assistant DTU leave group success! \n\n");
+ break;
+
+ default:
+ break;
+
+ }
+
+ return 0;
+}
+
+DWORD SeMCU_TS_communicate::get_semcuid()
+{
+ return SeMCUID;
+}
Added: incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/src/ts_communicate.h Mon Nov 30 11:44:51 2009
@@ -0,0 +1,142 @@
+//Licensed to the Apache Software Foundation (ASF) under one
+//or more contributor license agreements. See the NOTICE file
+//distributed with this work for additional information
+//regarding copyright ownership. The ASF licenses this file
+//to you under the Apache License, Version 2.0 (the
+//"License"); you may not use this file except in compliance
+//with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+//Unless required by applicable law or agreed to in writing,
+//software distributed under the License is distributed on an
+//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+//KIND, either express or implied. See the License for the
+//specific language governing permissions and limitations
+//under the License.
+#ifndef TS_COMMUNICATE_H
+#define TS_COMMUNICATE_H
+
+#include "stdafx.h"
+#include "clientsocket.h"
+#include "singlecomm.h"
+#include "mcumessage.h"
+#include "dtufunction.h"
+
+struct des_semuc_para_mcu
+{
+ DWORD des_id;
+ char des_ip[16];
+ DWORD TAPort;
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+};
+
+struct des_client_para_mcu
+{
+ CClientInfo ClientInfo;
+ char des_ip[16];
+ DWORD TAPort;
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+};
+
+struct group_list
+{
+ DWORD GroupCount;
+ CGroupInfo GroupList[10];
+};
+
+struct group_para_semcu
+{
+ DWORD GroupID;//ä¹è¿åç»ID
+ char MCUIP[16];//主MCUçIPå°å
+// char SeMCUIP[16];//è¾
MCUçIPå°å
+ DWORD TAPort; //主MCUçæ°æ®æ¥æ¶ç«¯å£
+ DWORD TVPort;
+ DWORD TSPort;
+ DWORD CAPort;
+ DWORD CVPort;
+
+// DWORD IfSeMCU;
+};
+
+typedef std::list<des_semuc_para_mcu*> LISTSEMCUDES;
+typedef std::list<des_client_para_mcu*> LISTCLIENTDES;
+typedef std::list<CRCLClientJoinInGroupRSeMCU *> LISTCLIENTDESSEMCU;
+
+////////////////////////// MCU Class////////////////////////////////////
+class MCU_TS_communicate
+{
+ public:
+ MCU_TS_communicate();
+ virtual ~MCU_TS_communicate();
+
+ int establish_connect(LPCTSTR,UINT,UINT nSocketPort=0);
+ int send_mes(struct CRCLMSG,int mes_length);
+ int close_socket(int nHow);
+
+ virtual int recevie_msg(char *buf,int buf_length)=0;
+
+ private:
+ CClientSocket MCU_socket;
+ CSingleComm MCU_socket_thread;
+
+};
+
+
+class MaMCU_TS_communicate: public MCU_TS_communicate
+{
+ public:
+ MaMCU_TS_communicate();
+ ~MaMCU_TS_communicate();
+
+ int recevie_msg(char *buf,int buf_length);
+ DWORD get_mcuid();
+ DWORD get_mcugroupid();
+
+ int refresh_clist(); //æ´æ°è½¬åå表
+
+ private:
+ DWORD MCU_ID; //MCU IDå·
+ struct CRCLCreateGroupRMCU MCU_Group;
+
+ LISTSEMCUDES mcu_des; //ä¿å转åå表ï¼ä¾¿äºæ¸
é¤
+ LISTCLIENTDES client_des;
+
+ JMutex mcu_clist_mutex;
+ JMutex access_clist_mutex;
+};
+
+class SeMCU_TS_communicate: public MCU_TS_communicate
+{
+ public:
+ SeMCU_TS_communicate();
+ ~SeMCU_TS_communicate();
+
+ int recevie_msg(char *buf,int buf_length);
+ DWORD get_semcuid();
+
+ int refresh_clist(); //æ´æ°è½¬åå表
+ inline DWORD GetSeMCUType(){return SeMCUType;};
+ private:
+ DWORD SeMCUID;
+ DWORD SeMCUType; //0:å¤ç½ 1:å
ç½
+
+ //struct group_list semcu_grouplist;
+ struct group_para_semcu group_info;
+
+ LISTCLIENTDESSEMCU semcu_client_des; //ä¿å转åå表ï¼ä¾¿äºæ¸
é¤
+
+ JMutex semcu_clist_mutex;
+ JMutex semcu_group_clist_mutex;
+ JMutex se_access_clist_mutex;
+};
+
+
+
+#endif
Added: incubator/bluesky/trunk/RealClass/DTU/stamp-h
URL: http://svn.apache.org/viewvc/incubator/bluesky/trunk/RealClass/DTU/stamp-h?rev=885383&view=auto
==============================================================================
--- incubator/bluesky/trunk/RealClass/DTU/stamp-h (added)
+++ incubator/bluesky/trunk/RealClass/DTU/stamp-h Mon Nov 30 11:44:51 2009
@@ -0,0 +1 @@
+timestamp