public ConnectionTriggerFileXml(FloorSet aFloorSet, SettingsBase aSetting) : base(aFloorSet, aSetting) { //获取初始化数据 mFloorSet = aFloorSet; mXmlFileName = (string)aSetting["XmlFileName"]; mXmlReader = new XmlTextReader(mXmlFileName); mXmlReader.MoveToFirstAttribute(); }
public FloorSet StartConnection() { FloorSet allFloorSet = new FloorSet(_Settings); string errorSetting = ""; List <string> errorList = new List <string>(); if (_Settings == null) { _Settings.NewSubSettings("Connection"); return(allFloorSet); } // Create connection for each connection subSettings foreach (string s in _Settings.SubSettings.Keys) { SettingsBase connectionSetting = _Settings.SubSettings[s]; try { ConnectionBase newConnection = CreateConnection(allFloorSet, connectionSetting); _Connections.Add(s, newConnection); if ((Convert.ToBoolean(connectionSetting["IsRunning", false]) == true) && (!newConnection.IsRunning)) { // Try to connect it try { newConnection.Connect(); } catch { } } } catch { errorList.Add(s); errorSetting += s; } } if (!string.IsNullOrEmpty(errorSetting)) { // Remove Error Connection for (int i = 0; i < errorList.Count; i++) { Trace.WriteLine(string.Format("Removing {0} connection", errorList[i]), "Connection"); _Settings.SubSettings.Remove((string)errorList[i]); } Trace.WriteLine(errorSetting + " Connection error, unable to create"); //_Log.WriteLog(errorSetting + "设置错误,无法被创建"); } OnHaveStartConnection(EventArgs.Empty); return(allFloorSet); }
public TcpipRcuConnection(FloorSet floorSet, SettingsBase settings) : base(floorSet, settings) { // TODO Listen to FloorSet events and send to RCU _FloorSet.HotelUsingStatusChanged += new HotelUsingStatusChangedEventHandler(_FloorSet_HotelUsingStatusChanged); _FloorSet.DefaultTemperatureChanged += new DefaultTemperatureChangedEventHandler(_FloorSet_DefaultTemperatureChanged); _FloorSet.DefaultRunningStatusChanged += new DefaultRunningStatusChangedEventHandler(_FloorSet_DefaultRunningStatusChanged); _SendBroadcastDataTimer.Elapsed += new System.Timers.ElapsedEventHandler(_SendBroadcastDataTimer_Elapsed); ResetSetting(); }
public void CreateConnection(FloorSet floorSet, SettingsBase settings, ConnectionType type) { if (settings == null) { return; } // Get the FloorSet Information to Settings string floorInfo = string.Empty; foreach (int floorNumber in floorSet.FloorNumbers) { // Save each floor number floorInfo += ("F" + floorNumber); // Save each room number foreach (Room room in floorSet[floorNumber].GetRooms()) { floorInfo += ("R" + room.Number); } } settings["Type"] = type.ClassInfo.Name; ConnectionBase newConnection = type.CreateConnection(floorSet, settings); if (newConnection == null) { _Log.WriteLog("没有此类的连接方式"); //如果没有以上种,就报错 return; } else { //has created the new connection , add informations settings["FloorSet"] = floorInfo; this._Connections.Add(settings["Name"].ToString(), newConnection); if ((Convert.ToBoolean(settings["IsRunning", false]) == true) && (!newConnection.IsRunning)) { // Try to connect it try { newConnection.Connect(); } catch { } } OnHaveCreatConnection(EventArgs.Empty); } }
//protected bool mMultiChannel; //Whether Use 0 1 Channel public ConnectionCANBus(FloorSet floorSet, SettingsBase connectionSettings) : base(floorSet, connectionSettings) { //Load Default Options _Settings = connectionSettings; _FloorSet = floorSet; _FloorSet.WakingGuestUp += new WakingGuestUpEventHandler(_FloorSet_WakingGuestUp); ResetSetting(); baseSetting = _Settings.ParentSettings.ParentSettings as Settings; //Connection Config //mConfig=new CANBusInitConfig(); //mConfig.AcceptCode=0x00000000; //mConfig.MaskCode=0xFFFFFFFF; //mConfig.RunningMode=RunningMode.Normal; //mConfig.Timing0=0x67; //mConfig.Timing1=0x2f; //Load User Define Settings //mConnection=new CANBusConnection(mConfig); //mConnection.DeviceType=(CANDeviceType)(Convert.ToInt32(ConnectionSettings["DeviceType",0])); //mConnection.DeviceInd=Convert.ToInt32(ConnectionSettings["DeviceInd",0]); //mConnection.CANInd=Convert.ToInt32(ConnectionSettings["CANInd",0]); //mConnection.UseAllCANInd = Convert.ToBoolean(ConnectionSettings["MultiChannel",false]); //this.mWhetherSendTimeToATM= //mDisconnectRetryTimes=Convert.ToInt32(ConnectionSettings["DisconnectRetryTimes",2]); //mScanDelay=Convert.ToInt32(ConnectionSettings["ScanDelay",1000]); //mSendTimeToATMFrequency=Convert.ToInt32(ConnectionSettings["SendTimeToATMFrequency",30]); //Apply Options _ScannerTimeout.Elapsed += new System.Timers.ElapsedEventHandler(mScannerTimeout_Elapsed); _SendTimeToATMTimer.Elapsed += new System.Timers.ElapsedEventHandler(mSendTimeToATMTimer_Elapsed); //mScannerTimeout.Interval=mScanDelay; //mSendTimeToATMTimer.Interval=mSendTimeToATMFrequency; // Connect All Rooms foreach (int floorNumber in _FloorSet.FloorNumbers) { foreach (Room room in _FloorSet[floorNumber].GetRooms()) { room.MyATM.Connect(); } } // Handle Vacant Information of the Room floorSet.HotelUsingStatusChanged += new HotelUsingStatusChangedEventHandler(aFloorSet_HotelUsingStatusChanged); }
IEnumerator CreatePlayerJumpRutine() { Debug.Log("PlayerJump"); yield return(new WaitForSeconds(0.5f)); // ターゲットとなるフロアセットのスクリプトを参照しておく FloorSet targetFloor = null; foreach (Transform floorSet in floorContainer.transform) { if (floorSet.GetComponent <FloorSet>().IsNotReached) { targetFloor = floorSet.GetComponent <FloorSet>(); break; } } if (targetFloor == null) { yield break; } // 参照スクリプトから着地点を常に計算する // 1秒くらいでジャンプさせる float passTime = 0f; float limitTime = 1.0f; var baseX = player.transform.position.x; float baseY = playerDefaultY; while ((passTime += Time.deltaTime) <= limitTime) { float per = passTime / limitTime; var pos = new Vector3(); pos.x = baseX + (targetFloor.distance - baseX) * per; pos.y = baseY + 3f * (per < 0.5f ? per: 1.0f - per) * 2f; player.transform.position = pos; yield return(null); } // 最後に合わせる player.transform.position = new Vector3(targetFloor.distance, baseY, 0); // フラグを消す targetFloor.IsNotReached = false; nowFloorGettingOn = targetFloor; Debug.Log("PlayerJump2"); yield return(null); playerJumpRutine = null; }
public Client(FloorSet floorSet, SettingsBase setting) : base(floorSet, setting) { _FloorSet = floorSet; _Settings = setting; if (setting == null) { _Logger.WriteLog("Setting为空,Client实例化失败"); } else { _TCPIPAddressSetting = setting; if (_TCPIPAddressSetting["IP"] == null) { _TCPIPAddressSetting["IP"] = "127.0.0.1"; setting.Save(); } if (_TCPIPAddressSetting["Port"] == null) { _TCPIPAddressSetting["Port"] = "15000"; setting.Save(); } } _LocalIP = IPAddress.Parse(_TCPIPAddressSetting["IP"].ToString()); MyServer = new IPEndPoint(_LocalIP, Int32.Parse(_TCPIPAddressSetting["Port"].ToString())); _CurrentRoom = floorSet.FirstFloor.FirstRoom; _TCPICClientLog.FileName = "TCPIPClient.log"; // Create a new Timer with Interval set to 10 seconds. _Timer.Elapsed += new ElapsedEventHandler(OnTimedEvent); InitCommands(); HandleEvents(); //Connect All Rooms foreach (int floorNumber in _FloorSet.FloorNumbers) { foreach (Room room in _FloorSet[floorNumber].GetRooms()) { room.MyATM.Connect(); } } }
public ConnectionTriggerFileText(FloorSet floorSet, SettingsBase setting) : base(floorSet, setting) { //获取初始化数据 _FloorSet = floorSet; _Settings = setting; _FileName = (string)setting["FileName"]; _FileWatcher.Filter = Path.GetFileName(_FileName); _FileWatcher.Path = Path.GetPathRoot(_FileName); _FileWatcher.NotifyFilter = NotifyFilters.LastAccess | NotifyFilters.LastWrite | NotifyFilters.FileName | NotifyFilters.DirectoryName; _FileWatcher.Changed += new FileSystemEventHandler(mFileWatcher_Changed); //设置所有的Room Connect foreach (int FloorNumber in _FloorSet.FloorNumbers) { foreach (Room room in _FloorSet[FloorNumber].GetRooms()) { room.MyATM.Connect(); } } }
public DataProviderATMSimulator(FloorSet aFloorSet, SettingsBase aSetting) : base(aFloorSet, aSetting) { ProviderSetting = aSetting; //默认选项 _RS232.PortName = "COM2"; _RS232.DtrEnable = false; _RS232.RtsEnable = false; _RS232.DataBits = 8; _RS232.ReadTimeout = 500; //ms //_RS232. = Rs232.Mode.NonOverlapped; _RS232.ReadBufferSize = 1024; _RS232.WriteBufferSize = 1024; //mComm.EOFEnable=false; //mComm.Handshaking=HandshakeConstants.comNone; //None Handshakeing //mComm.InputMode=InputModeConstants.comInputModeBinary; //mComm.NullDiscard=false; //mComm.ParityReplace="?"; //mComm.RThreshold=1; //R 闸值 //mComm.SThreshold=0; //S 闸值 //应用选项 _RS232.PortName = "COM" + Convert.ToInt16(ProviderSetting["CommPort", 2]); if (!PaserSettings(ProviderSetting["Settings", "2400,e,8,1"].ToString())) { PaserSettings("2400,e,8,1"); } mTimeoutDelay = Convert.ToInt32(ProviderSetting["Timeout", 100]); mTimeOutTimer.Elapsed += new System.Timers.ElapsedEventHandler(mTimeOutTimer_Elapsed); _RS232.DataReceived += new SerialDataReceivedEventHandler(_RS232_DataReceived); _FloorSet = aFloorSet; }
/// <summary> /// Constructor of TcpConversation /// </summary> /// <param name="currentSocket"></param> /// <param name="tcpIPServer"></param> public TcpConversation(Socket currentSocket, TcpServer tcpIPServer) { _CreateTime = DateTime.Now; _LastActivityTime = DateTime.Now; _CurrentSocket = currentSocket; _Server = tcpIPServer; _CurrentSocket.Blocking = true; this._CommandTable.Add("GETFLOORSET", new _ProcessCommandHandler(this.GetFloorSet)); this._CommandTable.Add("COUNTFLOOR", new _ProcessCommandHandler(this.CountFloor)); this._CommandTable.Add("GETROOM", new _ProcessCommandHandler(this.GetRoom)); this._CommandTable.Add("GETROOMNUMBER", new _ProcessCommandHandler(this.GetRoomNumber)); this._CommandTable.Add("DISCONNECT", new _ProcessCommandHandler(this.Disconnect)); this._CommandTable.Add("CHECKOUT", new _ProcessCommandHandler(this.CheckOut)); this._CommandTable.Add("SETAIRCONON", new _ProcessCommandHandler(this.SetAirconOn)); this._CommandTable.Add("SETAIRCONOFF", new _ProcessCommandHandler(this.SetAirconOff)); this._CommandTable.Add("EMPTY", new _ProcessCommandHandler(this.Empty)); this._CommandTable.Add("RENT", new _ProcessCommandHandler(this.Rent)); this._CommandTable.Add("VERSION", new _ProcessCommandHandler(this.Version)); this._CommandTable.Add("WAKEUP", new _ProcessCommandHandler(this.WakeUp)); this._CommandTable.Add("BOOK", new _ProcessCommandHandler(this.Book)); this._CommandTable.Add("MAINTANENT", new _ProcessCommandHandler(this.Maintanent)); this._CommandTable.Add("VIP", new _ProcessCommandHandler(this.VIP)); this._CommandTable.Add("VACANT", new _ProcessCommandHandler(this.Vacant)); this._CommandTable.Add("SETLIGHTSYSTEMOFF", new _ProcessCommandHandler(this.SetLightSystemOff)); this._CommandTable.Add("SETLIGHTSYSTEMON", new _ProcessCommandHandler(this.SetLightSystemOn)); this._CommandTable.Add("SETSEASON", new _ProcessCommandHandler(this.SetAllRoomSeason)); _FloorSet = _Server.FloorSet; _RoomView = new RoomView(_FloorSet); _CurrentThread = new Thread(new ThreadStart(ConversationMain)); _CurrentThread.IsBackground = true; _CurrentThread.Start(); }
public TcpServer(FloorSet aFloorSet, SettingsBase theSetting) : base(aFloorSet, theSetting) { _FloorSet = aFloorSet; _Settings = theSetting; if (theSetting == null) { //从注册表的TCPIPAddress中获取数据源,若TCPIPAddress不存在则创建它并给数据赋初值 _TCPIPAddressSetting = (Settings)theSetting; _TCPIPAddressSetting["IP"] = "0.0.0.0"; _TCPIPAddressSetting["Port"] = "15000"; } else { _TCPIPAddressSetting = (Settings)theSetting; if (_TCPIPAddressSetting["IP"] == null) { _TCPIPAddressSetting["IP"] = "0.0.0.0"; theSetting.Save(); } if (_TCPIPAddressSetting["Port"] == null) { _TCPIPAddressSetting["Port"] = "15000"; } } _IP = IPAddress.Parse(_TCPIPAddressSetting["IP"].ToString()); _ServerIPEndPoint = new IPEndPoint(_IP, Int32.Parse(_TCPIPAddressSetting["Port"].ToString())); // Hashtable CmdHT=new Hashtable(); HandleEvents(); _DefaultInstance = this; }
public ConnectionScannerCOM(FloorSet aFloorSet, SettingsBase ConnectionSetting) : base(aFloorSet, ConnectionSetting) { //默认选项 _Port.Port = 1; _Port.Dtr = true; _Port.Rts = false; _Port.DataBit = 8; _Port.Timeout = 500; //ms _Port.WorkingMode = Rs232.Mode.NonOverlapped; _Port.BufferSize = 1024; PaserSettings("2400,e,8,1"); //mComm.EOFEnable=false; // mComm.Handshaking=HandshakeConstants.comNone; //None Handshakeing // mComm.InputMode=InputModeConstants.comInputModeBinary; //mComm.NullDiscard=false; //mComm.ParityReplace="?"; //mComm.RThreshold=5; //R 闸值 //mComm.SThreshold=0; //S 闸值 //载入自定义选项 //检查看看选项是否存在 mSettings = ConnectionSetting; if (ConnectionSetting["CommPort"] == null) { ConnectionSetting["CommPort"] = 1; } if (ConnectionSetting["Settings"] == null) { ConnectionSetting["Settings"] = "2400,e,8,1"; } if (ConnectionSetting["ReceiveDataRepeatTimes"] == null) { ConnectionSetting["ReceiveDataRepeatTimes"] = 5; } if (ConnectionSetting["ReceiveDataCheckDelay"] == null) { ConnectionSetting["ReceiveDataCheckDelay"] = 50; } if (ConnectionSetting["ReceiveDataCheckRepeatTimes"] == null) { ConnectionSetting["ReceiveDataCheckRepeatTimes"] = 5; } if (ConnectionSetting["DisconnectRetryTimes"] == null) { ConnectionSetting["DisconnectRetryTimes"] = 3; } //if (ConnectionSetting["WhetherSendTimeToATM"]==null) ConnectionSetting["WhetherSendTimeToATM"]="True"; if (ConnectionSetting["SendTimeToATMFrequency"] == null) { ConnectionSetting["SendTimeToATMFrequency"] = 5; } //应用选项 _Port.Port = Convert.ToInt16(ConnectionSetting["CommPort"]); if (!PaserSettings(ConnectionSetting["Settings"].ToString())) { PaserSettings("2400,e,8,1"); } _ReceiveDataRepeatTimes = Convert.ToInt32(ConnectionSetting["ReceiveDataRepeatTimes"]); mReceiveDataCheckDelay = Convert.ToInt32(ConnectionSetting["ReceiveDataCheckDelay"]); mSendTimeToATMFrequency = Convert.ToInt32(ConnectionSetting["SendTimeToATMFrequency"]); _ReceiveDataCheckRepeatTimes = Convert.ToInt32(ConnectionSetting["ReceiveDataCheckRepeatTimes"]); mDisconnectRetryTimes = Convert.ToInt32(ConnectionSetting["DisconnectRetryTimes"]); //mComm.OnComm+=new DMSCommEvents_OnCommEventHandler(mComm_OnComm); _Port.Timeout = mReceiveDataCheckDelay; if (mWhetherSendTimeToATM == true) { mSendTimeToATMTimer.Interval = mSendTimeToATMFrequency * 1000; mSendTimeToATMTimer.Elapsed += new System.Timers.ElapsedEventHandler(mSendTimeToATMTimer_Elapsed); } //其他 mFloorSet = aFloorSet; _CurrentRoom = mFloorSet.FirstFloor.FirstRoom; //设置所有的Room Connect foreach (int FloorNumber in mFloorSet.FloorNumbers) { for (int RoomNumber = 1; RoomNumber <= mFloorSet[FloorNumber].Length; RoomNumber++) { mFloorSet[FloorNumber][RoomNumber].MyATM.Connect(); } } }
public DataProviderManager(SettingsBase theSetting, FloorSet aFloorSet) { mSetting = theSetting; mFloorSet = aFloorSet; }
public DataProviderBase(FloorSet aFloorSet, SettingsBase aSetting) { }
public ConnectionBase(FloorSet floorSet, SettingsBase setting) { _FloorSet = floorSet; _Settings = setting; }
void SetNewDataToCell(int setCount, bool startState) { int collectionId = GetCollectionId(); if (startState == true) { collectionId = defaultFloor.defaultFloorCollection; } int columnNo; int columnCount; for (int width = 0; width < setCount; width++) { columnCount = floorSetup.floorSetCollection[collectionId].floorSetConf.Count; columnNo = GetColumnId(columnCount); if (columnNo == 1) { collectionId = GetCollectionId(); } FloorColumnDef floorColumnDef = floorSetup.floorSetCollection[collectionId].floorSetConf[columnNo]; FloorColumnSet floorList = floorSetup.floorColumnSetList[floorColumnDef.columnIndex]; int floorSetupListCount = floorList.floorSetList.Count; int floorObjectIndex = 0; int obstacleObjectIndex = 0; int index; for (int length = 0; length < modelLengthNumOnScreen; length++) { bool listDataMatchState = false; int name = GetName(length, presentBlockNum); FloorSet tempFloorSet = new FloorSet(); ObstacleTypes obstacleType = ObstacleTypes.NONE; FloorAttributes tempFloorAtt = FloorAttributes.FLOOR; if (floorObjectIndex < floorSetupListCount) { tempFloorSet = floorList.floorSetList[floorObjectIndex]; if (tempFloorSet.index == length) { tempFloorAtt = tempFloorSet.floorAttribute; if (tempFloorSet.obstacleType != ObstacleTypes.NONE && tempFloorSet.obstacleType != null) { obstacleType = tempFloorSet.obstacleType; } listDataMatchState = true; Floor.instance.SetToCell(tempFloorSet.floorType, name, obstacleType, tempFloorAtt); floorObjectIndex++; } } if (listDataMatchState == false) { tempFloorSet = defaultFloor.initFloor; Floor.instance.SetToCell(tempFloorSet.floorType, name, obstacleType, tempFloorAtt); listDataMatchState = true; } } int widthSize = GetWidthSize(presentBlockNum); // If ninjastar has existing if (floorColumnDef.ninjastarIndex != null && floorColumnDef.ninjastarIndex > 0) { if (tempStars.ContainsKey(widthSize) == false) { index = floorColumnDef.ninjastarIndex; NinjaStarManage tempNinjastar = new NinjaStarManage(); tempNinjastar.columnNumber = widthSize; tempNinjastar.ninjaStarSet = ninjastarSetup.ninjaStarSetList[index]; tempNinjastar.movingState = NinjastarState.NONE; tempNinjastar.starsCount = 0; tempStars.Add(widthSize, tempNinjastar); if (ninjastarSetup.ninjaStarSetList[index].position == FloorPosition.TOP) { int enemyLocation = GetName(3, presentBlockNum); Floor.instance.SetObstacleType(ObstacleTypes.SOLDIER, enemyLocation); } } } if (floorColumnDef.stickfloorIndex != null && floorColumnDef.stickfloorIndex > 0) { if (tempStickfloors.ContainsKey(widthSize) == false) { index = floorColumnDef.stickfloorIndex; StickfloorManage tempStickfloor = new StickfloorManage(); tempStickfloor.columnNumber = widthSize; tempStickfloor.idleTimeCount = 0f; tempStickfloor.stickfloorSet = stickfloorSetup.stickfloorSetList[index]; tempStickfloor.movingState = StickfloorState.NONE; tempStickfloor.leftStickfloor = 0; tempStickfloor.speedTimeCount = 0; tempStickfloors.Add(widthSize, tempStickfloor); } } if (floorColumnDef.flowingfloorId != null && floorColumnDef.flowingfloorId > 0) { if (tempFlowingfloors.ContainsKey(widthSize) == false) { index = floorColumnDef.flowingfloorId; FlowingfloorManage tempFlowingfloor = new FlowingfloorManage(); tempFlowingfloor.columnNumber = widthSize; tempFlowingfloor.flowingfloorSet = flowingfloorSetup.flowingfloorSetList[index]; tempFlowingfloor.movingState = FlowingfloorState.NONE; tempFlowingfloor.count = 0; tempFlowingfloors.Add(widthSize, tempFlowingfloor); } } if (floorColumnDef.rollingRockId != null && floorColumnDef.rollingRockId > 0) { if (tempRollingRocks.ContainsKey(widthSize) == false) { index = floorColumnDef.rollingRockId; RollingRockManage tempRollingRock = new RollingRockManage(); tempRollingRock.columnNumber = widthSize; tempRollingRock.rollingRockSet = rollingRockSetup.rollingRockSetList[index]; tempRollingRock.movingState = RollingRockState.NONE; tempRollingRock.rollingRockCount = 0; tempRollingRock.rollingRockStartState = true; tempRollingRocks.Add(widthSize, tempRollingRock); } } // Floor local position increase if (presentBlockNum < modelWidthNumOnScreen) { presentBlockNum++; } } }
public ConnectionScannerCOM(FloorSet aFloorSet, SettingsBase ConnectionSetting) : base(aFloorSet, ConnectionSetting) { //默认选项 _Port.PortName = "COM1"; _Port.DtrEnable = true; _Port.RtsEnable = false; _Port.DataBits = 8; _Port.ReadTimeout = 500; //ms PaserSettings("2400,e,8,1"); //mComm.EOFEnable=false; // mComm.Handshaking=HandshakeConstants.comNone; //None Handshakeing // mComm.InputMode=InputModeConstants.comInputModeBinary; //mComm.NullDiscard=false; //mComm.ParityReplace="?"; //mComm.RThreshold=5; //R 闸值 //mComm.SThreshold=0; //S 闸值 //载入自定义选项 //检查看看选项是否存在 _Settings = ConnectionSetting; if (ConnectionSetting["CommPort"] == null) { ConnectionSetting["CommPort"] = 1; } if (ConnectionSetting["Settings"] == null) { ConnectionSetting["Settings"] = "2400,e,8,1"; } if (ConnectionSetting["ReceiveDataRepeatTimes"] == null) { ConnectionSetting["ReceiveDataRepeatTimes"] = 5; } if (ConnectionSetting["ReceiveDataCheckDelay"] == null) { ConnectionSetting["ReceiveDataCheckDelay"] = 50; } if (ConnectionSetting["ReceiveDataCheckRepeatTimes"] == null) { ConnectionSetting["ReceiveDataCheckRepeatTimes"] = 5; } if (ConnectionSetting["DisconnectRetryTimes"] == null) { ConnectionSetting["DisconnectRetryTimes"] = 3; } //if (ConnectionSetting["WhetherSendTimeToATM"]==null) ConnectionSetting["WhetherSendTimeToATM"]="True"; if (ConnectionSetting["SendTimeToATMFrequency"] == null) { ConnectionSetting["SendTimeToATMFrequency"] = 5; } //应用选项 _Port.PortName = "COM" + Convert.ToInt16(ConnectionSetting["CommPort"]); if (!PaserSettings(ConnectionSetting["Settings"].ToString())) { PaserSettings("2400,e,8,1"); } _ReceiveDataRepeatTimes = Convert.ToInt32(ConnectionSetting["ReceiveDataRepeatTimes"]); _ReceiveDataCheckDelay = Convert.ToInt32(ConnectionSetting["ReceiveDataCheckDelay"]); _SendTimeToATMFrequency = Convert.ToInt32(ConnectionSetting["SendTimeToATMFrequency"]); _ReceiveDataCheckRepeatTimes = Convert.ToInt32(ConnectionSetting["ReceiveDataCheckRepeatTimes"]); _DisconnectRetryTimes = Convert.ToInt32(ConnectionSetting["DisconnectRetryTimes"]); //mComm.OnComm+=new DMSCommEvents_OnCommEventHandler(mComm_OnComm); _Port.ReadTimeout = _ReceiveDataCheckDelay; if (_WhetherSendTimeToATM == true) { _SendTimeToATMTimer.Interval = _SendTimeToATMFrequency * 1000; _SendTimeToATMTimer.Elapsed += new System.Timers.ElapsedEventHandler(mSendTimeToATMTimer_Elapsed); } //其他 _FloorSet = aFloorSet; _CurrentRoom = _FloorSet.FirstFloor.FirstRoom; //设置所有的Room Connect foreach (int floorNumber in _FloorSet.FloorNumbers) { foreach (Room room in _FloorSet[floorNumber].GetRooms()) { room.MyATM.Connect(); } } }
public ConnectionScannerBase(FloorSet floorSet, SettingsBase setting) : base(floorSet, setting) { _CurrentRoom = _FloorSet.FirstFloor.FirstRoom; }
public ConnectionScannerCOM(FloorSet aFloorSet, SettingsBase ConnectionSetting) : base(aFloorSet, ConnectionSetting) { //默认选项 mComm.CommPort = 1; mComm.DTREnable = false; mComm.EOFEnable = false; mComm.Handshaking = HandshakeConstants.comNone; //None Handshakeing mComm.InBufferSize = 1024; mComm.InputMode = InputModeConstants.comInputModeBinary; mComm.NullDiscard = false; mComm.OutBufferSize = 512; mComm.ParityReplace = "?"; mComm.RThreshold = 5; //R 闸值 mComm.RTSEnable = false; mComm.Settings = "2400,e,8,1"; mComm.SThreshold = 0; //S 闸值 //载入自定义选项 //检查看看选项是否存在 mSettings = ConnectionSetting; if (ConnectionSetting["CommPort"] == null) { ConnectionSetting["CommPort"] = 1; } if (ConnectionSetting["Settings"] == null) { ConnectionSetting["Settings"] = "2400,e,8,1"; } if (ConnectionSetting["ReceiveDataRepeatTimes"] == null) { ConnectionSetting["ReceiveDataRepeatTimes"] = 5; } if (ConnectionSetting["ReceiveDataCheckDelay"] == null) { ConnectionSetting["ReceiveDataCheckDelay"] = 50; } if (ConnectionSetting["ReceiveDataCheckRepeatTimes"] == null) { ConnectionSetting["ReceiveDataCheckRepeatTimes"] = 5; } if (ConnectionSetting["DisconnectRetryTimes"] == null) { ConnectionSetting["DisconnectRetryTimes"] = 3; } //if (ConnectionSetting["WhetherSendTimeToATM"]==null) ConnectionSetting["WhetherSendTimeToATM"]="True"; if (ConnectionSetting["SendTimeToATMFrequency"] == null) { ConnectionSetting["SendTimeToATMFrequency"] = 5; } //应用选项 mComm.CommPort = Convert.ToInt16(ConnectionSetting["CommPort"]); mComm.Settings = (string)ConnectionSetting["Settings"]; mReceiveDataRepeatTimes = Convert.ToInt32(ConnectionSetting["ReceiveDataRepeatTimes"]); mReceiveDataCheckDelay = Convert.ToInt32(ConnectionSetting["ReceiveDataCheckDelay"]); mSendTimeToATMFrequency = Convert.ToInt32(ConnectionSetting["SendTimeToATMFrequency"]); mReceiveDataCheckRepeatTimes = Convert.ToInt32(ConnectionSetting["ReceiveDataCheckRepeatTimes"]); mDisconnectRetryTimes = Convert.ToInt32(ConnectionSetting["DisconnectRetryTimes"]); mScannerTimeout.Interval = mReceiveDataCheckDelay; mScannerTimeout.Elapsed += new System.Timers.ElapsedEventHandler(mScannerTimeout_Elapsed); mScanNextRoomDelay.Interval = mReceiveDataCheckDelay; mScanNextRoomDelay.Elapsed += new System.Timers.ElapsedEventHandler(mScanNextRoomDelay_Elapsed); mComm.OnComm += new DMSCommEvents_OnCommEventHandler(mComm_OnComm); if (mWhetherSendTimeToATM == true) { mSendTimeToATMTimer.Interval = mSendTimeToATMFrequency * 1000; mSendTimeToATMTimer.Elapsed += new System.Timers.ElapsedEventHandler(mSendTimeToATMTimer_Elapsed); } //其他 mFloorSet = aFloorSet; mCurrentRoom = mFloorSet.FirstFloor.FirstRoom; //设置所有的Room Connect foreach (int FloorNumber in mFloorSet.FloorNumbers) { for (int RoomNumber = 1; RoomNumber <= mFloorSet[FloorNumber].Length; RoomNumber++) { mFloorSet[FloorNumber][RoomNumber].MyATM.Connect(); } } }
public ConnectionScannerCOM(FloorSet aFloorSet, SettingsBase ConnectionSetting, SettingsBase ProgramSetting) : base(aFloorSet, ConnectionSetting) { }
private ConnectionBase CreateConnection(FloorSet allFloorSet, SettingsBase connectionSetting) { // Parser the floor info from the settings FloorSet newConnectionFloorSet; string[] floorInfo; if (connectionSetting["FloorSet"].ToString().Contains("L")) { // Use old parser method floorInfo = ((string)connectionSetting["FloorSet"]).Split(new char[] { 'F', 'L' }); // First Detect the FloorNumber has exist and the value is correct for (int i = 0, FloorNumber, FloorLength; i <= (floorInfo.Length / 2) - 1; i++) { FloorNumber = Convert.ToInt32(floorInfo[i * 2 + 1]); FloorLength = Convert.ToInt32(floorInfo[i * 2 + 2]); if ((allFloorSet[FloorNumber] != null) || (FloorLength <= 0) || (FloorLength >= 100)) { throw new ApplicationException("Settings中的楼层值有错误!"); } } // Start to create FloorSet newConnectionFloorSet = new FloorSet(); for (int i = 0; i <= (floorInfo.Length / 2) - 1; i++) { Floor floor = new Floor(Convert.ToInt32(floorInfo[i * 2 + 1]), Convert.ToInt32(floorInfo[i * 2 + 2])); newConnectionFloorSet.Add(floor); allFloorSet.Add(floor); } } else { // Use new parser method floorInfo = connectionSetting["FloorSet"].ToString().Split(new char[] { 'F' }, StringSplitOptions.RemoveEmptyEntries); // Parser each floor's room information Dictionary <int, int[]> roomNumberInfo = new Dictionary <int, int[]>(); for (int floorIndex = 0; floorIndex < floorInfo.Length; floorIndex++) { string[] roomInfo = floorInfo[floorIndex].Split('R'); // Obtain floor number int floorNumber = int.Parse(roomInfo[0]); if (allFloorSet[floorNumber] != null) { Trace.WriteLine(string.Format( "Settings:{0} contains duplicated floor {1}", connectionSetting["Name"], floorNumber), "Connection"); throw new ApplicationException("Settings中的楼层值有错误!"); } // Obtain room numbers List <int> rooms = new List <int>(); for (int roomIndex = 1; roomIndex < roomInfo.Length; roomIndex++) { int newRoomNumber = int.Parse(roomInfo[roomIndex]); if ((newRoomNumber <= 0) || (newRoomNumber >= 100) || rooms.Contains(newRoomNumber)) { Trace.WriteLine(string.Format( "Settings:{0} contains illegal room {1}", connectionSetting["Name"], floorNumber), "Connection"); throw new ApplicationException("Settings中的楼层值有错误!"); } rooms.Add(newRoomNumber); } roomNumberInfo.Add(floorNumber, rooms.ToArray()); } // Create new floor set for the new connection newConnectionFloorSet = new FloorSet(); foreach (KeyValuePair <int, int[]> floorRoomInfo in roomNumberInfo) { Floor floor = new Floor(floorRoomInfo.Key, floorRoomInfo.Value); newConnectionFloorSet.Add(floor); allFloorSet.Add(floor); } } // Create new Connection ConnectionBase newConnection = null; string newConnectionTypeName = connectionSetting["Type"].ToString(); if (_ConnectionTypes[newConnectionTypeName] != null) { newConnection = ((ConnectionType)_ConnectionTypes[newConnectionTypeName]).CreateConnection(newConnectionFloorSet, connectionSetting); } else { throw new Exception("Settings中含有未知的协议"); } return(newConnection); }
public ConnectionNewCANBus(FloorSet aFloorSet, SettingsBase ConnectionSettings) : base(aFloorSet, ConnectionSettings) { }
public ConnectionBase CreateConnection(FloorSet floorSt, SettingsBase settings) { return((ConnectionBase)Activator.CreateInstance(_Type, new object[] { floorSt, settings })); }