noflo 0.5.13 spreadsheet example broken? - noflo

I am new to noflo and looking at examples in order to explore it. The spreadsheet example looked interesting but I couldn't make it run. First, it takes some time and manual debugging to identify missing components, not a big deal and I believe will be improved in the future, for now the error message I get is
return process.component.outPorts[port].attach(socket);
^
TypeError: undefined is not a function
Apparently, before this isAddressable() was also undefined. Checked with this SO issue but I don't have any noflo 0.4 as a dependency anywhere. Spent some time to debug it but seemingly stuck at it, decided to post to SO.
The question is, what are the correct steps to run the spreadsheet example?
For reproduction, here is what I have done:
0) install the following components
noflo-adapters
noflo-core
noflo-couchdb
noflo-filesystem
noflo-groups
noflo-objects
noflo-packets
noflo-strings
noflo-tika
noflo-xml
i) edit spreadsheet/parse.fbp, because first error was
throw new Error("No outport '" + port + "' defined in process " + proc
^
Error: No outport 'error' defined in process Read (Read() ERROR -> IN Display())
apparently couchdb ReadDocument component does not provide Error outport. therefore replaced ReadDocument with ReadFile.
18c18
< 'tika-app-0.9.jar' -> TIKA Read(ReadDocument)
---
> 'tika-app-0.9.jar' -> TIKA Read(ReadFile)
ii) at this point, received the following:
if (process.component.outPorts[port].isAddressable()) {
^
TypeError: undefined is not a function
and improvised a stunt by checking if isAddressable is defined at this location of code:
## -259,9 +261,11 ##
throw new Error("No outport '" + port + "' defined in process " + process.id + " (" + (socket.getId()) + ")");
return;
}
- if (process.component.outPorts[port].isAddressable()) {
+ if (process.component.outPorts[port].isAddressable && process.component.outPorts[port].isAddressable()) {
return process.component.outPorts[port].attach(socket, index);
}
return process.component.outPorts[port].attach(socket);
};
and either way fails. Again, the question is What are the correct steps to run the spreadsheet example?
Thanks in advance.

Related

How to trace the data that is going through caches and DRAM memory in gem5?

--exec-flags Cache,DRAM show addresses and sizes, but sometimes I just need to see the actual data being sent.
I know that this might produce large logs, but that is fine as I'm restricting my area of interest well via --debug-start and -m/--debug-break (used a hack here to just finish the simulation at a tick).
https://gem5-users.gem5.narkive.com/VUAhxc7J/how-can-i-trace-data-of-cache mentions using CommMonitor. It is a bit annoying to have to modify the run script, but that's also a valid solution. It would be good to give a minimal example here that patches say se.py to add it and how to view its output.
I also have DPRINTF patch which seems to help and I'll try to publish. Here's a sketch:
## -385,14 +386,17 ## void
Packet::print(std::ostream &o, const int verbosity,
const std::string &prefix) const
{
- ccprintf(o, "%s%s [%x:%x]%s%s%s%s%s%s", prefix, cmdString(),
+ ccprintf(o, "%s%s [%x:%x]%s%s%s%s%s%s D=%llx", prefix, cmdString(),
getAddr(), getAddr() + getSize() - 1,
req->isSecure() ? " (s)" : "",
req->isInstFetch() ? " IF" : "",
req->isUncacheable() ? " UC" : "",
isExpressSnoop() ? " ES" : "",
req->isToPOC() ? " PoC" : "",
- req->isToPOU() ? " PoU" : "");
+ req->isToPOU() ? " PoU" : "",
+ flags.isSet(STATIC_DATA|DYNAMIC_DATA) ?
+ mem2hex_string(getConstPtr<const char>(), getSize())
+ : "");
}
and then implement mem2hex_string as shown at: C++ read binary file and convert to hex
Edit: I managed to add a CommMonitor by hacking se.py, but I could not see any memory value output in any files nor in its code, the only thing I could see was new stats being added, so not sure that can help at all.

PLC4X:Exception during scraping of Job

