TXSDateTime 类型数据赋值出现异常

yctg57358 2008-11-26 06:13:38
导入wsdl文件后生成如下文件
h文件
// ************************************************************************ //

#ifndef __wds9002ext_h__
#define __wds9002ext_h__

#include <System.hpp>
#include <InvokeRegistry.hpp>
#include <XSBuiltIns.hpp>
#include <SoapHTTPClient.hpp>


namespace NS_wds9002ext {

class RealDataItem;
class HisDataItem;

// ************************************************************************ //
// Namespace : urn:wds9002ext
// ************************************************************************ //
class RealDataItem : public TRemotable {
private:
int Fsend_id;
float Fv;
TXSDateTime* Ft;
public:
__fastcall ~RealDataItem();
__published:
__property int send_id = { read=Fsend_id, write=Fsend_id };
__property float v = { read=Fv, write=Fv };
__property TXSDateTime* t = { read=Ft, write=Ft };
};




// ************************************************************************ //
// Namespace : urn:wds9002ext
// ************************************************************************ //
class HisDataItem : public TRemotable {
private:
int Fsend_id;
float Fv;
TXSDateTime* Ft;
float Favg_v;
public:
__fastcall ~HisDataItem();
__published:
__property int send_id = { read=Fsend_id, write=Fsend_id };
__property float v = { read=Fv, write=Fv };
__property TXSDateTime* t = { read=Ft, write=Ft };
__property float avg_v = { read=Favg_v, write=Favg_v };
};


typedef DynamicArray<HisDataItem*> HisDataItems;
typedef DynamicArray<float> ArrayOf96Float;


// ************************************************************************ //
// Namespace : urn:wds9002ext
// ************************************************************************ //

typedef DynamicArray<BXFDataItem*> BXFDataItems;

// ************************************************************************ //
// Namespace : urn:wds9002ext
// transport : http://schemas.xmlsoap.org/soap/http
// style : document
// binding : wds9002ext
// service : wds9002ext
// port : wds9002ext
// URL : http://192.168.90.16:2556
// ************************************************************************ //
__interface INTERFACE_UUID("{648268D5-B889-F707-452C-B3A9A6A0EC22}") wds9002extPortType : public IInvokable
{
public:
virtual RealDataItem* getRealData(const int senid) = 0;
virtual HisDataItems getHisData(const int senid, const int type, const TXSDateTime* start_time, const TXSDateTime* end_time) = 0;

};
typedef DelphiInterface<wds9002extPortType> _di_wds9002extPortType;

_di_wds9002extPortType Getwds9002extPortType(bool useWSDL=false, AnsiString addr="");



#endif // __wds9002ext_h__

}; // wds9002ext

#if !defined(NO_IMPLICIT_NAMESPACE_USE)
using namespace NS_wds9002ext;
#endif
//-




///------CPP文件
#include <vcl.h>
#pragma hdrstop

#if !defined(__wds9002ext_h__)
#include "wds9002ext.h"
#endif



namespace NS_wds9002ext {

_di_wds9002extPortType Getwds9002extPortType(bool useWSDL, AnsiString addr)
{
static const char* defWSDL= "wds9002ext.wsdl";
static const char* defURL = "http://127.0.0.1:8991";
static const char* defSvc = "wds9002ext";
static const char* defPrt = "wds9002ext";
if (addr=="")
addr = useWSDL ? defWSDL : defURL;
THTTPRIO* rio = new THTTPRIO(0);
if (useWSDL) {
rio->WSDLLocation = addr;
rio->Service = defSvc;
rio->Port = defPrt;
} else {
rio->URL = addr;
}
_di_wds9002extPortType service;
rio->QueryInterface(service);
if (!service)
delete rio;
return service;
}


__fastcall RealDataItem::~RealDataItem()
{
delete Ft;
}

__fastcall HisDataItem::~HisDataItem()
{
delete Ft;
delete Fmin_t;
delete Fmax_t;
}

// ************************************************************************ //
// This routine registers the interfaces and types used by invoke the SOAP
// Service.
// ************************************************************************ //
static void RegTypes()
{
/* wds9002extPortType */
InvRegistry()->RegisterInterface(__interfaceTypeinfo(wds9002extPortType), L"urn:wds9002ext", L"UTF-8");
InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(wds9002extPortType), L"");
InvRegistry()->RegisterInvokeOptions(__interfaceTypeinfo(wds9002extPortType), ioDocument);
/* RealDataItem */
RemClassRegistry()->RegisterXSClass(__classid(RealDataItem), L"urn:wds9002ext", L"RealDataItem");
/* HisDataItem */
RemClassRegistry()->RegisterXSClass(__classid(HisDataItem), L"urn:wds9002ext", L"HisDataItem");
RemClassRegistry()->RegisterXSInfo(__arrayTypeinfo(HisDataItems), L"urn:wds9002ext", L"HisDataItems");
RemClassRegistry()->RegisterXSInfo(__arrayTypeinfo(ArrayOf96Float), L"urn:wds9002ext", L"ArrayOf96Float");
}
#pragma startup RegTypes 32

}; // wds9002ext

