Giter Club home page Giter Club logo

Comments (4)

tuxedo0801 avatar tuxedo0801 commented on June 5, 2024

The KNX bus has no idea about which GA uses which DPT. You have to tell calimero the DPT, then you can convert it accordingly.
For the most common types, you find the converters here: https://github.com/calimero-project/calimero-core/tree/master/src/tuwien/auto/calimero/dptxlator

from calimero-core.

DanielDocekalFHTW avatar DanielDocekalFHTW commented on June 5, 2024

As i mentioned my problem is not the conversion from KNX encoded to human read able data.
I already used the DPTXlator to get the according Data right. My question was if i there is a way to "map" the human readable the DPTXlator returns to boolean values (true/false).
At the moment i made a workaround for the 1.xxx DPT's

private void print(final String svc, final ProcessEvent e) {
		try {
			System.out.println( e.getSourceAddr() + "->"
					+ e.getDestination() + " " + svc + ": "
					+ DataUnitBuilder.toHex(e.getASDU(), ""));	
			String id=DPM.get(e.getDestination()).getDPT();
			DPTXlator t;
			t = TranslatorTypes.createTranslator(0,id);
			t.setAppendUnit(false);
			t.setData(e.getASDU());
			String s=t.getValue();
			System.out.println("translation complete DPID:"+id+"Value:"+s);
			Boolean b=true;
			Float f=(float) -1;
			if(id.startsWith("1")){
				Integer val=Integer.valueOf(DataUnitBuilder.toHex(e.getASDU(), ""));
				b=Integer.valueOf(val).equals(1);
				System.out.println("bool");
			}
			else{
				f=Float.valueOf(s);
				System.out.println("float");
			}
			System.out.println("DPT ID:"+id+"B:"+b+"||F:"+f);
		} catch (KNXException e1) {
			// TODO Auto-generated catch block
			e1.printStackTrace();
		}
}

from calimero-core.

calimero-project avatar calimero-project commented on June 5, 2024

Use can use DPTXlatorBoolean::getValueBoolean. Also note, that in cases a numeric representation makes sense (including booleans), you can use DPTXlator::getNumericValue.

from calimero-core.

DanielDocekalFHTW avatar DanielDocekalFHTW commented on June 5, 2024

Thank you very much, this did the magic.

from calimero-core.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.