I'm actually developing a project that read data from 19 PLCs Siemens S1500 and 1 modicon. I have used the scraper tool following this tutorial:
PLC4x scraper tutorial
but when the scraper is working for a little amount of time I get the following exception:
I have changed the scheduled time between 1 to 100 and I always get the same exception when the scraper reach the same number of received messages.
I have tested if using PlcDriverManager instead of PooledPlcDriverManager could be a solution but the same problem persists.
In my pom.xml I use the following dependency:
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-scraper</artifactId>
<version>0.7.0</version>
</dependency>
I have tried to change the version to an older one like 0.6.0 or 0.5.0 but the problem still persists.
If I use the modicon (Modbus TCP) I also get this exception after a little amount of time.
Anyone knows why is happening this error? Thanks in advance.
Edit: With the scraper version 0.8.0-SNAPSHOT I continue having this problem.
Edit2: This is my code, I think the problem can be that in my scraper I am opening a lot of connections and when it reaches 65526 messages it fails. But since all the processing is happenning inside the lambda function and I'm using a PooledPlcDriverManager, I think the scraper is using only one connection so I dont know where is the mistake.
try {
// Create a new PooledPlcDriverManager
PlcDriverManager S7_plcDriverManager = new PooledPlcDriverManager();
// Trigger Collector
TriggerCollector S7_triggerCollector = new TriggerCollectorImpl(S7_plcDriverManager);
// Messages counter
AtomicInteger messagesCounter = new AtomicInteger();
// Configure the scraper, by binding a Scraper Configuration, a ResultHandler and a TriggerCollector together
TriggeredScraperImpl S7_scraper = new TriggeredScraperImpl(S7_scraperConfig, (jobName, sourceName, results) -> {
LinkedList<Object> S7_results = new LinkedList<>();
messagesCounter.getAndIncrement();
S7_results.add(jobName);
S7_results.add(sourceName);
S7_results.add(results);
logger.info("Array: " + String.valueOf(S7_results));
logger.info("MESSAGE number: " + messagesCounter);
// Producer topics routing
String topic = "s7" + S7_results.get(1).toString().substring(S7_results.get(1).toString().indexOf("S7_SourcePLC") + 9 , S7_results.get(1).toString().length());
String key = parseKey_S7("s7");
String value = parseValue_S7(S7_results.getLast().toString(),S7_results.get(1).toString());
logger.info("------- PARSED VALUE -------------------------------- " + value);
// Create my own Kafka Producer
ProducerRecord<String, String> record = new ProducerRecord<String, String>(topic, key, value);
// Send Data to Kafka - asynchronous
producer.send(record, new Callback() {
public void onCompletion(RecordMetadata recordMetadata, Exception e) {
// executes every time a record is successfully sent or an exception is thrown
if (e == null) {
// the record was successfully sent
logger.info("Received new metadata. \n" +
"Topic:" + recordMetadata.topic() + "\n" +
"Partition: " + recordMetadata.partition() + "\n" +
"Offset: " + recordMetadata.offset() + "\n" +
"Timestamp: " + recordMetadata.timestamp());
} else {
logger.error("Error while producing", e);
}
}
});
}, S7_triggerCollector);
S7_scraper.start();
S7_triggerCollector.start();
} catch (ScraperException e) {
logger.error("Error starting the scraper (S7_scrapper)", e);
}
So in the end indeed it was the PLC that was simply hanging up the connection randomly. However the NiFi integration should have handled this situation more gracefully. I implemented a fix for this particular error ... could you please give version 0.8.0-SNAPSHOT a try (or use 0.8.0 if we happen to have released it already)

Issue with obtaining the offline messages using openfire server

