Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated to contain a toFileDirectoryEntry function for python #465

Open
wants to merge 3 commits into
base: v1.5
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions pyiec61850/iec61850.i
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,37 @@
#include <iec61850_client.h>
#include <iec61850_model.h>
#include <iec61850_server.h>

FileDirectoryEntry toFileDirectoryEntry(void* data)
{
return (FileDirectoryEntry) data;
}
FILE* openFile(char* name)
{
return fopen(name,"w+");
}

static bool IedConnection_downloadHandler(void* parameter, uint8_t* buffer, uint32_t bytesRead)
{
FILE* fp = (FILE*) parameter;

if(fp == NULL){
return false;
}
if (bytesRead > 0) {
if (fwrite(buffer, bytesRead, 1, fp) != 1) {
printf("Failed to write local file!\n");
fclose(fp);
return false;
}
}
fclose(fp);
return true;
}

IedClientGetFileHandler getIedconnectionDownloadHandler(){
return (IedClientGetFileHandler) &IedConnection_downloadHandler;
}
ModelNode* toModelNode(LogicalNode * ln)
{
return (ModelNode*) ln;
Expand Down Expand Up @@ -53,8 +84,13 @@ DataObject* toDataObject(ModelNode * MN)
typedef uint64_t msSinceEpoch;
typedef uint64_t nsSinceEpoch;

FILE* openFile(char*);
static bool IedConnection_downloadHandler(void*, uint8_t*, uint32_t);
IedClientGetFileHandler getIedconnectionDownloadHandler();

ModelNode* toModelNode(LogicalNode *);
ModelNode* toModelNode(DataObject *);
FileDirectoryEntry toFileDirectoryEntry(void*);
DataAttribute* toDataAttribute(DataObject *);
DataAttribute* toDataAttribute(ModelNode *);
DataObject* toDataObject(ModelNode *);
Expand Down