예제 #1
0
파일: iodev.cpp 프로젝트: vanessaorgua/lib
void IoDev::sendValueScaled(QString tag,double v)
{
    if(tags.contains(tag))
    {
        //qDebug() << "sendValueScaled: tag -" <<  tag << "type:" << tags[tag][2] << " ; value :" << v ;
        QVector<qint16> t(2);
        data_scale[tag][0]=v;
        v=((v-data_scale[tag][1])/(data_scale[tag][2] - data_scale[tag][1]) *4000.0 );

        switch(tags[tag][2]) // тип даних
            {
                default:
                case 0: // Integer
                    sendValue(tag,qint16(v));
                    break;
                case 1: // Bool
                    break;
                case 2: // Real
                    sendValue(tag,v);
                    break;
                case 3: // Timer
                case 4: // Long
                    sendValue(tag,qint32(v));
                    break;
            }


    }
    else
        qDebug() << "Tag not found " << tag;

}
예제 #2
0
파일: LCD5110.cpp 프로젝트: a-dma/LCD5110
/**
 * Send out an inverted caracter at the current cursor position
 * @param c The character to be printed
 */
void LCD5110::sendInvertedChar(byte c){

  sendValue(LCD5110::DATA, 0xFF);
  for(int i = 0; i < 5; i++)
    sendValue(LCD5110::DATA, 0xFF - LCD5110::ASCII[c - 0x20][i]);
  sendValue(LCD5110::DATA, 0xFF);

}
예제 #3
0
파일: LCD5110.cpp 프로젝트: a-dma/LCD5110
/**
 * Send out a caracter at the current cursor position
 * @param c The character to be printed
 */
void LCD5110::sendChar(byte c){

  sendValue(LCD5110::DATA, 0x00);
  for(int i = 0; i < 5; i++)
    sendValue(LCD5110::DATA, LCD5110::ASCII[c - 0x20][i]);
  sendValue(LCD5110::DATA, 0x00);

}
예제 #4
0
파일: LCD5110.cpp 프로젝트: a-dma/LCD5110
/**
 * Activate or deactivate inverse video mode
 * @param b Inverse video setting
 */
void LCD5110::setInverseVideo(boolean b){

  if (b)
    sendValue(LCD5110::COMMAND, 0x0D);
  else
    sendValue(LCD5110::COMMAND, 0x0C);

}
예제 #5
0
파일: LCD5110.cpp 프로젝트: a-dma/LCD5110
/**
 * Set the cursor to the character at coordinates (X,Y)
 * @param x The x coordinate [0:X_CHARS-1]
 * @param y Tee y coordinate [0:Y_CHARS-1]
 */
void LCD5110::setXYChar(byte x, byte y){

  /* Check for onscreen values */
  if (x >= LCD5110::X_CHARS || y >= LCD5110::Y_CHARS)
    return;

  sendValue(LCD5110::COMMAND, 0x80|(x*LCD5110::CHAR_WIDTH));
  sendValue(LCD5110::COMMAND, 0x40|y);

}
예제 #6
0
void FrSkySPort::sendData(IFrSkyDataProvider* dataProvider)
{
    static uint8_t counter ;
    switch ( counter)
    {
    case 0 :
        sendValue(VARIO_ID, dataProvider->getTemp1());
        break;

    case 1 :
        sendValue(ALT_ID, dataProvider->getAltitude());
        break;
    }
    counter = (counter + 1) & 1 ;
}
예제 #7
0
파일: gameframe.cpp 프로젝트: jpleau/sudoqu
void GameFrame::setAt(int pos, int val, bool send_network) {
    board[static_cast<size_t>(pos)] = val;
    if (send_network) {
        emit sendValue(pos, val);
    }
    notes[pos].clear();
}
예제 #8
0
파일: watering.cpp 프로젝트: twd2/SmartD
void water(double moisture)
{
  if (moisture < MOISTURE_THRESHOLD) // watering is needed
  {
    auto errorCode = waterDo(WATER_DURATION);
    DBG("Sending error code: ");
    sendValue(TYPE_Watered, errorCode);
  }
}
예제 #9
0
파일: MidiRouter.cpp 프로젝트: t3kt/memory
 MidiBinding(const MidiMappingKey& key,
             TParam<T>& param,
             std::shared_ptr<MidiDevice> device)
 : _key(key)
 , _param(param)
 , _device(device) {
   _param.changed.addListener([&](T&) {
     sendValue();
   }, this);
 }