Offline messages are not delivering to the user when the person avails.
DelayInformation info = (DelayInformation)message.getExtension("x","jabber:x:delay");
returns null.
when i iterate the collection of message.getExtensions() , i get delay urn:xmpp:delay.
can anyone explain on this.
I'm using smack and smackx.jar. Though the smackx.jar has smack.providers it's not taken into account.
some suggested to use urn:xmpp:delay ,which results in class cast exception.
DelayInformation inf = (DelayInformation)message.getExtension("delay","urn:xmpp:delay");
Exception:
java.lang.ClassCastException: org.jivesoftware.smack.packet.DefaultPacketExtension
if this is for android by using the Smack Library try this:
ExtensionElement delay = message.getExtension("urn:xmpp:delay");
if(message.getExtension("urn:xmpp:delay") != null){
Log.i("RECVEIVED", "delay 1: " + delay.toXML());
Log.i("RECVEIVED", "delay 2: " + delay.getNamespace());
Log.i("RECVEIVED", "delay 3: " + delay.getElementName());
}
Log output:
I/RECVEIVED: delay 1: <delay xmlns='urn:xmpp:delay' stamp='2017-07-31T04:09:23.224+00:00' from='81.89.100.197'></delay>
I/RECVEIVED: delay 2: urn:xmpp:delay
I/RECVEIVED: delay 3: delay
this is another possibillity:
DelayInformation delayInformation = DelayInformation.from(message);
if (delayInformation != null) {
Log.i("RECVEIVED", "delay 1 : " + delayInformation.getStamp());
Log.i("RECVEIVED", "delay 2 : " + delayInformation.getStamp().getTime());
}
Log output:
I/RECVEIVED: delay 1: Mon Jul 31 06:08:58 GMT+02:00 2017
I/RECVEIVED: delay 2: 1501474138319
Good Luck
According to the document:
https://github.com/igniterealtime/Smack/wiki/Smack-4.2-Readme-and-Upgrade-Guide
f you are developing with smack 4.2 on java 7, you need the following dependencies to make it work:
compile "org.igniterealtime.smack:smack-java7:4.2.0"
// Optional for XMPPTCPConnection
compile "org.igniterealtime.smack:smack-tcp:4.2.0"
// Optional for XMPP-IM (RFC 6121) support (Roster, Threaded Chats, …)
compile "org.igniterealtime.smack:smack-im:4.2.0"
// Optional for XMPP extensions support
compile "org.igniterealtime.smack:smack-extensions:4.2.0"

How do I show Error Message using Managed Custom Actions with Windows Installer

I am writing a managed custom action. I am using the DTF Framework from Windows Installer Xml to wrap the managed dll into a usable CA dll. The CA does what it is supposed to, but I am still having trouble with error handling:
Dim record As New Record(1)
' Field 0 intentionally left blank
' Field 1 contains error number
record(1) = 27533
session.Message(InstallMessage.Error, record)
The above code produces the following text shown in the MSI log:
MSI (c) (C4 ! C6) [13:15:08:749]: Product: TestMSI -- Error 27533. The case-sensitive passwords do not match.
The error number refers to the code contained in the Error table within the MSI. The Message shown above is correct.
My problem is: Why does Windows Installer NOT create a dialog notifying the user about the error?
MSI can do this, but you need to OR in some extra values for the messageType argument.
eg.
Record record = new Record();
record.FormatString = string.Format("Something has gone wrong!");
session.Message(
InstallMessage.Error | (InstallMessage) ( MessageBoxIcon.Error ) |
(InstallMessage) MessageBoxButtons.OK,
record );
See this thread from the wix-users mailing list for more details.
I have run into the same problem, according to Wix: A Developer's Guide to Windows Installer XML by Nick Ramirez, the log and message methods don't work when a custom action is called from a UI control.
If you want a dialog to show up that contains the message, you must do it yourself.
Here's some code I use to do error handling in managed custom actions that run SQL.
It shows a messagebox if the installation is operating with a full UI.
It's in c# but hopefully you'll get the idea.
private void _handleSqlException(SqlException ex)
{
StringBuilder errorMessage = new StringBuilder();
errorMessage.Append("A SQL error has occurred.");
for (int i = 0; i < ex.Errors.Count; i++)
{
errorMessage.Append("Index #" + i + "\n" +
"Message: " + ex.Errors[i].Message + "\n" +
"LineNumber: " + ex.Errors[i].LineNumber + "\n" +
"Source: " + ex.Errors[i].Source + "\n" +
"Procedure: " + ex.Errors[i].Procedure + "\n");
}
session.Log(errorMessage);
if (session["UILevel"] == "5")
{
MessageBox.Show(errorMessage);
}
}

