RIAPS / riaps-integration

Tested collection of RIAPS packages for releases
Apache License 2.0
6 stars 3 forks source link

PMU network visibility inside riaps code #55

Closed iliesaya closed 5 years ago

iliesaya commented 5 years ago

I am not sure this is the correct place to ask a question about PMU and networking, please pardon me if not.

I am trying to read PMU data, just like in your wind curtailment example, with pypmu. I have a PMU simulator running on my PC, I can reach it and get values with the unit_test.py :

from utils.pmu_connection import PMUConnection
import time

pmu_connection = PMUConnection()
time.sleep(3)
print(pmu_connection.get_V_I())
pmu_connection.close()

So this is working, but what I don't understand is why this very same piece of code is failing to reach the PMU when it's deployed by riaps_ctrl and launched in riaps_deplo :

class SensorComponent(Component):
    def __init__(self):
        super(SensorComponent, self).__init__()
        self.pmu_connection = PMUConnection()
        self.logger.info("SensorComponent initialized")

[info]:[05-19-2019 07:01:50.843]:[3881]:MonitorActor.monitor:(PID 3881)-starting MonitorComponent, Sun May 19 07:01:50 2019 [2019-05-19 07:01:50.844] [discovery] [info] Register actor with PID - 3881 : /JustReadPMUapp/MonitorActor/ [2019-05-19 07:01:51.959] [discovery] [info] Lookup: /JustReadPMUapp/C37DataMessage/pub CONNECTING ['10.76.90.65', 4712, 1] ERROR:07:01:52,299:[3905]:utils.pypmu.pdc:[1] - Error while connecting to (10.76.90.65:4712) ERROR:07:01:52,299:[3905]:utils.pypmu.pdc:[Errno 111] Connection refused [info]:[05-19-2019 07:01:52.299]:[3905]:SensorActor.sensor:SensorComponent initialized

I tried something else : the VM dev box is running only the monitor , and 1 bbb is running the sensor. the bbb can reach and display the PMU data when I run the code in python alone, but same error when the code is launched by riaps_deplo :

May 19 12:12:58 bbb-e59a RIAPS-DEPLO[1964]: CONNECTING ['10.76.90.65', 4712, 1] May 19 12:12:58 bbb-e59a RIAPS-DEPLO[1964]: ERROR:12:12:58,879:[2662]:utils.pypmu.pdc:[1] - Error while connecting to (10.76.90.65:4712) May 19 12:12:58 bbb-e59a RIAPS-DEPLO[1964]: ERROR:12:12:58,885:[2662]:utils.pypmu.pdc:[Errno 110] Connection timed out May 19 12:12:58 bbb-e59a RIAPS-DEPLO[1964]: [info]:[05-19-2019 12:12:58.890]:[2662]:SensorActor.sensor:SensorComponent initialized

Did I miss something? thanks for your help

nie93 commented 5 years ago

Hi @iliesaya ,

This error message should be due to the unsuccessful connection between your PMU device and the pypmu. Please try to run some simple tests to see if you have got the connection strings correctly. Here are my suggestions:

  1. Use the PMUConnectionTester to see if your computer can establish connection to the PMU device. This requires Windows OS for installation. If not, it means that the PMU has been connecting to other host. You need to make sure that your computer can make successful connection to the PMU device.

  2. Use the simple Python script to test the connection in pypmu/tinyPDC.py. You may set the pypmu to the "DEBUG" mode to understand where the error comes from.

pdc.logger.setLevel("DEBUG")

Hope it helps! Jack

iliesaya commented 5 years ago

Dear @nie93 , thanks a lot for taking time to answer. Yes, I am testing my connection with PmuConnectionTester and it is working outside the execution inside riaps_deploy. I also have my own PMU simulator https://github.com/ALSETLab/PMU-PDC-StreamSimulator . To summarize :

PyPMU random pmu simulator, running on the same riaps dev VM (so I reach it with 127.0.0.1) --> riaps_deploy running on that same VM see it, WORKING

PyPMU random pmu simulator, running on a riaps dev VM and 1 bbb on the same network --> riaps_deploy running on that bbb don't see it, NOT WORKING (but the same code running in python but lanched manually, outside riaps_deploy work)

ALSETLab PMU simulator running on a PC , riaps dev VM see it , can connect if code is launched manually but not working if it's launched by riaps_deploy. Same behaviours on the bbb.

nie93 commented 5 years ago

Hi @iliesaya ,

Please let me know if I put it correctly.

In the first case, you run the pypmu's pmu simulator on VM, and a process on VM that connects and parses the PMU data packets. It is working.

In the second case, you run the pypmu's pmu simulator on VM, and a process on BBB that connects and parses the PMU data packets. It is not working.

In the third case, you run a software-base pmu simulator on PC, and the connection process on VM runs fine but not on BBB.

I am supposing the PMU simulators are working correctly since you can connect them from the other PC. What I think is the problem should come with the BBB's connection. Would you please just run a simple tinyPDC.py Python process on BBB's terminal (without riaps) to see what error message is showing? And you may also try to use wireshark to sniff the data packets transmitted between the simulator and the BBB.

Please note that I am not familiar with pypmu's pmu simulator, and I am only using the pdc functions in my case. For this part I have limited help on that, you may need to consult their GitHub page.

Best, Jack

MMetelko commented 5 years ago

If you have security enabled and the PMU is accessed via IP, the BBB node that runs the PMU device component must be enabled to access the IP network the PMU Is on. The default security enforces the rule that a RIAPS app running on a RIAPS node can access IP addresses the RIAPS app is running on (I.e. the ‘RIAPS App’s network’).

The simplest solution is to disable security (but this is not safe for an industrial installation). The more complex solution is to enable access via the deployment model (.depl file):

app App {
                // All hosts on the network can access DNS
                host all {
                                network dns;                                  
                }
                // This host 192.168.1.1 can access www.ibm.com  (can use IP address as well)
                host 192.168.1.1 {
                                network www.ibm.com;  
                }
                // This host 192.168.1.2 can access any IP addresses
                host 192.168.1.2 {
                                network any;                 
                }
                // Some example deployments
                on all ActorAll;                                                                   
                on (127.0.0.1,192.168.1.1) ActorPair;
                on (192.168.1.2) ActorNetwork;
}
iliesaya commented 5 years ago

Thank you both for your help. Disabling security solved the problem. Re-enabling the security and updating the .depl file as indicated by @MMetelko also solved the problem. now it's working well 👍