void OpenDeviceClass::setValue(uint8_t id, value_t value){

    for (int i = 0; i < deviceLength; i++) {
    	if(devices[i]->id == id){
    		devices[i]->setValue(value, false);
    		sendValue(devices[i]);
    		break;
    	}
    }
}
예제 #11
0
void loop()
{ 
  if (Serial.available() > 0)
      {                                               // Check serial buffer for characters
           if (Serial.read() == 'r')
               {                                      // If an 'r' is received then read the pins
               for (int pin= 0; pin<=5; pin++)
                        {                             //   Read and send analog pins 0-5
                        x = 1024-analogRead(pin);
                        sendValue (x);
                        }
               for (int pin= 2; pin<=13; pin++)
                        {                             // Read and send digital pins 2-13
                        x = digitalRead(pin);
                        sendValue (x);
                        }
               Serial.println();                      // Send a carriage returnt to mark end of pin data. 
               delay (5);                             // add a delay to prevent crashing/overloading of the serial port
               }
       }
}
예제 #12
0
void flowControl::updateChannel(Channel * c) {
    // data format is channel number int; air pressure float 0-1, water pressure float 0-1, air open bool, water open bool,
    
    int ci;
    int ard = 0;
    
    if (c->i > 2 && c->i < 4) {
        ci = c->i - 3;
        ard = 1;
    } else if (c->i > 4) {
        ci = c->i - 6;
        ard = 2;
    }
    
    sendValue('c', ci, &arduino[ard]);    
    
    sendValue('p', 100, &arduino[ard]);
    //sendValue('s', ofMap(c->waterPressure, 0, 1, 0, 255), &arduino[ard]);
    sendValue('a', c->airOpen, &arduino[ard]);
    sendValue('w', c->waterOpen, &arduino[ard]); // hard coded ex
    
}
예제 #13
0
파일: LCD5110.cpp 프로젝트: a-dma/LCD5110
 /**
 * Set the pins mode, reset the display and put it in non-inverted video mode
 */