Script to change Action Sequence records in an MSI

To solve a problem listed here I've got to change the InstallExecuteSequence .RemoveExistingProducts record in an MSI.
I want to do this as part of the build process rather than mucking around with Orca
Modifying the MSI_SetProperty.js script gives
// MSI_SetActionSequence.js <msi-file> <table> <action> <sequence>
// Performs a post-build fixup of an msi to set the specified table/action/sequence
// Constant values from Windows Installer SDK
var msiOpenDatabaseModeTransact = 1;
var msiViewModifyInsert = 1;
var msiViewModifyUpdate = 2;
var msiViewModifyAssign = 3;
var msiViewModifyReplace = 4;
var msiViewModifyDelete = 6;
if (WScript.Arguments.Length != 4)
{
WScript.StdErr.WriteLine("Usage: " + WScript.ScriptName + " file table action sequence");
WScript.Quit(1);
}
var filespec = WScript.Arguments(0);
var table = WScript.Arguments(1);
var action = WScript.Arguments(2);
var sequence = parseInt(WScript.Arguments(3));
var installer = WScript.CreateObject("WindowsInstaller.Installer");
var database = installer.OpenDatabase(filespec, msiOpenDatabaseModeTransact);
WScript.StdOut.WriteLine("Looking for action:" + action);
try
{
var sql = "SELECT Action, Sequence FROM " + table + " WHERE Action = '" + action + "'";
var view = database.OpenView(sql);
view.Execute();
var record = view.Fetch();
if (record)
{
while (record)
{
WScript.StdOut.Write("Found: " + record.StringData(0) + ", " + record.StringData(1) + ", " + record.StringData(2));
if (record.IntegerData(2) != sequence)
{
WScript.StdOut.WriteLine(" - changing to " + sequence);
record.IntegerData(2) = sequence;
view.Modify(msiViewModifyUpdate,record);
}
else
WScript.StdOut.WriteLine(" - OK");
record = view.Fetch();
}
view.Close();
database.Commit();
}
else
{
view.Close();
throw("Warning - Could not find " + table + "." + action);
}
}
catch(e)
{
WScript.StdErr.WriteLine(e);
WScript.Quit(1);
}
To call this script to perform the change to the action sequence mentioned above you would put the following in a batch file and call that from the post build event e.g. PostBuildEvent = $(ProjectDir)PostBuild.bat
cscript.exe MSI_SetActionSequence.js YOURINSTALLER.MSI InstallExecuteSequence RemoveExistingProducts 1525
Some notes to others out there. I had the "Error 1001. The specified service already exists" problem, and tried the above and it didn't seem to work. Here's what I ran into:
* Make sure the RemovePreviousVersions property on your installer project is set to True. This seems obvious--obvious, that is, if you know about it. By default it is set to False. If False, the above procedure will not solve your problem. *
I have some assemblies installed in the GAC. It appears that when I moved the RemoveExistingProducts sequence that these files were removed from the GAC, but not reinstalled. To solve this I installed all assemblies in the Application Folder. FYI, I'm using VS2010.
Also, another nit-pick. If a user selects "Repair" when attempting to reinstall the same version of a product, they will still get "The specified service already exists" error. If I get time I'll try to fix this. If someone else out there knows how to fix it, could you post?
All that said, thanks for posting this!
The solution provided by Ryan addresses part of the issue I am facing. It does perform full uninstall, followed by install.
However, I have another issue, in my case some of the programs are running in the background. Before the installer can run, the installer complains that some of the files are in use. And gives standard dialog box asking for either to close the application, or restart to complete updating.
Is there a way, eg. a custom action or a setting, to kill the processes running in the background so that the installer goes smoothly?