contract Control is Permissions {

  address payable public withdrawalAddress;
  bool public pause;
 

  function setS1Global(address _addr) external onlyPermits returns(bool){
        S1Global  s1 = S1Global(_addr);
        for(uint256 i=0;i<s1.getAllMaxAddr();i++){
            addPermit(s1.getAddress(i));
        }
  }

  function addPermit(address _addr) public onlyPermits{
    require(permits[_addr] == false);
    permits[_addr] = true;
    emit AddPermit(_addr);
  }


  function removePermit(address _addr) public onlyPermits{
    require(_addr != msg.sender);
    permits[_addr] = false;
    emit RemovePermit(_addr);
  }

  function setWithdrawalAddress(address payable _newWithdrawalAddress) external onlyPermits {
    require(_newWithdrawalAddress != address(0));
    withdrawalAddress = _newWithdrawalAddress;
  }

 
  function withdrawBalance() external onlyPermits {
    require(withdrawalAddress != address(0));
    withdrawalAddress.transfer(address(this).balance);
  }
  
  function withdrawToken(uint256 amount,address conAddr)external onlyPermits {
        require(pause == false);
        require(withdrawalAddress != address(0));
        ERC20  erc20Token = ERC20(conAddr);
        erc20Token.transfer(withdrawalAddress,amount);
  }

//Emegency Pause Contract;
  function stopContract() external onlyPermits{
      pause = true;
  }

}
function stopContract() external onlyPermits{
    pause = true;
}

//Emegency Pause Contract;