void LCD5110::init(void){

  /* Set pins mode */
  pinMode(sclk_pin, OUTPUT);
  pinMode(sdin_pin, OUTPUT);
  pinMode(dc_pin, OUTPUT);
  pinMode(reset_pin, OUTPUT);
  pinMode(sce_pin, OUTPUT);
  pinMode(led_pin, OUTPUT);

  reset(); /* Reset the display */
  sendValue(LCD5110::COMMAND, 0x20); /* Set PD (power down) off */
  setInverseVideo(false);
  clearScreen();

}
void ZmqClientProcess::send(GenericSendMessage &message, EventHandler &handler) {
    m_zmqMutex.lock();
    if (m_isAlive) {
        switch (message.type) {
        case None: {
            throw std::invalid_argument("Message type must not be 'None'");
            break;
        }
        case Track: {
            auto &m = static_cast<SendTrackMessage &>(message);
            track(m, handler);
            break;
        }
        case Paint: {
            auto &m = static_cast<SendPaintMessage &>(message);
            paint(m, handler);
            break;
        }
        case PaintOverlay: {
            auto &m = static_cast<SendPaintOverlayMessage &>(message);
            paintOverlay(m, handler);
            break;
        }
        case RequestTools: {
            auto &m = static_cast<SendRequestWidgetsMessage &>(message);
            requestTools(m, handler);
            break;
        }
        case ButtonClick: {
            auto &m = static_cast<SendButtonClickMessage &>(message);
            buttonClicked(m, handler);
            break;
        }
        case ValueChanged: {
            auto &m = static_cast<SendValueChangedMessage &>(message);
            sendValue(m, handler);
            break;
        }
        }
    }
    m_zmqMutex.unlock();
}
void CANGenPlugin::setValue(libwebsocket* socket, const std::string& property, const std::string& value, int zone, const std::string& interface, const std::string& transactionId)
{
    LOG_MESSAGE( "CANGenPlugin::setValue called with arguments:" << property << ", " << value << endl);

    bool sent(false);
    std::unique_ptr<AbstractPropertyType> type(VehicleProperty::getPropertyTypeForPropertyNameValue(property,value));
    if(type) {
        type->zone = zone;
        type->sourceUuid = CANSimPluginUUID;

        sent = sendValue(interface, type.get());
    }

    stringstream ss;
    ss << "{\"type\":\"methodReply\",\"name\":\"set\",\"data\":[{\"property\":\"" << property << "\"}],\"transactionid\":\"" << transactionId << "\"";
    if(!sent)
        ss << ",\"error\":\"method call failed\"";
    ss << "}";

    string replystr = ss.str();
    LOG_MESSAGE( "Reply:" << replystr << endl);

    WebSockets::Write(socket, replystr);
}
예제 #16
0
파일: DataPush.cpp 프로젝트: ZaaaV/domoticz
std::string CDataPush::ProcessSendValue(std::string rawsendValue, int delpos, int nValue, int includeUnit, int metertypein)
{
	
	std::string vType = DropdownOptionsValue(DeviceRowIdx,delpos);
	unsigned char tempsign=m_sql.m_tempsign[0];
	_eMeterType metertype = (_eMeterType) metertypein;
	char szData[100]= "";

	if ((vType=="Temperature") || (vType=="Temperature 1") || (vType=="Temperature 2")|| (vType == "Set point"))
	{
		double tvalue=ConvertTemperature(atof(rawsendValue.c_str()),tempsign);
		if (includeUnit) {
			sprintf(szData,"%.1f %c", tvalue,tempsign);
		}
		else {
			sprintf(szData,"%.1f", tvalue);
		}
	
	}
	else if (vType == "Humidity")
	{
		if (includeUnit) {
			sprintf(szData,"%d %%", atoi(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%d", atoi(rawsendValue.c_str()));
		}

	}
	else if (vType == "Humidity Status")
	{
			sprintf(szData,"%s", RFX_Humidity_Status_Desc(atoi(rawsendValue.c_str())));	
	}
	else if (vType == "Barometer")
	{
		if (includeUnit) {
			sprintf(szData,"%.1f hPa", atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f", atof(rawsendValue.c_str()));
		}

	}
	else if (vType == "Forecast")
	{
		int forecast=atoi(rawsendValue.c_str());
		if (forecast!=baroForecastNoInfo)
		{
			sprintf(szData,"%s", RFX_Forecast_Desc(forecast));
		}
		else {
			sprintf(szData,"%d", forecast);
		}
	}
	else if (vType == "Altitude")
	{
		sprintf(szData,"Not supported yet");
	}

	else if (vType == "UV")
	{
		float UVI=(float)atof(rawsendValue.c_str());
		if (includeUnit) {
			sprintf(szData,"%.1f UVI",UVI);
		}
		else {
			sprintf(szData,"%.1f",UVI);
		}
	}
	else if (vType == "Direction")
	{
		float Direction = (float)atof(rawsendValue.c_str());
		if (includeUnit) {
			sprintf(szData,"%.1f Degrees",Direction); 
		}
		else {
			sprintf(szData,"%.1f",Direction); 
		}
	}
	else if (vType == "Direction string")
	{
		sprintf(szData,"%s",rawsendValue.c_str());
	}
	else if (vType == "Speed")
	{
		int intSpeed=atoi(rawsendValue.c_str());
		if (includeUnit) {
			sprintf(szData,"%.1f",float(intSpeed) * m_sql.m_windscale); //todo: unit?
		}
		else {
			sprintf(szData,"%.1f",float(intSpeed) * m_sql.m_windscale);
		}
	}
	else if (vType == "Gust")
	{
		int intGust=atoi(rawsendValue.c_str());
		if (includeUnit) {
			sprintf(szData,"%.1f",float(intGust) *m_sql.m_windscale); //todo: unit?
		}
		else {
			sprintf(szData,"%.1f",float(intGust) *m_sql.m_windscale);
		}
	}
	else if (vType == "Chill")
	{
		double tvalue=ConvertTemperature(atof(rawsendValue.c_str()),tempsign);
		if (includeUnit) {
			sprintf(szData,"%.1f %c", tvalue,tempsign);
		}
		else {
			sprintf(szData,"%.1f", tvalue);
		}
	}
	else if (vType == "Rain rate")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Total rain")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if (vType == "Counter")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if (vType == "Mode")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Status")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if ((vType == "Current 1") || (vType == "Current 2") || (vType == "Current 3"))
	{
		sprintf(szData,"Not supported yet");
	}	
	else if (vType == "Instant")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if ((vType == "Usage") || (vType == "Usage 1") || (vType == "Usage 2") )
	{
		if (includeUnit) {
			sprintf(szData,"%.1f Watt",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
		}
	}	
	else if ((vType == "Delivery") || (vType == "Delivery 1") || (vType == "Delivery 2") )
	{
		if (includeUnit) {
			sprintf(szData,"%.1f Watt",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
		}
	}

	else if (vType == "Usage current")
	{
		if (includeUnit) {
			sprintf(szData,"%.1f Watt",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
		}
	}
	else if (vType == "Delivery current")
	{
		if (includeUnit) {
			sprintf(szData,"%.1f Watt",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
		}
	}
	else if (vType == "Gas usage")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Weight")
	{
		if (includeUnit) {
			sprintf(szData,"%.1f kg",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
		}
	}	
	else if (vType == "Voltage")
	{
		if (includeUnit) {
			sprintf(szData,"%.3f V",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.3f",atof(rawsendValue.c_str()));
		}
	}
	else if (vType == "Value")
	{
		sprintf(szData,"%d", atoi(rawsendValue.c_str())); //??
	}
	else if (vType == "Visibility")
	{
		float vis=(float)atof(rawsendValue.c_str());
		if (includeUnit) {
			if (metertype==0)
			{
				//km
				sprintf(szData,"%.1f km",vis);
			}
			else
			{
				//miles
				sprintf(szData,"%.1f mi",vis*0.6214f);
			}
		}
		else {
			if (metertype==0)
			{
				//km
				sprintf(szData,"%.1f",vis);
			}
			else
			{
				//miles
				sprintf(szData,"%.1f",vis*0.6214f);
			}
		}
	}
	else if (vType == "Solar Radiation")
	{
		float radiation=(float)atof(rawsendValue.c_str());
		if (includeUnit) {
			sprintf(szData,"%.1f Watt/m2",radiation);
		}
		else {
			sprintf(szData,"%.1f",radiation);
		}
	}
	else if (vType == "Soil Moisture")
	{
		if (includeUnit) {
			sprintf(szData,"%d cb",nValue);
		}
		else {
			sprintf(szData,"%d",nValue);
		}
	}
	else if (vType == "Leaf Wetness")
	{
		sprintf(szData,"%d",nValue);
	}
	else if (vType == "Percentage")
	{
		if (includeUnit) {
			sprintf(szData,"%.2f%%",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.2f",atof(rawsendValue.c_str()));
		}
	}
	else if (vType == "Fanspeed")
	{
		if (includeUnit) {
			sprintf(szData,"%d RPM",atoi(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%d",atoi(rawsendValue.c_str()));
		}
	}
	else if (vType == "Pressure")
	{
		if (includeUnit) {
			sprintf(szData,"%.1f Bar",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
		}
	}
	else if (vType == "Lux")
	{
		if (includeUnit) {
			sprintf(szData,"%.0f Lux",atof(rawsendValue.c_str()));
		}
		else {
			sprintf(szData,"%.0f",atof(rawsendValue.c_str()));
		}
	}
	if (szData[0] != '\0') { 
		std::string sendValue(szData);
		return sendValue;
	}
	else {
		_log.Log(LOG_ERROR,"Could not determine data push value");
		return "";
	}
}
예제 #17
0
std::string CPush::ProcessSendValue(const std::string &rawsendValue, const int delpos, const int nValue, const int includeUnit, const int metertypein)
{
	std::string vType = DropdownOptionsValue(m_DeviceRowIdx,delpos);
	unsigned char tempsign=m_sql.m_tempsign[0];
	_eMeterType metertype = (_eMeterType) metertypein;
	char szData[100]= "";

	std::string unit = getUnit(delpos, metertypein);

	if ((vType=="Temperature") || (vType=="Temperature 1") || (vType=="Temperature 2")|| (vType == "Set point"))
	{
		double tvalue=ConvertTemperature(atof(rawsendValue.c_str()),tempsign);
		sprintf(szData,"%.1f", tvalue);
	}
	else if (vType == "Concentration")
	{
		sprintf(szData,"%d", nValue);
	}
	else if (vType == "Humidity")
	{
		sprintf(szData,"%d", atoi(rawsendValue.c_str()));
	}
	else if (vType == "Humidity Status")
	{
		sprintf(szData,"%s", RFX_Humidity_Status_Desc(atoi(rawsendValue.c_str())));	
	}
	else if (vType == "Barometer")
	{
		sprintf(szData,"%.1f", atof(rawsendValue.c_str()));
	}
	else if (vType == "Forecast")
	{
		int forecast=atoi(rawsendValue.c_str());
		if (forecast!=baroForecastNoInfo)
		{
			sprintf(szData,"%s", RFX_Forecast_Desc(forecast));
		}
		else {
			sprintf(szData,"%d", forecast);
		}
	}
	else if (vType == "Altitude")
	{
		sprintf(szData,"Not supported yet");
	}

	else if (vType == "UV")
	{
		float UVI = static_cast<float>(atof(rawsendValue.c_str()));
		sprintf(szData,"%.1f",UVI);
	}
	else if (vType == "Direction")
	{
		float Direction = static_cast<float>(atof(rawsendValue.c_str()));
		sprintf(szData,"%.1f",Direction); 
	}
	else if (vType == "Direction string")
	{
		sprintf(szData,"%s",rawsendValue.c_str());
	}
	else if (vType == "Speed")
	{
		int intSpeed = atoi(rawsendValue.c_str());
		if (m_sql.m_windunit != WINDUNIT_Beaufort)
		{
			sprintf(szData, "%.1f", float(intSpeed) * m_sql.m_windscale);
		}
		else
		{
			float speedms = float(intSpeed)*0.1f;
			sprintf(szData, "%d", MStoBeaufort(speedms));
		}
	}
	else if (vType == "Gust")
	{
		int intGust=atoi(rawsendValue.c_str());
		if (m_sql.m_windunit != WINDUNIT_Beaufort)
		{
			sprintf(szData, "%.1f", float(intGust) *m_sql.m_windscale);
		}
		else
		{
			float gustms = float(intGust)*0.1f;
			sprintf(szData, "%d", MStoBeaufort(gustms));
		}
	}
	else if (vType == "Chill")
	{
		double tvalue=ConvertTemperature(atof(rawsendValue.c_str()),tempsign);
		sprintf(szData,"%.1f", tvalue);
	}
	else if (vType == "Rain rate")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Total rain")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if (vType == "Counter")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if (vType == "Mode")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Status")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if ((vType == "Current 1") || (vType == "Current 2") || (vType == "Current 3"))
	{
		sprintf(szData,"Not supported yet");
	}	
	else if (vType == "Instant")
	{
		sprintf(szData,"Not supported yet");
	}	
	else if ((vType == "Usage") || (vType == "Usage 1") || (vType == "Usage 2") )
	{
		sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
	}	
	else if ((vType == "Delivery") || (vType == "Delivery 1") || (vType == "Delivery 2") )
	{
		sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
	}
	else if (vType == "Usage current")
	{
		sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
	}
	else if (vType == "Delivery current")
	{
		sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
	}
	else if (vType == "Gas usage")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Weight")
	{
		sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
	}	
	else if (vType == "Voltage")
	{
		sprintf(szData,"%.3f",atof(rawsendValue.c_str()));
	}
	else if (vType == "Value")
	{
		sprintf(szData,"%d", atoi(rawsendValue.c_str())); //??
	}
	else if (vType == "Visibility")
	{
		float vis = static_cast<float>(atof(rawsendValue.c_str()));
		if (metertype==0)
		{
			//km
			sprintf(szData,"%.1f",vis);
		}
		else
		{
			//miles
			sprintf(szData,"%.1f",vis*0.6214f);
		}
	}
	else if (vType == "Solar Radiation")
	{
		float radiation = static_cast<float>(atof(rawsendValue.c_str()));
		sprintf(szData,"%.1f",radiation);
	}
	else if (vType == "Soil Moisture")
	{
		sprintf(szData,"%d",nValue);
	}
	else if (vType == "Leaf Wetness")
	{
		sprintf(szData,"%d",nValue);
	}
	else if (vType == "Percentage")
	{
		sprintf(szData,"%.2f",atof(rawsendValue.c_str()));
	}
	else if (vType == "Fanspeed")
	{
		sprintf(szData,"%d",atoi(rawsendValue.c_str()));
	}
	else if (vType == "Pressure")
	{
		sprintf(szData,"%.1f",atof(rawsendValue.c_str()));
	}
	else if (vType == "Lux")
	{
		sprintf(szData,"%.0f",atof(rawsendValue.c_str()));
	}
	if (szData[0] != '\0') { 
		std::string sendValue(szData);
		if (includeUnit) {
			sendValue+=" ";
			sendValue+=unit;
		}
		return sendValue;
	}
	else {
		_log.Log(LOG_ERROR,"Could not determine data push value");
		return "";
	}
}
예제 #18
0
std::string CPush::getUnit(const int delpos, const int metertypein)
{
	std::string vType = DropdownOptionsValue(m_DeviceRowIdx,delpos);
	unsigned char tempsign=m_sql.m_tempsign[0];
	_eMeterType metertype = (_eMeterType) metertypein;
	char szData[100]= "";

	if ((vType=="Temperature") || (vType=="Temperature 1") || (vType=="Temperature 2")|| (vType == "Set point"))
	{
		sprintf(szData,"%c", tempsign);
	}
	else if (vType == "Humidity")
	{
		strcpy(szData,"%%");
	}
	else if (vType == "Humidity Status")
	{
		strcpy(szData, "");
	}
	else if (vType == "Barometer")
	{
		strcpy(szData, "hPa");
	}
	else if (vType == "Forecast")
	{
		strcpy(szData, "");
	}
	else if (vType == "Altitude")
	{
		strcpy(szData, "");
	}
	else if (vType == "UV")
	{
		strcpy(szData, "UVI");
	}
	else if (vType == "Direction")
	{
		strcpy(szData, "Degrees");
	}
	else if (vType == "Direction string")
	{
		strcpy(szData, "");
	}
	else if (vType == "Speed")
	{
		strcpy(szData, "");//todo: unit?
	}
	else if (vType == "Gust")
	{
		strcpy(szData, "");//todo: unit?
	}
	else if (vType == "Chill")
	{
		sprintf(szData, "%c", tempsign);
	}
	else if (vType == "Rain rate")
	{
		sprintf(szData,"Not supported yet");
	}
	else if (vType == "Total rain")
	{
		strcpy(szData, "");
	}	
	else if (vType == "Counter")
	{
		strcpy(szData, "");
	}	
	else if (vType == "Mode")
	{
		strcpy(szData, "");
	}
	else if (vType == "Status")
	{
		strcpy(szData, "");
	}	
	else if ((vType == "Current 1") || (vType == "Current 2") || (vType == "Current 3"))
	{
		strcpy(szData, "");
	}	
	else if (vType == "Instant")
	{
		strcpy(szData, "");
	}	
	else if ((vType == "Usage") || (vType == "Usage 1") || (vType == "Usage 2") )
	{
		strcpy(szData, "Watt");
	}	
	else if ((vType == "Delivery") || (vType == "Delivery 1") || (vType == "Delivery 2") )
	{
		strcpy(szData, "Watt");
	}
	else if (vType == "Usage current")
	{
		strcpy(szData, "Watt");
	}
	else if (vType == "Delivery current")
	{
		strcpy(szData, "Watt");
	}
	else if (vType == "Gas usage")
	{
		strcpy(szData, "");
	}
	else if (vType == "Weight")
	{
		strcpy(szData, "kg");
	}	
	else if (vType == "Voltage")
	{
		strcpy(szData, "V");
	}
	else if (vType == "Value")
	{
		strcpy(szData, "");
	}
	else if (vType == "Visibility")
	{
		if (metertype==0)
		{
			//km
			strcpy(szData, "km");
		}
		else
		{
			//miles
			strcpy(szData, "mi");
		}
	}
	else if (vType == "Solar Radiation")
	{
		strcpy(szData, "Watt/m2");
	}
	else if (vType == "Soil Moisture")
	{
		strcpy(szData, "cb");
	}
	else if (vType == "Leaf Wetness")
	{
		strcpy(szData, "");
	}
	else if (vType == "Percentage")
	{
		strcpy(szData, "%");
	}
	else if (vType == "Fanspeed")
	{
		strcpy(szData, "RPM");
	}
	else if (vType == "Pressure")
	{
		strcpy(szData, "Bar");
	}
	else if (vType == "Lux")
	{
		strcpy(szData, "Lux");
	}
	else if (vType == "Concentration")
	{
		strcpy(szData, "ppm");
	}
	if (szData[0] != '\0') { 
		std::string sendValue(szData);
		return sendValue;
	}
	// No unit
	return "";
}
예제 #19
0
int main(int argc, char const *argv[])
{
    int fd1[2];
    int fd2[2];

    if (pipe(fd1) == -1)
    {
        perror("pipe");
        exit(1);
    }

    if (pipe(fd2) == -1)
    {
        perror("pipe");
        exit(1);
    }


    pid_t pid;

    pid = fork();

    if (pid < 0)
    {
        perror("fork");
        exit(1);
    }
    else if (pid == 0) // Child process -> Reader
    {
        close(fd1[WRITE]);
        close(fd2[READ]);

        int values[2];

        read(fd1[READ], &values, sizeof(values));

        close(fd1[READ]);

        int sum =  values[0] + values[1];
        int diff = values[0] - values[1];
        int prod = values[0] * values[1];

        float quocient;
        if (values[1] != 0)
            quocient = (float)values[0] / (float)values[1];
        else
            quocient = NAN;


        sendValue(fd2[WRITE], TYPE_INTEGER, &sum);
        sendValue(fd2[WRITE], TYPE_INTEGER, &diff);
        sendValue(fd2[WRITE], TYPE_INTEGER, &prod);
        if (isnan(quocient))
            sendValue(fd2[WRITE], TYPE_INVALID, NULL);
        else
            sendValue(fd2[WRITE], TYPE_FLOAT, &quocient);

        close(fd2[WRITE]);

        _exit(0);
    }
    else if (pid > 0) // Father process -> Writer
    {
        close(fd1[READ]);
        close(fd2[WRITE]);
        int values[NUMS_TO_READ];

        printf("Insert two comma separated integers (example: 1, 2): ");
        fflush(stdout);

        scanf("%10d, %10d", &values[0], &values[1]);

        write(fd1[WRITE], values, sizeof(values));

        close(fd1[WRITE]);

        for (int i = 0; i < 4; ++i)
        {
            value val = receiveValue(fd2[READ]);
            printf(strOperations[i], values[0], values[1]);

            switch(val.t)
            {
                case TYPE_INTEGER:
                    printf("%d", val.val.i);
                    break;
                case TYPE_FLOAT:
                    printf("%f", val.val.f);
                    break;
                case TYPE_INVALID:
                    printf("invalid");
                    break;
            }

            printf("\n");
        }

        close(fd2[READ]);
        wait(NULL);

        exit(0);
    }
}
예제 #20
0
void CharAttrNoBlink()
{
	regDMM &= ~0x10;
	sendValue(0x4,regDMM);		// +8->invert, +20->background, +10->blink
}
예제 #21
0
void CharAttrBackGr()
{
	regDMM |= 0x20;
	sendValue(0x4,regDMM);		// +8->invert, +20->background, +10->blink
}
예제 #22
0
파일: LCD5110.cpp 프로젝트: a-dma/LCD5110
/**
 * Clear the dispplay
 */
void LCD5110::clearScreen(void){

  for (int i = 0; i < LCD5110::WIDTH * LCD5110::HEIGHT / 8; i++)
    sendValue(LCD5110::DATA, 0x00);

}
예제 #23
0
파일: PCfilter.C 프로젝트: dyninst/paradyn
void
valFilter::newData(pdRate newVal, relTimeStamp start, relTimeStamp end)
{
  // lack of forward progress signals a serious internal data handling error
  // in paradyn DM and will absolutely break the PC
  assert (end > lastDataSeen);
  // first, make adjustments to nextSendTime, partialIntervalStartTime,
  // and/or start to handle some special cases
  if (nextSendTime == relTimeStamp::Zero()) {
    // CASE 1: this is first data received since this filter was created.
    // We compute nextSendTime, the first possible send, and initialize 
    // partial interval to begin at time "start".
    getInitialSendTime(start);  
    partialIntervalStartTime = nextSendTime - intervalLength;
  } else if (start > lastDataSeen)  {
    // CASE 2: this is first data value after a gap in data.
    // We re-compute nextSendTime and reset partial interval (if any)
    // to begin at time "start".  if there was partial data before this 
    // new data came along, it is discarded since it may no longer 
    // be current. 
    updateNextSendTime(start);
    partialIntervalStartTime = nextSendTime - intervalLength;
  } else if (start < lastDataSeen) {
    // CASE 3: partially duplicate data after a fold
    // we've already seen data for a piece of this interval, so we reset 
    // the start time to use the new portion and ignore the rest
    start = lastDataSeen;
  }
  if (end > nextSendTime) {
  // CASE 4: first data value after a fold
  // call to updateNextSendTime will correctly adjust intervalSize
  // we roll back nextSendTime to last send, then recompute nextSendTime.
    nextSendTime = partialIntervalStartTime;
    updateNextSendTime (partialIntervalStartTime);
  }

  // now we update our running average, and send a data value to subscribers
  // if this datum fills an interval.
  // Note: because intervalLength is always set to 
  //       MAX(requested value, bucket size)
  // we never overlap more than one interval with a single datum

  timeLength currInterval = end - start;

 if (end >= nextSendTime) {
    // PART A: if we have a full interval of data, split off piece of 
    // data which is within interval (if needed) and send.
    timeLength pieceOfInterval = nextSendTime - start;
    workingValue += newVal * pieceOfInterval;
    workingInterval += pieceOfInterval;
    pdRate curValue(workingValue, workingInterval);
    sendValue(mi, curValue, partialIntervalStartTime, nextSendTime);
#ifdef PCDEBUG
    // debug printing
    if (performanceConsultant::printDataTrace) {
      cout << "FILTER SEND mi=" << mi << " mh=" << metric << " foc=" << foc 
	   << " value=" << curValue 
	   << "interval=" << start << " to " << end << endl;
    }
#endif

    // its important to update intervalLength only after we send a sample;
    // part of what this filtering accomplishes is keeping intervals correctly
    // aligned in spite of the unaligned data the data manager sends 
    // around a fold.  If you're not clear on what happens around a fold,
    // go find out before you try to change this code!!
    partialIntervalStartTime = nextSendTime;
    updateNextSendTime (nextSendTime);
    // adjust currInterval to contain only portion of time not just sent,   
    // since we already added the other portion to workingInterval above
    currInterval = currInterval - pieceOfInterval;     
  }

  // PART B: either the new value received did not complete an interval, 
  // or it did and there may be some remainder data.  If no remainder data,
  // currInterval will be 0 so workingValue and workingInterval will both
  // be set to 0.
  workingValue = newVal * currInterval;
  workingInterval = currInterval;
  lastDataSeen = end;
#ifdef PCDEBUG
  // debug printing
  if (performanceConsultant::printDataTrace) {
    cout << *this;
  }
#endif
}