Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Before commenting read Forum rules
Don't comment the topic if you have a new question.
You can create a new topic selecting correct category from Gurux Forum and then create a new topic selecting "New Topic" from the top left.
Good morning!
First of all, thank you in advance for any reply. I have developed a device simulator using Gurux as a server.
I'm trying to execute the action defined in the bluebook as enter(data)
protected override void PreAction(ValueEventArgs[] args)
{
foreach (var valueEventArg in args)
{
Logger.Information("{Method} {Target}:{LogicalName}", nameof(PreAction), valueEventArg.Target.GetType(),
valueEventArg.Target.LogicalName);
_companionServer.CompanionPreAction(valueEventArg, this);
}
}
------------------------------------------------------------------
public void CompanionPreAction(ValueEventArgs preActionArgs, DlmsServer dlmsServer)
{
switch (preActionArgs.Target)
{
case GXDLMSImageTransfer _:
HandleImageTransferActions(preActionArgs);
break;
case GXDLMSSecuritySetup _:
HandleSecuritySetupActions(preActionArgs);
break;
case GXDLMSClock _:
HandleClockRelativeTimeSetActions(preActionArgs);
break;
case GXDLMSDisconnectControl _:
HandleDisconnectControlActions(preActionArgs, dlmsServer);
break;
case GXDLMSTokenGateway _:
HandleTokenGatewayActions(preActionArgs);
break;
}
}
------------------------------------------------------------------
When it arrives to the server I try to assign the value of the structure in the response and I get no result.
1. If I just assign the value to the token it returns success but no data.
protected void HandleTokenGatewayActions(ValueEventArgs preActionArgs)
{
if (!(preActionArgs.Target is GXDLMSTokenGateway gxdlmsTokenGateway)) return;
switch (preActionArgs.Index)
{
case 1:
{
gxdlmsTokenGateway.Token = (byte[])preActionArgs.Parameters;
preActionArgs.Handled = true;
break;
}
}
}
-------------------------------------------------------------------
Request: C301C100730000132800FF0101090AAAAAAAAAAAAAAAAAAAAA
Response: C701C10000
<ActionResponse>
<ActionResponseNormal>
<!--Priority: HIGH ServiceClass: CONFIRMED invokeID: 1-->
<InvokeIdAndPriority Value="C1" />
<Result Value="Success" />
</ActionResponseNormal>
</ActionResponse>
2. If I try to assign the value of the attribute with the GetValues I get a ReadWriteDenied error.
protected virtual void HandleTokenGatewayActions(ValueEventArgs preActionArgs)
{
if (!(preActionArgs.Target is GXDLMSTokenGateway gxdlmsTokenGateway)) return;
switch (preActionArgs.Index)
{
case 1:
{
gxdlmsTokenGateway.Token = (byte[])preActionArgs.Parameters;
gxdlmsTokenGateway.StatusCode = TokenStatusCode.TokenExecutionOk;
gxdlmsTokenGateway.DataValue = Convert.ToString((byte)(101));
preActionArgs.Value = gxdlmsTokenGateway.GetValues()[5];
preActionArgs.Handled = true;
break;
}
}
}
Request: C301C100730000132800FF0101090AAAAAAAAAAAAAAAAAAAAA
Response: C701C10300
<ActionResponse>
<ActionResponseNormal>
<!--Priority: HIGH ServiceClass: CONFIRMED invokeID: 1-->
<InvokeIdAndPriority Value="C1" />
<Result Value="ReadWriteDenied" />
</ActionResponseNormal>
</ActionResponse>
3. If I try to assign a structure it also gives an error ReadWriteDenied
protected virtual void HandleTokenGatewayActions(ValueEventArgs preActionArgs)
{
if (!(preActionArgs.Target is GXDLMSTokenGateway gxdlmsTokenGateway)) return;
switch (preActionArgs.Index)
{
case 1:
{
gxdlmsTokenGateway.Token = (byte[])preActionArgs.Parameters;
gxdlmsTokenGateway.StatusCode = TokenStatusCode.TokenExecutionOk;
gxdlmsTokenGateway.DataValue = Convert.ToString((byte)(101));
var structure = new GXStructure
{
(byte)gxdlmsTokenGateway.StatusCode,
gxdlmsTokenGateway.DataValue
};
preActionArgs.Value = structure;
preActionArgs.Handled = true;
break;
}
}
}
-----------------------------------------------------------------
Request: C301C100730000132800FF0101090AAAAAAAAAAAAAAAAAAAAA
Response: C701C10300
<ActionResponse>
<ActionResponseNormal>
<!--Priority: HIGH ServiceClass: CONFIRMED invokeID: 1-->
<InvokeIdAndPriority Value="C1" />
<Result Value="ReadWriteDenied" />
</ActionResponseNormal>
</ActionResponse>
4. On the other hand, if I assign a string it returns an OctetString, but of course this is not what the client system expects.
protected virtual void HandleTokenGatewayActions(ValueEventArgs preActionArgs)
{
if (!(preActionArgs.Target is GXDLMSTokenGateway gxdlmsTokenGateway)) return;
switch (preActionArgs.Index)
{
case 1:
{
gxdlmsTokenGateway.Token = (byte[])preActionArgs.Parameters;
gxdlmsTokenGateway.StatusCode = TokenStatusCode.TokenExecutionOk;
gxdlmsTokenGateway.DataValue = Convert.ToString((byte)(101));
var buff = new GXByteBuffer();
buff.SetUInt8((byte)DataType.Structure);
buff.SetUInt8((byte)2);
SetData(new GXDLMSSettings(), buff, DataType.Enum, (object)gxdlmsTokenGateway.StatusCode);
SetData(new GXDLMSSettings(), buff, DataType.BitString, (object)gxdlmsTokenGateway.DataValue);
var result = (object)buff.Array();
preActionArgs.Value = result;
preActionArgs.Handled = true;
break;
}
}
}
-----------------------------------------------------------------------
request: C301C100730000132800FF0101090AAAAAAAAAAAAAAAAAAAAA
response: C701C10001000907020216030403A0
<ActionResponse>
<ActionResponseNormal>
<!--Priority: HIGH ServiceClass: CONFIRMED invokeID: 1-->
<InvokeIdAndPriority Value="C1" />
<Result Value="Success" />
<ReturnParameters>
<Data>
<OctetString Value="020216030403A0" />
</Data>
</ReturnParameters>
</ActionResponseNormal>
</ActionResponse>
Can someone help me? I am desperate. Thanks again for your trouble.
Rubent
Hi,
Hi,
#1.
if you set Handled = true then you need to return the value in preActionArgs.Value. Because there is no data, the reply is empty.
#2. and #3.
Is HandleTokenGatewayActions invoked or is error returned before? Are there any exceptions thrown?
BR,
Mikko