为什么调用getRealData时可以正常使用取到的TXSDateTime* 类型数据
但当给getHisData赋值时则不管使用AsDateTime还是Year等各分解时间赋值均抛出异常。
而用DateTimeToXSDateTime转换时取的时间均为1970-01-01
NS_wds9002ext::_di_wds9002extPortType wsdl_service;
NS_wds9002ext::RealDataItem *day_rain2;
TXSDateTime* AAA;
TXSDateTime* begin_1;
TXSDateTime* end_1;
day_rain2=wsdl_service->getRealData(111) ;
AAA= day_rain2->t;
//此时均正常
TDateTime dt_beg;
TDateTime dt_end;
dt_beg= StrToDateTime("2007-11-20 08:00:00");
dt_end= StrToDateTime("2007-11-21 08:00:00");
begin_1->AsDateTime=(dt_beg);end_1->AsDateTime =(dt_end); //使用此时编译通过,但运行到此抛出异常
begin_1=DateTimeToXSDateTime(dt_beg);end_1=DateTimeToXSDateTime(dt_end);//上句换作使用此时编译通过,运行getHisData时取时间均为1970-01-01
NS_wds9002ext::HisDataItems day_rain3;
day_rain3=wsdl_service->getHisData(6980109,1, begin_1,end_1);

即datetime类型直接赋值给TXSDateTime出现异常,将datetime类型转换成TXSDateTime不能成功。
如何给TXSDateTime赋值呢?




...全文
708 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
yctg57358 2008-11-28
  • 打赏
  • 举报
回复
可能是C++builder 6.0导入wsdl文件时生成代码有问题,用C++builder 2009 生成wdsl文件的.h、.cpp置换C++builder 6.0的文件
问题解决!
在此谢谢yuanreid的热心帮助
yuanreid 2008-11-27
  • 打赏
  • 举报
回复
getHisData是你调用的WebService,我理解后两个参数都是输出参数,值是被修改了的。这个逻辑需要看WebService的业务实现。
yctg57358 2008-11-27
  • 打赏
  • 举报
回复
getHisData从oracle数据库取数据集合,对应的参数一个是数据ID(number类型),一个数据类型(number类型),一个是起始时间(date类型),一个是结束时间(date类型)
yctg57358 2008-11-27
  • 打赏
  • 举报
回复
webservice 服务器端是VC写的,vc和vb都能正常调用,bcb中相关CLASS中TXSDateTime*类型的公共变量可以调用,但TXSDateTime*作为函数参数时
值却无法传递。
迷茫了好几天,把相关的XSBuiltIns.hpp、XSBuiltIns.pas都看了好几遍均未发现问题。
是否C++builder 6.0对delphi的TXSDateTime*支持上有问题?
yuanreid 2008-11-26
  • 打赏
  • 举报
回复
getHisData不知道是什么,帮不了你了
yctg57358 2008-11-26
  • 打赏
  • 举报
回复
day_rain3=wsdl_service->getHisData(6980109,1, begin_1,end_1);

返回的所取参数时间仍为1970-01-01 08:00:00,而不是2007-11-20 08:00:00
返回的值仍为空,实在是找不出问题所在,将所有文件中的TXSDateTime*换成WideString依然是1970
yuanreid 2008-11-26
  • 打赏
  • 举报
回复
第二个问题,也测试通过:


TXSDateTime* AAA;
TXSDateTime* begin_1 = new TXSDateTime();
TXSDateTime* end_1 = new TXSDateTime();
//此时均正常
TDateTime dt_beg;
TDateTime dt_end;
dt_beg= StrToDateTime("2007-11-20 08:00:00");
dt_end= StrToDateTime("2007-11-21 08:00:00");
//begin_1->AsDateTime=(dt_beg);end_1->AsDateTime =(dt_end);
begin_1=DateTimeToXSDateTime(dt_beg);end_1=DateTimeToXSDateTime(dt_end);
Caption = FormatDateTime("YYYY-MM-DD HH:NN:SS",begin_1->AsDateTime);
yuanreid 2008-11-26
  • 打赏
  • 举报
回复
运行出错是因为你的指针没有new,以下代码,我测试通过:

TXSDateTime* AAA;
TXSDateTime* begin_1 = new TXSDateTime();
TXSDateTime* end_1 = new TXSDateTime();
TDateTime dt_beg;
TDateTime dt_end;
dt_beg= StrToDateTime("2007-11-20 08:00:00");
dt_end= StrToDateTime("2007-11-21 08:00:00");
begin_1->AsDateTime=(dt_beg);end_1->AsDateTime =(dt_end);
内容概要:本文系统研究了基于W-GAN(Wasserstein生成对抗网络)的光伏出力场景生成方法,并提供了完整的Python代码实现。该方法充分利用W-GAN在捕捉复杂数据分布方面的优势,能够生成具有高度真实性与时序一致性的光伏发电功率场景,有效解决了传统场景生成方法在处理非线性、非平稳光伏数据时存在的模式坍塌与分布偏差问题。研究内容涵盖网络架构设计、梯度惩罚机制引入以保障训练稳定性、损失函数优化及生成样本质量评估等关键环节,生成的场景可用于电力系统规划、运行调度、储能配置及风险评估等任务,尤其适用于高比例可再生能源接入背景下的不确定性建模需求。; 适合人群:具备一定Python编程能力、深度学习基础理论知识的研究生、科研人员,以及从事新能源发电预测、电力系统优化调度等相关领域的工程技术人员。; 使用场景及目标:①实现光伏出力不确定性建模,生成满足统计特性的典型与极端功率场景;②支撑含光伏的微电网、主动配电网的优化调度、可靠性分析与韧性评估;③作为深度学习在能源时序数据生成领域的一个典型案例,服务于教学演示与学术研究。; 阅读建议:建议结合所提供的Python代码进行动手实践,重点理解W-GAN中判别器(Critic)结构、梯度惩罚项(Gradient Penalty)的实现原理,并通过可视化手段对比原始数据与生成数据的分布特征,进一步可尝试将其与传统GAN、VAE或DDPM等生成模型在场景多样性、保真度方面进行横向比较。

1,317

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder 网络及通讯开发
社区管理员
  • 网络及通讯开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