Пример #1
0
void ItemAttributeMgr::SetRealEx(Attr attr, const real_t &v, bool persist) {
    // first check if it can be stored as integer
    if(_IsInt(v)) {
        // store as integer
        SetIntEx(attr, static_cast<int32>(v), persist);
    } else {
        // store as real
        PyRep *oldValue = NULL;
        if(GetNotify() == true && !IsRechargable(attr)) {
            // get old value
            oldValue = PyGet(attr);
        }
        // set the attribute value
        EVEAdvancedAttributeMgr::SetReal(attr, v);
        // check if we shall save to DB
        if(GetSave() == true && (persist || IsPersistent(attr))) {
            // save to DB
            m_factory.db().UpdateAttribute_double(m_item.itemID(), attr, v);
        }
        if(GetNotify() == true) {
            std::map<Attr, TauCap>::const_iterator i = m_tauCap.find(attr);
            if(i != m_tauCap.end()) {
                // build the special list for rechargables
                PyList *l = new PyList;

                l->AddItemReal( v );
                l->AddItemLong( Win32TimeNow() );
                l->AddItem( _PyGet( GetReal( i->second.tau ) / 5.0 ) );
                l->AddItem( PyGet( i->second.cap ) );

                oldValue = l;
            }
            // send change
            _SendAttributeChange(attr, oldValue, new PyFloat(v));
        }
    }
}
Пример #2
0
// Initialize
void NmEditVhOptionInit(HWND hWnd, SM_HUB *r)
{
	char tmp[MAX_SIZE];
	VH_OPTION t;
	// Validate arguments
	if (hWnd == NULL || r == NULL)
	{
		return;
	}

	SetIcon(hWnd, 0, ICO_ROUTER);

	FormatText(hWnd, S_TITLE, r->HubName);

	Zero(&t, sizeof(VH_OPTION));
	StrCpy(t.HubName, sizeof(t.HubName), r->HubName);
	if (CALL(hWnd, ScGetSecureNATOption(r->Rpc, &t)) == false)
	{
		EndDialog(hWnd, false);
		return;
	}

	if (GetCapsBool(r->p->CapsList, "b_virtual_nat_disabled"))
	{
		SetEnable(hWnd, R_USE_NAT, false);
		Check(hWnd, R_USE_NAT, false);
	}

	MacToStr(tmp, sizeof(tmp), t.MacAddress);
	SetTextA(hWnd, E_MAC, tmp);
	IpSet(hWnd, E_IP, IPToUINT(&t.Ip));
	IpSet(hWnd, E_MASK, IPToUINT(&t.Mask));

	Check(hWnd, R_USE_NAT, t.UseNat);
	SetIntEx(hWnd, E_MTU, t.Mtu);
	SetIntEx(hWnd, E_TCP, t.NatTcpTimeout);
	SetIntEx(hWnd, E_UDP, t.NatUdpTimeout);

	Check(hWnd, R_USE_DHCP, t.UseDhcp);
	IpSet(hWnd, E_DHCP_START, IPToUINT(&t.DhcpLeaseIPStart));
	IpSet(hWnd, E_DHCP_END, IPToUINT(&t.DhcpLeaseIPEnd));
	IpSet(hWnd, E_DHCP_MASK, IPToUINT(&t.DhcpSubnetMask));
	SetIntEx(hWnd, E_EXPIRES, t.DhcpExpireTimeSpan);

	if (IPToUINT(&t.DhcpGatewayAddress) != 0)
	{
		IpSet(hWnd, E_GATEWAY, IPToUINT(&t.DhcpGatewayAddress));
	}

	if (IPToUINT(&t.DhcpDnsServerAddress) != 0)
	{
		IpSet(hWnd, E_DNS, IPToUINT(&t.DhcpDnsServerAddress));
	}

	if (IPToUINT(&t.DhcpDnsServerAddress2) != 0)
	{
		IpSet(hWnd, E_DNS2, IPToUINT(&t.DhcpDnsServerAddress2));
	}

	SetTextA(hWnd, E_DOMAIN, t.DhcpDomainName);
	Check(hWnd, R_SAVE_LOG, t.SaveLog);

	StrCpy(r->CurrentPushRouteStr, sizeof(r->CurrentPushRouteStr), t.DhcpPushRoutes);

	if (GetCapsBool(r->p->CapsList, "b_suppport_push_route_config") == false)
	{
		Disable(hWnd, S_1);
		Disable(hWnd, S_2);
		Disable(hWnd, B_PUSH);
	}

	NmEditVhOptionUpdate(hWnd, r);

}