1. 為了提速,沒用序列化,改自己寫對映。
2. 為了方便改動變數型別,都是分配8位元組。
3. 我這裡的body結構體一半是a端寫b端都,另一半是b端寫a端讀,看起來比較亂。
** charts
using system;
using system.io;
using system.collections.generic;
using system.collections.concurrent;
using system.linq;
using system.text;
using system.linq;
using system.threading;
using system.threading.tasks;
namespace mmf
public void free()
// 所有變數的讀寫函式
# region
public int readidread()
public void writeidread()
public int readidwrite()
public void writeidwrite()
public long readtimelastread()
public void writetimelastread()
public long readtimelastwrite()
public void writetimelastwrite()
public int readsizecharthead()
public void writesizecharthead()
public int readsizechartbody()
public void writesizechartbody()
public int readcapacity()
public void writecapacity()
public void read()
public void write()
# endregion
public bool canread()
public bool canwrite()
public int addidread()
public int addidwrite()
}[serializable]
public class chartbody
// 所有變數的讀寫函式
# region
public int readid()
public void writeid()
public int readreelnum()
public void writereelnum()
public float readrunpos()
public void writerunpos()
public int readrunstop()
public void writerunstop()
public int readsoftwarerunstate()
public void writesoftwarerunstate()
public int readsoftwaredetectstate()
public void writesoftwaredetectstate()
public int readsoftwarealarmstate()
public void writesoftwarealarmstate()
public long readtimeread()
public void writetimeread()
public long readtimewrite()
public void writetimewrite()
public string readordernum()
public void writeordernum()
# endregion
int getpos()
public void readplc()
public void writeplc()
public void readsoftware()
public void writesofeware()
}}
** server
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.io;
using system.threading;
namespace mmf
public void init()
public void initpreparam()
public void initrunningparam(bool bupdate)
public void initres()
public void free()
public void updaterunningdata()
public void start()
public void write()
}double aa = sw.elapsedmilliseconds / 1000.0;
string result = "title= software write \n" + aa;
system.windows.forms.messagebox.show(result);
headsoftware.idread = 0; headsoftware.writeidread();
headsoftware.idwrite = 0; headsoftware.writeidwrite();}}
}
** client
using system;
using system.collections.generic;
using system.linq;
using system.text;
using system.io;
using system.threading;
namespace mmf
public void init()
public void initpreparam()
public void initrunningparam(bool bupdate)
public void initres()
public void free()
public void updaterunningdata()
public void start()
public void read()
}double aa = sw.elapsedmilliseconds / 1000.0;
string result = "title= plc read \n" + aa;
system.windows.forms.messagebox.show(result);}}
}
記憶體檔案對映 程序間通訊
記憶體對映檔案可以分為兩種 一種是普通的檔案,它需要乙個普通的檔案控制代碼,用於快速的讀寫檔案,這種檔案的資料在程序退出後會儲存在硬碟上,所以程序在下次執行時可以得到之前的資料 另一種是頁檔案,當建立記憶體對映檔案的時候傳入無效的控制代碼,這時會把頁檔案當作臨時的共享儲存空間,當程序退出後這些資料是...
程序間通訊 記憶體對映
程序1的資料有時需要傳送給程序b,這可以通過記憶體對映實現。主要用到的函式 寫方式開啟對映,page writecopy 為寫操作留下備份 dword dwmaximumsizehigh,檔案對映的最大長度的高32位,一般設為0,用低32位一般就夠用了 dword dwmaximumsizelow,...
程序間通訊之記憶體對映 mmap記憶體對映
讀資料端程序 mmanp r.c include include include include include include define len 0x1000 int main close fd while 1 close fd munmap addr,len return 0 寫資料端程序 ...