- 浏览: 79624 次
最新评论
-
zhangjie3140:
感谢分享
tabhost里解决按键事件捕获的问题 -
honghe:
请问我重写了 onCreateWindow,但处理window ...
在webview中访问互联网应用,碰到弹出窗口怎么办? -
肖默it:
解决了我的问题,感谢楼主的分享!
tabhost里解决按键事件捕获的问题 -
hecal:
太感谢了~~
tabhost里解决按键事件捕获的问题 -
guogzhao:
注意在if判断中要加一个event.getAction() = ...
tabhost里解决按键事件捕获的问题
.Net/C#: 实现支持断点续传多线程下载的 Http Web 客户端工具类 (C# DIY HttpWebClient)
/* .Net/C#: 实现支持断点续传多线程下载的 Http Web 客户端工具类 (C# DIY HttpWebClient)
* Reflector 了一下 System.Net.WebClient ,重载或增加了若干:
* DownLoad、Upload 相关方法!
* DownLoad 相关改动较大!
* 增加了 DataReceive、ExceptionOccurrs 事件!
* 了解服务器端与客户端交互的 HTTP 协议参阅:
* 使文件下载的自定义连接支持 FlashGet 的断点续传多线程链接下载! JSP/Servlet 实现!
* http://blog.csdn.net/playyuer/archive/2004/08/02/58430.aspx
* 使文件下载的自定义连接支持 FlashGet 的断点续传多线程链接下载! C#/ASP.Net 实现!
* http://blog.csdn.net/playyuer/archive/2004/08/02/58281.aspx
*/
namespace Microshaoft.Utils
{
using System;
using System.IO;
using System.Net;
using System.Text;
using System.Security;
using System.Threading;
using System.Collections.Specialized;
/// <summary>
/// 记录下载的字节位置
/// </summary>
public class DownLoadState
{
private string _FileName;
private string _AttachmentName;
private int _Position;
private string _RequestURL;
private string _ResponseURL;
private int _Length;
private byte[] _Data;
public string FileName
{
get
{
return _FileName;
}
}
public int Position
{
get
{
return _Position;
}
}
public int Length
{
get
{
return _Length;
}
}
public string AttachmentName
{
get
{
return _AttachmentName;
}
}
public string RequestURL
{
get
{
return _RequestURL;
}
}
public string ResponseURL
{
get
{
return _ResponseURL;
}
}
public byte[] Data
{
get
{
return _Data;
}
}
internal DownLoadState(string RequestURL, string ResponseURL, string FileName, string AttachmentName, int Position, int Length, byte[] Data)
{
this._FileName = FileName;
this._RequestURL = RequestURL;
this._ResponseURL = ResponseURL;
this._AttachmentName = AttachmentName;
this._Position = Position;
this._Data = Data;
this._Length = Length;
}
internal DownLoadState(string RequestURL, string ResponseURL, string FileName, string AttachmentName, int Position, int Length, ThreadCallbackHandler tch)
{
this._RequestURL = RequestURL;
this._ResponseURL = ResponseURL;
this._FileName = FileName;
this._AttachmentName = AttachmentName;
this._Position = Position;
this._Length = Length;
this._ThreadCallback = tch;
}
internal DownLoadState(string RequestURL, string ResponseURL, string FileName, string AttachmentName, int Position, int Length)
{
this._RequestURL = RequestURL;
this._ResponseURL = ResponseURL;
this._FileName = FileName;
this._AttachmentName = AttachmentName;
this._Position = Position;
this._Length = Length;
}
private ThreadCallbackHandler _ThreadCallback;
//
internal void StartDownloadFileChunk()
{
if (this._ThreadCallback != null)
{
this._ThreadCallback(this._RequestURL, this._FileName, this._Position, this._Length);
}
}
}
//委托代理线程的所执行的方法签名一致
public delegate void ThreadCallbackHandler(string S, string s, int I, int i);
//异常处理动作
public enum ExceptionActions
{
Throw,
CancelAll,
Ignore,
Retry
}
/// <summary>
/// 包含 Exception 事件数据的类
/// </summary>
public class ExceptionEventArgs : System.EventArgs
{
private System.Exception _Exception;
private ExceptionActions _ExceptionAction;
private DownLoadState _DownloadState;
public DownLoadState DownloadState
{
get
{
return _DownloadState;
}
}
public Exception Exception
{
get
{
return _Exception;
}
}
public ExceptionActions ExceptionAction
{
get
{
return _ExceptionAction;
}
set
{
_ExceptionAction = value;
}
}
internal ExceptionEventArgs(System.Exception e, DownLoadState DownloadState)
{
this._Exception = e;
this._DownloadState = DownloadState;
}
}
/// <summary>
/// 包含 DownLoad 事件数据的类
/// </summary>
public class DownLoadEventArgs : System.EventArgs
{
private DownLoadState _DownloadState;
public DownLoadState DownloadState
{
get
{
return _DownloadState;
}
}
public DownLoadEventArgs(DownLoadState DownloadState)
{
this._DownloadState = DownloadState;
}
}
/// <summary>
/// 支持断点续传多线程下载的类
/// </summary>
public class HttpWebClient
{
private static object _SyncLockObject = new object();
public delegate void DataReceiveEventHandler(HttpWebClient Sender, DownLoadEventArgs e);
public event DataReceiveEventHandler DataReceive; //接收字节数据事件
public delegate void ExceptionEventHandler(HttpWebClient Sender, ExceptionEventArgs e);
public event ExceptionEventHandler ExceptionOccurrs; //发生异常事件
private int _FileLength; //下载文件的总大小
public int FileLength
{
get
{
return _FileLength;
}
}
/// <summary>
/// 分块下载文件
/// </summary>
/// <param name="Address">URL 地址</param>
/// <param name="FileName">保存到本地的路径文件名</param>
/// <param name="ChunksCount">块数,线程数</param>
public void DownloadFile(string Address, string FileName, int ChunksCount)
{
int p = 0; // position
int s = 0; // chunk size
string a = null;
HttpWebRequest hwrq;
HttpWebResponse hwrp = null;
try
{
hwrq = (HttpWebRequest) WebRequest.Create(this.GetUri(Address));
hwrp = (HttpWebResponse) hwrq.GetResponse();
long L = hwrp.ContentLength;
hwrq.Credentials = this.m_credentials;
L = ((L == -1) || (L > 0x7fffffff)) ? ((long) 0x7fffffff) : L; //Int32.MaxValue 该常数的值为 2,147,483,647; 即十六进制的 0x7FFFFFFF
int l = (int) L;
this._FileLength = l;
// 在本地预定空间(竟然在多线程下不用先预定空间)
// FileStream sw = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
// sw.Write(new byte[l], 0, l);
// sw.Close();
// sw = null;
bool b = (hwrp.Headers["Accept-Ranges"] != null & hwrp.Headers["Accept-Ranges"] == "bytes");
a = hwrp.Headers["Content-Disposition"]; //attachment
if (a != null)
{
a = a.Substring(a.LastIndexOf("filename=") + 9);
}
else
{
a = FileName;
}
int ss = s;
if (b)
{
s = l / ChunksCount;
if (s < 2 * 64 * 1024) //块大小至少为 128 K 字节
{
s = 2 * 64 * 1024;
}
ss = s;
int i = 0;
while (l > s)
{
l -= s;
if (l < s)
{
s += l;
}
if (i++ > 0)
{
DownLoadState x = new DownLoadState(Address, hwrp.ResponseUri.AbsolutePath, FileName, a, p, s, new ThreadCallbackHandler(this.DownloadFileChunk));
// 单线程下载
// x.StartDownloadFileChunk();
//多线程下载
//Thread t =
new Thread(new ThreadStart(x.StartDownloadFileChunk)).Start();
//t.Start();
}
p += s;
}
s = ss;
byte[] buffer = this.ResponseAsBytes(Address, hwrp, s, FileName);
// lock (_SyncLockObject)
// {
// this._Bytes += buffer.Length;
// }
}
}
catch (Exception e)
{
ExceptionActions ea = ExceptionActions.Throw;
if (this.ExceptionOccurrs != null)
{
DownLoadState x = new DownLoadState(Address, hwrp.ResponseUri.AbsolutePath, FileName, a, p, s);
ExceptionEventArgs eea = new ExceptionEventArgs(e, x);
ExceptionOccurrs(this, eea);
ea = eea.ExceptionAction;
}
if (ea == ExceptionActions.Throw)
{
if (!(e is WebException) && !(e is SecurityException))
{
throw new WebException("net_webclient", e);
}
throw;
}
}
}
/// <summary>
/// 下载一个文件块,利用该方法可自行实现多线程断点续传
/// </summary>
/// <param name="Address">URL 地址</param>
/// <param name="FileName">保存到本地的路径文件名</param>
/// <param name="Length">块大小</param>
public void DownloadFileChunk(string Address, string FileName, int FromPosition, int Length)
{
HttpWebResponse hwrp = null;
string a = null;
try
{
//this._FileName = FileName;
HttpWebRequest hwrq = (HttpWebRequest) WebRequest.Create(this.GetUri(Address));
//hwrq.Credentials = this.m_credentials;
hwrq.AddRange(FromPosition);
hwrp = (HttpWebResponse) hwrq.GetResponse();
a = hwrp.Headers["Content-Disposition"]; //attachment
if (a != null)
{
a = a.Substring(a.LastIndexOf("filename=") + 9);
}
else
{
a = FileName;
}
byte[] buffer = this.ResponseAsBytes(Address, hwrp, Length, FileName);
// lock (_SyncLockObject)
// {
// this._Bytes += buffer.Length;
// }
}
catch (Exception e)
{
ExceptionActions ea = ExceptionActions.Throw;
if (this.ExceptionOccurrs != null)
{
DownLoadState x = new DownLoadState(Address, hwrp.ResponseUri.AbsolutePath, FileName, a, FromPosition, Length);
ExceptionEventArgs eea = new ExceptionEventArgs(e, x);
ExceptionOccurrs(this, eea);
ea = eea.ExceptionAction;
}
if (ea == ExceptionActions.Throw)
{
if (!(e is WebException) && !(e is SecurityException))
{
throw new WebException("net_webclient", e);
}
throw;
}
}
}
internal byte[] ResponseAsBytes(string RequestURL, WebResponse Response, long Length, string FileName)
{
string a = null; //AttachmentName
int P = 0; //整个文件的位置指针
int num2 = 0;
try
{
a = Response.Headers["Content-Disposition"]; //attachment
if (a != null)
{
a = a.Substring(a.LastIndexOf("filename=") + 9);
}
long num1 = Length; //Response.ContentLength;
bool flag1 = false;
if (num1 == -1)
{
flag1 = true;
num1 = 0x10000; //64k
}
byte[] buffer1 = new byte[(int) num1];
int p = 0; //本块的位置指针
string s = Response.Headers["Content-Range"];
if (s !=null)
{
s = s.Replace("bytes ", "");
s = s.Substring(0, s.IndexOf("-"));
P = Convert.ToInt32(s);
}
int num3 = 0;
Stream S = Response.GetResponseStream();
do
{
num2 = S.Read(buffer1, num3, ((int) num1) - num3);
num3 += num2;
if (flag1 && (num3 == num1))
{
num1 += 0x10000;
byte[] buffer2 = new byte[(int) num1];
Buffer.BlockCopy(buffer1, 0, buffer2, 0, num3);
buffer1 = buffer2;
}
// lock (_SyncLockObject)
// {
// this._bytes += num2;
// }
if (num2 > 0)
{
if (this.DataReceive != null)
{
byte[] buffer = new byte[num2];
Buffer.BlockCopy(buffer1, p, buffer, 0, buffer.Length);
DownLoadState dls = new DownLoadState(RequestURL, Response.ResponseUri.AbsolutePath, FileName, a, P, num2, buffer);
DownLoadEventArgs dlea = new DownLoadEventArgs(dls);
//触发事件
this.OnDataReceive(dlea);
//System.Threading.Thread.Sleep(100);
}
p += num2; //本块的位置指针
P += num2; //整个文件的位置指针
}
else
{
break;
}
}
while (num2 != 0);
S.Close();
S = null;
if (flag1)
{
byte[] buffer3 = new byte[num3];
Buffer.BlockCopy(buffer1, 0, buffer3, 0, num3);
buffer1 = buffer3;
}
return buffer1;
}
catch (Exception e)
{
ExceptionActions ea = ExceptionActions.Throw;
if (this.ExceptionOccurrs != null)
{
DownLoadState x = new DownLoadState(RequestURL, Response.ResponseUri.AbsolutePath, FileName, a, P, num2);
ExceptionEventArgs eea = new ExceptionEventArgs(e, x);
ExceptionOccurrs(this, eea);
ea = eea.ExceptionAction;
}
if (ea == ExceptionActions.Throw)
{
if (!(e is WebException) && !(e is SecurityException))
{
throw new WebException("net_webclient", e);
}
throw;
}
return null;
}
}
private void OnDataReceive(DownLoadEventArgs e)
{
//触发数据到达事件
DataReceive(this, e);
}
public byte[] UploadFile(string address, string fileName)
{
return this.UploadFile(address, "POST", fileName, "file");
}
public string UploadFileEx(string address, string method, string fileName, string fieldName)
{
return Encoding.ASCII.GetString(UploadFile(address, method, fileName, fieldName));
}
public byte[] UploadFile(string address, string method, string fileName, string fieldName)
{
byte[] buffer4;
FileStream stream1 = null;
try
{
fileName = Path.GetFullPath(fileName);
string text1 = "---------------------" + DateTime.Now.Ticks.ToString("x");
string text2 = "application/octet-stream";
stream1 = new FileStream(fileName, FileMode.Open, FileAccess.Read);
WebRequest request1 = WebRequest.Create(this.GetUri(address));
request1.Credentials = this.m_credentials;
request1.ContentType = "multipart/form-data; boundary=" + text1;
request1.Method = method;
string[] textArray1 = new string[7] {"--", text1, "/r/nContent-Disposition: form-data; name=/"" + fieldName + "/"; filename=/"", Path.GetFileName(fileName), "/"/r/nContent-Type: ", text2, "/r/n/r/n"};
string text3 = string.Concat(textArray1);
byte[] buffer1 = Encoding.UTF8.GetBytes(text3);
byte[] buffer2 = Encoding.ASCII.GetBytes("/r/n--" + text1 + "/r/n");
long num1 = 0x7fffffffffffffff;
try
{
num1 = stream1.Length;
request1.ContentLength = (num1 + buffer1.Length) + buffer2.Length;
}
catch
{
}
byte[] buffer3 = new byte[Math.Min(0x2000, (int) num1)];
using (Stream stream2 = request1.GetRequestStream())
{
int num2;
stream2.Write(buffer1, 0, buffer1.Length);
do
{
num2 = stream1.Read(buffer3, 0, buffer3.Length);
if (num2 != 0)
{
stream2.Write(buffer3, 0, num2);
}
}
while (num2 != 0);
stream2.Write(buffer2, 0, buffer2.Length);
}
stream1.Close();
stream1 = null;
WebResponse response1 = request1.GetResponse();
buffer4 = this.ResponseAsBytes(response1);
}
catch (Exception exception1)
{
if (stream1 != null)
{
stream1.Close();
stream1 = null;
}
if (!(exception1 is WebException) && !(exception1 is SecurityException))
{
//throw new WebException(SR.GetString("net_webclient"), exception1);
throw new WebException("net_webclient", exception1);
}
throw;
}
return buffer4;
}
private byte[] ResponseAsBytes(WebResponse response)
{
int num2;
long num1 = response.ContentLength;
bool flag1 = false;
if (num1 == -1)
{
flag1 = true;
num1 = 0x10000;
}
byte[] buffer1 = new byte[(int) num1];
Stream stream1 = response.GetResponseStream();
int num3 = 0;
do
{
num2 = stream1.Read(buffer1, num3,((int) num1) - num3);
num3 += num2;
if (flag1 && (num3 == num1))
{
num1 += 0x10000;
byte[] buffer2 = new byte[(int) num1];
Buffer.BlockCopy(buffer1, 0, buffer2, 0, num3);
buffer1 = buffer2;
}
}
while (num2 != 0);
stream1.Close();
if (flag1)
{
byte[] buffer3 = new byte[num3];
Buffer.BlockCopy(buffer1, 0, buffer3, 0, num3);
buffer1 = buffer3;
}
return buffer1;
}
private NameValueCollection m_requestParameters;
private Uri m_baseAddress;
private ICredentials m_credentials = CredentialCache.DefaultCredentials;
public ICredentials Credentials
{
get
{
return this.m_credentials;
}
set
{
this.m_credentials = value;
}
}
public NameValueCollection QueryString
{
get
{
if (this.m_requestParameters == null)
{
this.m_requestParameters = new NameValueCollection();
}
return this.m_requestParameters;
}
set
{
this.m_requestParameters = value;
}
}
public string BaseAddress
{
get
{
if (this.m_baseAddress != null)
{
return this.m_baseAddress.ToString();
}
return string.Empty;
}
set
{
if ((value == null) || (value.Length == 0))
{
this.m_baseAddress = null;
}
else
{
try
{
this.m_baseAddress = new Uri(value);
}
catch (Exception exception1)
{
throw new ArgumentException("value", exception1);
}
}
}
}
private Uri GetUri(string path)
{
Uri uri1;
try
{
if (this.m_baseAddress != null)
{
uri1 = new Uri(this.m_baseAddress, path);
}
else
{
uri1 = new Uri(path);
}
if (this.m_requestParameters == null)
{
return uri1;
}
StringBuilder builder1 = new StringBuilder();
string text1 = string.Empty;
for (int num1 = 0; num1 < this.m_requestParameters.Count; num1++)
{
builder1.Append(text1 + this.m_requestParameters.AllKeys[num1] + "=" + this.m_requestParameters[num1]);
text1 = "&";
}
UriBuilder builder2 = new UriBuilder(uri1);
builder2.Query = builder1.ToString();
uri1 = builder2.Uri;
}
catch (UriFormatException)
{
uri1 = new Uri(Path.GetFullPath(path));
}
return uri1;
}
}
}
/// <summary>
/// 测试类
/// </summary>
class AppTest
{
static void Main()
{
AppTest a = new AppTest();
Microshaoft.Utils.HttpWebClient x = new Microshaoft.Utils.HttpWebClient();
//订阅 DataReceive 事件
x.DataReceive += new Microshaoft.Utils.HttpWebClient.DataReceiveEventHandler(a.x_DataReceive);
//订阅 ExceptionOccurrs 事件
x.ExceptionOccurrs += new Microshaoft.Utils.HttpWebClient.ExceptionEventHandler(a.x_ExceptionOccurrs);
string F = "http://localhost/download/phpMyAdmin-2.6.1-pl2.zip";
a._F = F;
F = "http://localhost/download/jdk-1_5_0_01-windows-i586-p.aa.exe";
//F = "http://localhost/download/ReSharper1.5.exe";
//F = "http://localhost/mywebapplications/WebApplication7/WebForm1.aspx";
//F = "http://localhost:1080/test/download.jsp";
//F = "http://localhost/download/Webcast20050125_PPT.zip";
//F = "http://www.morequick.com/greenbrowsergb.zip";
//F = "http://localhost/download/test_local.rar";
string f = F.Substring(F.LastIndexOf("/") + 1);
//(new System.Threading.Thread(new System.Threading.ThreadStart(new ThreadProcessState(F, @"E:/temp/" + f, 10, x).StartThreadProcess))).Start();
x.DownloadFile(F, @"E:/temp/temp/" + f, 10);
// x.DownloadFileChunk(F, @"E:/temp/" + f,15,34556);
System.Console.ReadLine();
// Upload 测试
// string uploadfile = "e://test_local.rar";
// string str = x.UploadFileEx("http://localhost/phpmyadmin/uploadaction.php", "POST", uploadfile, "file1");
// System.Console.WriteLine(str);
// System.Console.ReadLine();
}
string bs = ""; //用于记录上次的位数
bool b = false;
private int i = 0;
private static object _SyncLockObject = new object();
string _F;
string _f;
private void x_DataReceive(Microshaoft.Utils.HttpWebClient Sender, Microshaoft.Utils.DownLoadEventArgs e)
{
if (!this.b)
{
lock (_SyncLockObject)
{
if (!this.b)
{
System.Console.Write(System.DateTime.Now.ToString() + " 已接收数据: ");
//System.Console.Write( System.DateTime.Now.ToString() + " 已接收数据: ");
this.b = true;
}
}
}
string f = e.DownloadState.FileName;
if (e.DownloadState.AttachmentName != null)
f = System.IO.Path.GetDirectoryName(f) + @"/" + e.DownloadState.AttachmentName;
this._f = f;
using (System.IO.FileStream sw = new System.IO.FileStream(f, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite))
{
sw.Position = e.DownloadState.Position;
sw.Write(e.DownloadState.Data, 0,
e.DownloadState.Data.Length);
sw.Close();
}
string s = System.DateTime.Now.ToString();
lock (_SyncLockObject)
{
this.i += e.DownloadState.Data.Length;
System.Console.Write(bs + "/b/b/b/b/b/b/b/b/b/b" + i + " / " + Sender.FileLength + " 字节数据 " + s);
//System.Console.Write(bs + i + " 字节数据 " + s);
this.bs = new string('/b', Digits(i) + 3 + Digits(Sender.FileLength) + s.Length);
}
}
int Digits(int n) //数字所占位数
{
n = System.Math.Abs(n);
n = n / 10;
int i = 1;
while (n > 0)
{
n = n / 10;
i++;
}
return i;
}
private void x_ExceptionOccurrs(Microshaoft.Utils.HttpWebClient Sender, Microshaoft.Utils.ExceptionEventArgs e)
{
System.Console.WriteLine(e.Exception.Message);
//发生异常重新下载相当于断点续传,你可以自己自行选择处理方式或自行处理
Microshaoft.Utils.HttpWebClient x = new Microshaoft.Utils.HttpWebClient();
x.DownloadFileChunk(this._F, this._f, e.DownloadState.Position, e.DownloadState.Length);
e.ExceptionAction = Microshaoft.Utils.ExceptionActions.Ignore;
}
}
/*
* 用于 upload 测试的 Action php:
http://localhost/phpmyadmin/uploadaction.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
</HEAD>
<BODY>
<?php
print_r($_REQUEST);
$uploadDir = '';
$uploadFile = $uploadDir . $_FILES['file1']['name'];
print "<pre>";
if (move_uploaded_file($_FILES['file1']['tmp_name'], $uploadFile))
{
print "File is valid, and was successfully uploaded. ";
}
else
{
print "Possible file upload attack! Here's some debugging info:/n";
print_r($_FILES);
}
print "</pre>";
?>
</BODY>
</HTML>
*/
相关推荐
在C#编程中,实现一个支持断点续传和多线程下载的HTTP Web客户端工具类是一项复杂但实用的任务。断点续传允许用户在下载过程中中断,然后在稍后的时间点继续下载,而不会丢失已下载的数据。多线程下载则能显著提高大...
这个示例展示了如何使用C#来实现这样的动态调用。 首先,我们引入了多个命名空间,这些命名空间提供了用于处理XML、网络通信、编译和反射的关键功能。如`Microsoft.CSharp`、`System.Net`、`System.Reflection`和`...
基于模拟退火算法与A*算法融合的送餐机器人多目标点路径规划策略,多目标点路径规划---模拟 火算法+A*算法 送餐机器人多目标点路径规划,室内AGV路径规划。 基于模拟 火算法融合A*算法的移动机器人路径规划 1,从厨房出发,移动到多个目标点,最后返回厨房。 2,采用A*算法规划两点间的距离,然后依据规划路径距离模拟 火算法运算全过程最短距离。 旅行商的室内规划应用 ,多目标点路径规划; 模拟退火算法; A*算法; 送餐机器人; 室内AGV路径规划; 移动机器人路径规划; 厨房出发; 最短距离; 旅行商应用。,基于模拟退火算法与A*算法融合的送餐机器人多目标点路径规划系统
"谐波抑制Matlab Simulink仿真实践:有源无源混合型(PPF、APF)滤波效果对比报告",谐波抑制matlab simulink仿真,包含有源无源混合(ppf、apf,混合型)效果好可参考,有报告,下图为ppf滤波前后对比 ,谐波抑制; MATLAB Simulink仿真; 有源无源混合滤波; PPF与APF混合型; 滤波效果; 报告对比,Matlab Simulink仿真:混合型谐波抑制技术报告
线上一流课程教学辅助系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程 启动教程:https://www.bilibili.com/video/BV1jKDjYrEz1 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
沉浸式戏曲文化体验系统 免费JAVA毕业设计 2024成品源码+论文+录屏+启动教程 启动教程:https://www.bilibili.com/video/BV1jKDjYrEz1 项目讲解视频:https://www.bilibili.com/video/BV1Tb421n72S 二次开发教程:https://www.bilibili.com/video/BV18i421i7Dx
基于Matlab GUI界面的工件尺寸测量系统:数字图像处理技术在机械零件测量中的应用,- 标题:基于Matlab的工件测量系统 - 关键词:matlab GUI界面 工件尺寸测量 圆 长方形 直径 周长 数字图像处理 - 步骤:打开图像 选择标签 灰度化 滤波(中值,均值,高斯) 二值化 边缘检测 尺寸测量 结果绘制在在GUI上 - 简述:使用matlab数字图像处理技术,处理锯片,垫片,螺丝等机械零件的尺寸,只要包含半径(内径和外径),周长,长宽等,并在原图上进行绘制,并展示在界面上。 ,Matlab; GUI界面; 图像处理; 尺寸测量; 圆; 长方形; 半径; 周长; 边缘检测; 机械零件,"基于Matlab GUI界面的工件尺寸测量系统"
FDTD COMSOL技术下的超结构与超表面光吸收与分光滤波模型:一维至三维SPP偏振模型的自研与文献参考,FDTD COMSOL现有MIM超结构模型,超表面超吸收分光滤波SPP模型(一维光栅,二维光栅,三维超表面,偏振模型),介质超表面BIC模型等都是自己做的,文献参考, ,关键词:FDTD;COMSOL;MIM超结构模型;超表面超吸收分光滤波SPP模型;一维光栅;二维光栅;三维超表面;偏振模型;介质超表面BIC模型;文献参考,自研MIM超结构及多类超表面光学模型集
"金豺优化算法在冷热电联供系统优化调度中的应用:基于MATLAB平台的仿真与实证研究",金豺优化算法(2022年)冷热电联优化调度 说明书MATLAB代码:基于金豺优化算法冷热电联优化调度 关键词: 冷热电三联供 金豺优化算法 仿真平台:MATLAB 平台采用金豺优化算法实现求解优势:代码注释详实,适合参考学习,程序非常精品,请仔细辨识 主要内容:代码构建了含冷、热、电负荷的冷热电联供型系统优化调度模型,考虑了各出力源出力成本及环境污染治理成本、分时电价,考虑了光伏、风机、燃气轮机、燃料电池、电制冷机、电锅炉、余热回收以及蓄电池、蓄热装置、蓄冷装置等资源,并且考虑与上级电网的购电,考虑了燃机出力的非线性,实现CCHP系统的经济运行,求解效果极佳,具体可以看图 ,冷热电三联供;金豺优化算法;MATLAB平台;系统优化调度模型;资源利用;经济运行;求解效果极佳;CCHP系统;非线性问题;详实注释。,《基于金豺优化算法的冷热电联供系统MATLAB仿真优化调度说明书》
,永磁同步电机伺服控制仿真三环PI参数自整定 Matlab仿真模型 1.模型简介 模型为永磁同步电机伺服控制仿真,采用 Matlab R2018a Simulink搭建。 模型内主要包含DC直流电压源、三相逆变器、永磁同步电机、采样模块、SVPWM、Clark、Park、Ipark、位置环、速度环、电流环等模块,其中,SVPWM、Clark、Park、Ipark模块采用Matlab funtion编写,其与C语言编程较为接近,容易进行实物移植。 模型均采用离散化仿真,其效果更接近实际数字控制系统。 2.算法简介 伺服控制由位置环、速度环、电流环三环结构构成,其中,电流环采用PI控制,并具有电流环解耦功能;转速环采用抗积分饱和PI控制;位置环采用P+前馈的复合控制,能够更好地跟踪指令信号。 本仿真中最大的亮点是三环PI参数自整定,只需输入正确的电机参数(电阻、电感、转动惯量等参数),无需手动调节PI参数,能够节省调试时间。 3.仿真效果 位置响应波形,如下图所示。 转速响应波形,如下图所示。 转矩电流响应波形,如下图所示。 4. 可提供模型
基于西门子PLC与组态王技术的锅炉控制系统设计与应用,13基于西门子PLC和组态王锅炉控制系统 ,基于西门子PLC; 锅炉控制系统; 组态王; 自动化控制,基于西门子PLC与组态王锅炉控制系统研究
转子动力学与模态分析:临界转速计算与稳定状态下的轴心轨迹分析,圆盘质量不平衡条件下的振动响应及操作视频解析。,转子动力学,模态分析求临界转速,稳定状态下转子轴心轨迹,圆盘质量不平衡条件下振动响应+操作视频。 ,转子动力学;模态分析;临界转速;稳定状态;轴心轨迹;质量不平衡;振动响应;操作视频。,转子动力学分析:模态与振动响应研究视频
一阶直线倒立摆非线性动力学模型的MATLAB Simulink仿真研究:模型推导、S-Function实现与离散PID控制的测试服务,一阶直线倒立摆MATLAB Simulink仿真 (1)模型推导 + 仿真工程 (2)讲解服务 主要保留模型的非线性动力学特性,即不在平衡点做线性化处理; (1)MathType 详细推导二阶非线性微分方程 (2)S-Function 实现非线性连续状态空间模型 (3)测试离散PID控制倒立摆重心变化适应性 #倒立摆 #MATLAB #Simulink #离散控制 #S-Function ,一阶直线倒立摆; MATLAB Simulink 仿真; 模型推导与仿真工程; 非线性动力学特性; MathType 推导; S-Function 实现; 离散PID控制; 重心变化适应性。,一阶直线倒立摆非线性动力学MATLAB Simulink仿真研究
基于AHP-CRITIC组合变权与指标劣化度修正的赋权方法研究,38考虑劣化度APH-CRITIC组合变权 组合变权赋权方法,基于AHP和改进CRITIC计算主客观权重,引入指标劣化度构造变权函数对综合权重进行修正,还方法可以捕捉指标时序的劣化程度,实现数据的有效跟踪,评价更加合理。 可根据需求进行改进。 ,关键词:组合变权赋权方法;AHP;CRITIC;指标劣化度;变权函数;时序劣化程度;数据跟踪;评价合理。,基于AHP-CRITIC组合变权法:综合主客观权重与指标劣化度评价
基于两并联虚拟阻抗下垂控制的微电网有功功率共享技术研究及其应用效果分析——有参考文献支撑,微电网,下垂控制,两并联阻抗下垂控制,实现了有功功率共享,效果好,有参考文献。 ,微电网;下垂控制;两并联虚拟阻抗下垂控制;有功功率共享;参考文献,微电网两并联虚拟阻抗下垂控制技术实现有功共享,效果显著,有参考文献支持。
MATLAB仿真湍流相位屏相位结构函数:功率谱反演法及其低频信息补偿优化研究,MATLAB仿真湍流相位屏相位结构函数 功率谱反演法 补偿低频信息达到与理论更好的拟合程度 ,MATLAB仿真; 湍流相位屏; 相位结构函数; 功率谱反演法; 低频信息补偿; 理论拟合,MATLAB仿真湍流相位屏结构与功率谱反演法优化研究
棋盘设计: 创建一个 15x15 的棋盘,用户可以点击每个格子放置棋子。 棋子颜色: 黑方和白方棋子通过 CSS 样式显示为圆形。 胜利检测: 检查横向、纵向和对角线的五子连珠以判断胜利。 游戏重置: 游戏可以重置,重新开始。 重新开始按钮: 点击后重置游戏状态,清空棋盘。 退出游戏按钮: 点击后弹出确认对话框,确认后尝试关闭窗口。
基于f(x,y,z,t)的高斯烟团模型纯Python代码实现:大气稳定度计算、坐标转换与扩散系数分析,三维浓度叠加值的计算研究,基于f(x,y,z,t)的高斯烟团模型纯Python代码实现(包涵大气稳定度计算、坐标转,扩散系数以及三维坐标系内浓度叠加值) ,核心关键词:f(x,y,z,t)高斯烟团模型; 大气稳定度计算; 坐标转换; 扩散系数; 三维坐标系内浓度叠加值; 纯Python代码实现;,Python实现高斯烟团模型的大气扩散浓度计算代码
基于ADRC的主动悬架控制技术:设计观测器与非线性误差反馈控制器的优化研究,基于ADRC的主动悬架控制: 1.设计观测器 2.非线性误差反馈控制器。 相同参数下,优于pid的调节效果。 并且可查看观测器对比被控对象效果模型绝对正确 参考文献(仅用于学术交流) ,基于ADRC的主动悬架控制; 观测器设计; 非线性误差反馈控制器; 调节效果优于PID; 观测器对比被控对象效果模型绝对正确,基于ADRC的主动悬架:观测器设计与非线性误差反馈控制
matlab实现CNN时序预测完整程序+数据